1

I am using speech-to-text service and unfortunately the 'OPUS' encoding does not work for my content, or any other audio/ogg content that is not corrupted.

There is a way to convert audio/ogg bufferArray/base64 to other audio format in base 64 using node.js?

Gal Shalom
  • 43
  • 6
  • Could you please expand more about what are you referring to your OPUS file content doesn't work? opus ogg is a compatible audio format for Speech to Text. Also, what do you mean with “audio/ogg bufferArray/base64”? Did you convert your ogg audio to base64-encoded data? And, now you are trying to convert this base64-encoded file to another type format such as mp3,flac … and keep the base64 encoding? – Narda Monserrat Jul 12 '21 at 20:16
  • Thank you for your response. i am uploading audio/ogg file to firebase storage and get a signedUrl of the file. then, using axios, i am downloading the file from the signedUrl using responseType:'arraybuffer'. speech-to-text required base-64 format, so after getting the arraybuffer, i am converting him using arraybuffer.toString('base64') and sending the content to speech-to-text using the following configuration: const config = { encoding:'OGG_OPUS', sampleRateHerts:16000, languageCode:'en-US' } – Gal Shalom Jul 13 '21 at 12:26
  • Use fs.readFileSync(filename).toString('base64') in order to encode data. Check the example of encoding audio content.https://cloud.google.com/speech-to-text/docs/base64-encoding#embedding_audio_content_programmatically Also, Speech-to-text can recognize directly on an audio file located in Cloud Storage using the URL.https://cloud.google.com/speech-to-text/docs/sync-recognize#performing_synchronous_speech_recognition_on_a_remote_file. Probably it could be a good approach for your use-case. – Narda Monserrat Jul 13 '21 at 22:01

0 Answers0