对不起,我一直坚持这一个月,我想提供尽可能多的细节......它只是一个文件没有发现异常在一个简单的库...: )文件未找到异常? (语音识别)
我对我的variances
文件中获取文件未发现异常:
,不过我会,有差异文件:
我试图简单地在我的后台服务中实现语音识别,以便我可以检测到用户说出单词hello(使用pocketsphinx)。
的问题发生在这个方法:createSphinxDir();
这里是我的服务:
@Override
public void onCreate() {
super.onCreate();
setupRecog();
}
private void setupRecog() {
String sphinxDir = createSphinxDir();
Log.v(TAG, "ABOUT TO CREATE SETUP");
if (sphinxDir != null) {
try {
Log.v(TAG, "SETTING UP! :)");
mSpeechRecognizer = defaultSetup()
.setAcousticModel(new File(sphinxDir, "en-us-ptm"))
.setDictionary(new File(sphinxDir, "hello.dict"))
.setBoolean("-allphone_ci", true) //WHAT IS THIS
.getRecognizer();
mSpeechRecognizer.addListener(this);
Log.v(TAG, "ADDED LISTENER");
if ((new File(sphinxDir + File.separator + "command.gram")).isFile()) {
mSpeechRecognizer.addKeywordSearch("hello",
new File(sphinxDir + File.separator + "command.gram"));
Log.v(TAG, "ADDED KEYWORD SEARCH! :)");
}
// Or wherever appropriate
mSpeechRecognizer.startListening("wakeup"); //Is this correct?
Log.v(TAG, "STARTED LISTENING");
} catch (IOException e) {
Log.v("ERROR", TAG);
}
}
}
String createSphinxDir() {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
String sphinxDir = prefs.getString("sphinx", null);
if (sphinxDir == null) {
Assets assets;
Log.v(TAG, "Assets are not synced, should sync now:");
try {
Log.v(TAG, "In try block!");
assets = new Assets(this);
File sphinxDirFile = assets.syncAssets();
Log.v(TAG, "Syncing assets...should set up listener");
if (sphinxDirFile != null) {
sphinxDir = sphinxDirFile.getAbsolutePath();
SharedPreferences.Editor editor = prefs.edit();
editor.putString("sphinx", sphinxDir);
editor.commit();
Log.v(TAG, "Set up listener");
}else{
Log.v(TAG, "sphinxDirFile is null!");
}
} catch (IOException e) { //THIS IS THE PLACE WHERE I AM GETTING THE ERROR!
e.printStackTrace();
Log.d(TAG, e.toString());
}
}
return sphinxDir;
}
我也有所有的回调方法(onPartialResult,onResult等),但他们从来没有得到调用。
早些时候我得到一个异常说方差.md5文件不存在,所以我把一个空间,在variances
和.md5
之间,但现在我得到这个错误,我不知道为什么...
请让我知道,
Ruchir
我没有看到你所处理的AssetManager通过其加载的资产的代码。 –
我可以从堆栈跟踪中看到您正在使用AssetManager。它在Assets类中,我们在这里看不到。 –
在差异文件末尾添加一个空格,看看它是否可以。您不需要AssetManager,Sphinx的syncAssets方法为您完成副本。 –