python-docs-samples icon indicating copy to clipboard operation
python-docs-samples copied to clipboard

.flac file plays fine, but the speech/transcribe.py returns empty JSON output

Open jcastill0 opened this issue 10 years ago • 8 comments

Using sox I created a .flac file. I'm able to "play" the file which yields the following output of which I can also hear the audio: % ./play Clip1.flac

Clip1.flac:

File Size: 356k Bit Rate: 161k Encoding: FLAC Info: Processed by SoX Channels: 1 @ 16-bit
Samplerate: 16000Hz
Replaygain: off
Duration: 00:00:17.64

In:100% 00:00:17.64 [00:00:00.00] Out:847k [ -====|====- ] Hd:2.8 Clip:0
Done.

When I try to use the transcribe.py script on the same file, it returns an empty {} JSON output

jcastill0 avatar Nov 07 '16 02:11 jcastill0

Are you using the one under grpc/ or api-client/ ?

puneith avatar Nov 07 '16 04:11 puneith

API-client

On Sunday, November 6, 2016, Puneith Kaul [email protected] wrote:

Are you using the one under grpc/ or api-client/ ?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/GoogleCloudPlatform/python-docs-samples/issues/640#issuecomment-258747112, or mute the thread https://github.com/notifications/unsubscribe-auth/AAtixfaWDf8zeb9Ym-vTqN2gIXgIijarks5q7q7BgaJpZM4Kqx9B .

jcastill0 avatar Nov 07 '16 05:11 jcastill0

That code uses LINEAR16 as input format and thats why you get empty json. You can change manually to either flac or send .raw file to this code. https://github.com/GoogleCloudPlatform/python-docs-samples/blob/master/speech/api-client/transcribe.py#L65

puneith avatar Nov 07 '16 06:11 puneith

I tried to figure out how to generate a proper FLAC file, but I can'f find a way to do so with sox. I tried the following commands and although I can play them back with the play script, they still return an empty {} JSON output. First, using the macos version of sox. it doesn't take FLAC or LINEAR16 as an encoding parameter. So, I used the following commands to generate the .flac file:

% ./sox data/Clip1.wav --rate 16k --bits 16 --channels 1 data/Clip1.flac ./sox WARN wav: wave header missing extended part of fmt chunk % ./play data/Clip1.flac

data/Clip1.flac:

File Size: 355k Bit Rate: 161k Encoding: FLAC Info: Processed by SoX Channels: 1 @ 16-bit
Samplerate: 16000Hz
Replaygain: off
Duration: 00:00:17.64

In:100% 00:00:17.64 [00:00:00.00] Out:847k [ -====|====- ] Hd:2.8 Clip:0

Done.

I also tried the following: % ./sox data/Clip1.wav --rate 16k --bits 16 --channels 1 --encoding mu-law data/Clip1a.flac % ./play data/Clip1a.flac

data/Clip1a.flac:

File Size: 356k Bit Rate: 161k Encoding: FLAC Info: Processed by SoX Channels: 1 @ 16-bit
Samplerate: 16000Hz
Replaygain: off
Duration: 00:00:17.64

In:100% 00:00:17.64 [00:00:00.00] Out:847k [ -====|====- ] Hd:2.8 Clip:0
Done.

Running the 2nd file on the transcribe.py yields the same resuls (empty JSON file)

jcastill0 avatar Nov 08 '16 02:11 jcastill0

Can you send me the audio file?

puneith avatar Nov 09 '16 00:11 puneith

I tried sending the files, but it was rejected. I put them up on a public folder on my Google Drive: https://drive.google.com/open?id=0B6DP39h3iDDvSDNDVkJ2QjNCTG8

In there you will find 2 sets of files, both using Clip1.wav as a source.

Clip1 used the following script to generate the flac file ./sox data/Clip1.wav --rate 16k --bits 16 --channels 1 data/Clip1.flac

Clip1a used the following script to generate the flac file: ./sox data/Clip1.wav --rate 16k --bits 16 --channels 1 --encoding mu-law data/Clip1a.flac

Let me know if you have any problems accessing the folder and the files within it

On Tue, Nov 8, 2016 at 5:27 PM, Puneith Kaul [email protected] wrote:

Can you send me the audio file?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/GoogleCloudPlatform/python-docs-samples/issues/640#issuecomment-259302686, or mute the thread https://github.com/notifications/unsubscribe-auth/AAtixXwYiU5sfbhOTlTKX1fjvm3ihiKQks5q8RNYgaJpZM4Kqx9B .

jcastill0 avatar Nov 09 '16 01:11 jcastill0

So, I do get some transcription (Both sync and async). Its not complete though, but thats a different issue. Are you not seeing this output?

python api-client/transcribe_async.py Clip1.raw {"name": "7080391486607377985"} Waiting for server processing... Waiting for server processing... Waiting for server processing... Waiting for server processing... Waiting for server processing... Waiting for server processing... Waiting for server processing... Waiting for server processing... Waiting for server processing... Waiting for server processing... Waiting for server processing... Waiting for server processing... {"@type": "type.googleapis.com/google.cloud.speech.v1beta1.AsyncRecognizeResponse", "results": [{"alternatives": [{"confidence": 0.82116348, "transcript": "no Mom's going to do the turkey I get there"}]}]}

python api-client/transcribe.py input_files/Clip1.flac {"results": [{"alternatives": [{"confidence": 0.77390969, "transcript": "no Mom's going to do the turkey I get there"}]}]}

puneith avatar Nov 10 '16 03:11 puneith

(Closing due to inactivity, feel free to comment and we'll re-open)

theacodes avatar Feb 28 '17 20:02 theacodes