What audio file types does Google Cloud Speech API recognize?
Asked Answered
G

2

9

I'm trying to use Google's Cloud Speech API. There's documentation and code examples here:

https://cloud.google.com/speech/docs/basics
https://cloud.google.com/speech/docs/rest-tutorial

I can get the sample code to run just fine if I point it to an included file, audio.raw, but not with a brief .wav file.

I have no idea what format the audio sample file is:

$ file audio.raw 
audio.raw: data

With my .wav file that has maybe 10 seconds of audio I get an empty result.

I'm aware of this answer.

google cloud speech api returning empty result

My question was asked before but there was not an answer to the question.

What types of audio are supported by Cloud Speech API?

I can't imagine that I would have to get the properties of the audio file just right to get this to work. I assume a common use case, mine, is that someone records a meeting, has no idea of the parameters of the recording and just wants a text file.

Guadiana answered 15/10, 2016 at 14:49 Comment(3)
@alex I see you responded to #39713123. Any thoughts on my question?Guadiana
You cannot message other uses on SO (@foo does not work that way here)Caecilian
Good to know. Thanks.Guadiana
C
5

EDIT May 2020: seems things improved and this answer is no longer correct: see new docs for details about supported formats (including WAV).


As of 2016 the WAVe format does not seem to be supported. These formats are documented as supported though:

  • LINEAR16 Uncompressed 16-bit signed little-endian samples. This is the only encoding that may be used by speech.asyncrecognize.
  • FLAC This is the recommended encoding for speech.syncrecognize and StreamingRecognize because it uses lossless compression; therefore recognition accuracy is not compromised by a lossy codec. Only 16-bit samples are supported. Not all fields in STREAMINFO are supported
  • MULAW 8-bit samples that compand 14-bit audio samples using G.711 PCMU/mu-law.
  • AMR Adaptive Multi-Rate Narrowband codec. sampleRate must be 8000 Hz.
  • AMR_WB Adaptive Multi-Rate Wideband codec. sampleRate must be 16000 Hz.

https://cloud.google.com/speech/reference/rest/v1beta1/RecognitionConfig#AudioEncoding

Caecilian answered 15/10, 2016 at 17:8 Comment(2)
Thanks. That got me past that problem. I installed sox and converted the .wav file to .flac. Now I get a different problem which I'll research and post about separately.Guadiana
as for flac: Only 16-bit samples are supported. Not all fields in STREAMINFO are supported.. Checks docsCaecilian
W
1

According to Google Cloud Speech Documentation : Speech-to-Text supports WAV files with LINEAR16 or MULAW encoded audio. https://cloud.google.com/speech-to-text/docs/encoding

Waly answered 19/2, 2019 at 9:49 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.