AndyPerlitch AndyPerlitch - 2 months ago 15x
Node.js Question

.flac file with google cloud speech API fails

I've successfully run this nodejs demo from my local machine with the supplied

file. Now I would like to use my own file, which started as a
file which I converted using the following sox command (as per step 3 of the google speech troubleshoot page):

sox resources/my-audio.wav --channels=1 --bits=16 --rate=16000 --endian=little resources/my-audio.flac

However I am still getting an empty response from google (no transcript, no error) when I try with
. I can play the flac file just fine on my machine.

Any suggestions?


Figured it out... turns out the sox command to convert the wav on the support page isn't quite right. Here is the command that worked for me:

sox resources/my-audio.wav \
--channels=1 \
--bits=16 \
--rate=16000 \
--encoding=signed-integer \
--endian=little resources/my-audio.raw

The two key differences with my original command were (1) add the --encoding=signed-integer (thanks to this) and (2) use the .raw extension on the output filename.