Input for Pocketsphinx on Android

允我心安 提交于 2019-12-21 05:53:28

问题


I make a demo for speech recognize to text. I have just built the demo Building Pocketsphinx On Android and it work well. But my problem is how to make input from an audio file, not from real time speaking. Any idea to solve it? Thanks.


回答1:


You can use Pocketsphinx API to process any binary data, including binary data read from file. You only need to make sure that data is in the required format. Once you read the binary data into the buffer of type short[] you can process it using pocketsphinx API calls:

import edu.cmu.pocketsphinx.pocketsphinx;

Pocketsphinx ps = new Decoder(....)
ps.processRaw(buf, buf.length, false, false);

After all data is processed you can retrieve the result

Hypothesis hyp = pocketsphinx.getHyp();
System.out.println(hyp.getHypstr())

For more details see the Pocketsphinx part of the CMUSphinx tutorial




回答2:


Although a little late in the day, hope it might be of help to someone else looking to address similar requirements. Have a look at the following code in SpeechRecognizerclass in particular at Declaring AudioRecord object AudioRecord recorder = new AudioRecord( AudioSource.VOICE_RECOGNITION, sampleRate, AudioFormat.CHANNEL_IN_MONO, AudioFormat.ENCODING_PCM_16BIT, bufferSize * 2); Creating another class like SpeechRecognizer, you could choose any of the audio sources supported by MediaRecord



来源:https://stackoverflow.com/questions/15566701/input-for-pocketsphinx-on-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!