本文整理汇总了Java中edu.cmu.pocketsphinx.RecognitionListener类的典型用法代码示例。如果您正苦于以下问题:Java RecognitionListener类的具体用法?Java RecognitionListener怎么用?Java RecognitionListener使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
RecognitionListener类属于edu.cmu.pocketsphinx包,在下文中一共展示了RecognitionListener类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: FlyteToText
import edu.cmu.pocketsphinx.RecognitionListener; //导入依赖的package包/类
public FlyteToText(final Context context, final RecognitionListener listener) {
// Start recognizer in a syncTask to avoid freeze
new AsyncTask<Void, Void, Exception>() {
@Override
protected Exception doInBackground(Void... params) {
try {
Assets assets = new Assets(context);
File assetDir = assets.syncAssets();
setupRecognizer(assetDir, listener);
} catch (IOException e) {
return e;
}
return null;
}
@Override
protected void onPostExecute(Exception result) {
if (result != null) {
Log.e("Sphinx error", result.getMessage());
}
}
}.execute();
}
示例2: execute
import edu.cmu.pocketsphinx.RecognitionListener; //导入依赖的package包/类
@Override
protected void execute(RecognitionListener listener) {
if (state)
listener.onBeginningOfSpeech();
else
listener.onEndOfSpeech();
}
示例3: setupRecognizer
import edu.cmu.pocketsphinx.RecognitionListener; //导入依赖的package包/类
private void setupRecognizer(File assetsDir, RecognitionListener listener) throws IOException {
recognizer = defaultSetup()
.setAcousticModel(new File(assetsDir, "en-us-ptm"))
.setDictionary(new File(assetsDir, "cmudict-en-us.dict"))
.setRawLogDir(assetsDir)
.setKeywordThreshold(1e-45f)
.setBoolean("-allphone_ci", true)
.getRecognizer();
recognizer.addListener(listener);
File flyteGrammar = new File(assetsDir, "flyte.gram");
recognizer.addGrammarSearch("flyte", flyteGrammar);
}
示例4: addRapidListener
import edu.cmu.pocketsphinx.RecognitionListener; //导入依赖的package包/类
/**
* Adds listener.
*/
protected void addRapidListener(RecognitionListener listener) {
synchronized (listeners) {
listeners.add(listener);
}
}
示例5: removeRapidListener
import edu.cmu.pocketsphinx.RecognitionListener; //导入依赖的package包/类
/**
* Removes listener.
*/
protected void removeRapidListener(RecognitionListener listener) {
synchronized (listeners) {
listeners.remove(listener);
}
}
示例6: run
import edu.cmu.pocketsphinx.RecognitionListener; //导入依赖的package包/类
public void run() {
RecognitionListener[] emptyArray = new RecognitionListener[0];
for (RecognitionListener listener : listeners.toArray(emptyArray))
execute(listener);
}