MCPcopy Create free account
hub / github.com/GoogleCloudPlatform/nodejs-docs-samples / transcribeFile

Function transcribeFile

speech/transcribeFile.v2.js:34–52  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

32 const fs = require('fs');
33
34 async function transcribeFile() {
35 // Instantiate the client
36 const client = new speech.SpeechClient();
37
38 const content = fs.readFileSync(audioFilePath).toString('base64');
39 const transcriptionRequest = {
40 recognizer: recognizerName,
41 config: {
42 // Automatically detects audio encoding
43 autoDecodingConfig: {},
44 },
45 content: content,
46 };
47
48 const response = await client.recognize(transcriptionRequest);
49 for (const result of response[0].results) {
50 console.log(`Transcript: ${result.alternatives[0].transcript}`);
51 }
52 }
53
54 await transcribeFile();
55 // [END speech_transcribe_file_v2]

Callers 1

mainFunction · 0.85

Calls 1

toStringMethod · 0.80

Tested by

no test coverage detected