Skip to main content

Posts

Showing posts with the label text

Google speech to text node js code

// Imports the Google Cloud client library const speech = require('@google-cloud/speech'); const fs = require('fs'); var speechToText = function(filetoProcess , callback){ // Creates a client const client = new speech.SpeechClient(); // The name of the audio file to transcribe const fileName = filetoProcess; // Reads a local audio file and converts it to base64 const file = fs.readFileSync(fileName); const audioBytes = file.toString('base64'); // The audio file's encoding, sample rate in hertz, and BCP-47 language code const audio = {   content: audioBytes, }; const config = {   encoding: 'LINEAR16',   sampleRateHertz: 8000,   languageCode: 'en-IN',   profanityFilter: true,   // speechContexts: {   //     phrases:["yes","no"]   //    },   metadata: {            interactionType: "VOICEMAIL",            //industryNaicsCodeOfAudio:...