-
Notifications
You must be signed in to change notification settings - Fork 0
/
index copy.js
34 lines (30 loc) · 952 Bytes
/
index copy.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// Imports the Google Cloud client library
const speech = require('@google-cloud/speech');
// Creates a client
const client = new speech.SpeechClient();
async function quickstart() {
// The path to the remote LINEAR16 file
// const gcsUri = 'gs://cloud-samples-data/speech/brooklyn_bridge.raw';
const gcsUri = 'gs://diavox-project-1/transcripts/josie1.mp3';
// The audio file's encoding, sample rate in hertz, and BCP-47 language code
const audio = {
uri: gcsUri,
};
const config = {
encoding: 'MP3',
sampleRateHertz: 48000,
// languageCode: 'en-US',
languageCode: 'fil-PH',
};
const request = {
audio: audio,
config: config,
};
// Detects speech in the audio file
const [response] = await client.recognize(request);
const transcription = response.results
.map(result => result.alternatives[0].transcript)
.join('\n');
console.log(`Transcription: ${transcription}`);
}
quickstart();