Input for Pocketsphinx on Android

偶尔善良 提交于 2019-12-03 20:58:47

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

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

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