Google Cloud Platform : Speech to Text gives Unhan

2019-08-28 23:50发布

I'm converting speech to text using google speech to text API

it works fine for the short audio file https://cloud.google.com/speech-to-text/docs/sync-recognize

and it works for long audio file using following link https://cloud.google.com/speech-to-text/docs/async-recognize

but as it is paid so is there any other option that we can covert our local file source and use google speech to text API. as when i try to do that get error and suggest me to use GCS.

As I don't want to use GCS. so is there any option to use speech to text for long file?

I have tried as follows

const config = { 
   encoding: 'MP3',
   sampleRateHertz: 8000,
   languageCode: 'en-US',
};
const file = fs.readFileSync(path.join(__dirname,"audios/longaudio.mp3"))


const audioBytes = file.toString('base64');
const audio = {
    content: audioBytes,
};
const request = {
    config: config,
    interimResults: true, 
    audio: audio,
};
const [operation] = await client.longRunningRecognize(request);
const [response] = await operation.promise();
const transcription = response.results
.map(result => {
  return result.alternatives[0].transcript;
})
.join('\n');
console.log(`Transcription: ${transcription}`);

I have tried by the with the key interimResults and without as well . and also tried all the possible sampleRateHertz and encoding

0条回答
登录 后发表回答