Skip to content

Instantly share code, notes, and snippets.

@rashaabdulrazzak
Last active May 29, 2021 09:39
Show Gist options
  • Save rashaabdulrazzak/7abd711b823349b2d536f621a5b29f2e to your computer and use it in GitHub Desktop.
Save rashaabdulrazzak/7abd711b823349b2d536f621a5b29f2e to your computer and use it in GitHub Desktop.
Turkish Long File
// Imports the Google Cloud client library
const speech = require("@google-cloud/speech");
const fs = require('fs')
// Creates a client
const client = new speech.SpeechClient();
async function main() {
const gcsUri = 'gs://aksiontest/one-turkish.wav';
const encoding = 'LINEAR16';
const sampleRateHertz = 44100;
const languageCode = 'tr-TR';
const config = {
encoding: encoding,
sampleRateHertz: sampleRateHertz,
languageCode: languageCode,
audioChannelCount: 2
};
const audio = {
uri: gcsUri,
};
const request = {
config: config,
audio: audio,
};
// Detects speech in the audio file. This creates a recognition job that you
// can wait for now, or get its result later.
const [operation] = await client.longRunningRecognize(request);
// Get a Promise representation of the final result of the job
const [response] = await operation.promise();
const transcription = response.results
.map(result => result.alternatives[0].transcript)
.join('\n');
console.log(`Transcription: ${transcription}`);
}
main().catch(console.error);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment