Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
685 views
in Technique[技术] by (71.8m points)

Google Speech recognition for Android using python : Empty return {"result":[]} & no errors

I am trying to create a voice assistant for android. Below are the steps I followed:

  1. I tried recording using the mediarecorder (jnius autoclass).
  2. The voice was recorded in awb format using following: self.mRecorder.setOutputFormat(self.OutputFormat.AMR_WB) self.mRecorder.setOutputFile('/sdcard/test_recording.awb')
  3. converting it to wav using ffmpef
  4. further converting it to flac using sox subprocess.
  5. Submitting to google web speech api.

However it returns an empty response and no error.

{"result":[]}

I had to resort to various conversions as mediarecorder doesn't provide an option to record either a flac or a wav file. Also, normal SpeechRecognition module for python doesn't have a flac convertor for android and hence can't be used

How to debug to figure out what might be wrong that google returns this unexpected response and why not an error. I downloaded my intermediate wav file and tried to use "play audio.wav" and it gave the following output:

File Size: 157k Bit Rate: 256k Encoding: Signed PCM
Channels: 1 @ 16-bit Samplerate: 16000Hz Replaygain: off
Duration: 00:00:04.90

In:100% 00:00:04.90 [00:00:00.00] Out:78.4k [ | ] Hd:4.7 Clip:0 Done.

This audio was further converted to FLAC using SOX(over termux).

Any help is appreciated.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...