本文介绍了输入Pocketsphinx在Android的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我做一个演示语音识别为文本。我刚建的试玩大厦Pocketsphinx在Android上它工作得很好。但我的问题是,如何使投入的音频文件,而不是从实时讲话。任何想法来解决呢?谢谢你。

I make a demo for speech recognize to text. I have just built the demo Building Pocketsphinx On Androidand 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.

推荐答案

您可以使用Pocketsphinx API来处理任何二进制数据,包括从文件中读取二进制数据。你只需要确保数据在需要的格式。一旦你读的二进制数据转换类型的缓冲短[]您可以使用pocketsphinx API调用对其进行处理:

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:

进口edu.cmu.pocketsphinx.pocketsphinx;

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())

有关详细信息请参见的CMUSphinx教程Pocketsphinx部分

这篇关于输入Pocketsphinx在Android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-13 13:30