我試圖在文件中保存由android的語音識別服務收聽的音頻數據。保存Android股票語音識別引擎的音頻輸入
其實我實現RecognitionListener
如下解釋: Speech to Text on Android
將數據保存到緩衝區中,如下圖所示: Capturing audio sent to Google's speech recognition server
和緩存寫入到一個WAV文件,如在這裏。 Android Record raw bytes into WAVE file for Http Streaming
我的問題是如何得到適當的音頻設置保存在wav文件的標題。 事實上,當我玩wav文件只能聽到奇怪的聲音,這個參數,
short nChannels=2;// audio channels
int sRate=44100; // Sample rate
short bSamples = 16;// byteSample
或自認倒黴:
short nChannels=1;// audio channels
int sRate=8000; // Sample rate
short bSamples = 16;// byteSample
什麼困惑的是,看的語音識別任務的參數從logcat的,我覺得第一設置播放採樣率44100赫茲:
12-20 14:41:34.007: DEBUG/AudioHardwareALSA(2364): Set PLAYBACK PCM format to S16_LE (Signed 16 bit Little Endian)
12-20 14:41:34.007: DEBUG/AudioHardwareALSA(2364): Using 2 channels for PLAYBACK.
12-20 14:41:34.007: DEBUG/AudioHardwareALSA(2364): Set PLAYBACK sample rate to 44100 HZ
12-20 14:41:34.007: DEBUG/AudioHardwareALSA(2364): Buffer size: 2048
12-20 14:41:34.007: DEBUG/AudioHardwareALSA(2364): Latency: 46439
然後aInfo.SampleRate = 8000時,它起着發送給谷歌服務器上的文件:
12-20 14:41:36.152: DEBUG/(2364): PV_Wav_Parser::InitWavParser
12-20 14:41:36.152: DEBUG/(2364): File open Succes
12-20 14:41:36.152: DEBUG/(2364): File SEEK End Succes
...
12-20 14:41:36.152: DEBUG/(2364): PV_Wav_Parser::ReadData
12-20 14:41:36.152: DEBUG/(2364): Data Read buff = RIFF?
12-20 14:41:36.152: DEBUG/(2364): Data Read = RIFF?
12-20 14:41:36.152: DEBUG/(2364): PV_Wav_Parser::ReadData
12-20 14:41:36.152: DEBUG/(2364): Data Read buff = fmt
...
12-20 14:41:36.152: DEBUG/(2364): PVWAVPARSER_OK
12-20 14:41:36.156: DEBUG/(2364): aInfo.AudioFormat = 1
12-20 14:41:36.156: DEBUG/(2364): aInfo.NumChannels = 1
12-20 14:41:36.156: DEBUG/(2364): aInfo.SampleRate = 8000
12-20 14:41:36.156: DEBUG/(2364): aInfo.ByteRate = 16000
12-20 14:41:36.156: DEBUG/(2364): aInfo.BlockAlign = 2
12-20 14:41:36.156: DEBUG/(2364): aInfo.BitsPerSample = 16
12-20 14:41:36.156: DEBUG/(2364): aInfo.BytesPerSample = 2
12-20 14:41:36.156: DEBUG/(2364): aInfo.NumSamples = 2258
所以,我怎樣才能找到合適的參數保存音頻緩衝在一個良好的WAV音頻文件?
你有沒有找到你的解決方案? – Doug 2012-03-11 23:45:14
好像你已經得到了最遠的這樣做。 mmmx,你能解決這個問題嗎? – ComputerEngineer88 2012-03-14 07:25:18