本文介绍了语音目录在本地存储中不可用,用于“此处映射语音指令"功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
按照此处的导航语音指令的Android SDK开发人员指南中的步骤操作,我无法启动语音功能.调试信息如下:
Following the steps in HERE Android SDK Developer's Guide for Navigation Voice Instruction, I cannot start the Voice feature. The debug information is as below:
-
//检索VoiceCatalog并下载最新更新VoiceCatalog voiceCatalog = VoiceCatalog.getInstance();voiceCatalog.downloadCatalog(新的VoiceCatalog.OnDownloadDoneListener(){@Override公共无效onDownloadDone(VoiceCatalog.Error错误){如果(错误== VoiceCatalog.Error.NONE){//目录下载成功Toast.makeText(getApplicationContext(),语音目录下载成功.",Toast.LENGTH_LONG).show();} 别的 {Toast.makeText(getApplicationContext(),语音目录下载错误.",Toast.LENGTH_LONG).show();}}});
onDownloadDone()
函数将始终收到错误: VoiceCatalog.Error UNKNOW
onDownloadDone()
function will always receive an error: VoiceCatalog.Error UNKNOW
-
VoiceCatalog.getInstance().isLocalCatalogAvailable()
isLocalCatalogAvailable()
始终为false.
- 将sdk.zip/misc中的一组示例语音皮肤复制到/data/app_namespace/files/voices-download
有人可以建议这个问题吗?谢谢.
Could anyone suggest on this issue? Thanks.
推荐答案
针对此问题,我们找到了以下解决方案.
We find the following solution for this issue.
private void setupVoice() {
// Retrieve the VoiceCatalog and download the latest updates
VoiceCatalog voiceCatalog = VoiceCatalog.getInstance();
if (!voiceCatalog.isLocalCatalogAvailable()) {
if (DEBUG) Log.d(TAG, "Voice catalog is not available in local storage.");
//Toast.makeText(mActivity.getApplicationContext(), "Voice catalog is not available in local storage.", Toast.LENGTH_LONG).show();
voiceCatalog.downloadCatalog(new VoiceCatalog.OnDownloadDoneListener() {
@Override
public void onDownloadDone(VoiceCatalog.Error error) {
if (error == VoiceCatalog.Error.NONE) {
// catalog download successful
if (DEBUG) Log.d(TAG, "Download voice catalog successfully.");
//Toast.makeText(mActivity.getApplicationContext(), "Voice catalog download successful.", Toast.LENGTH_LONG).show();
} else {
if (DEBUG) Log.d(TAG, "Download voice catalog failed.");
//Toast.makeText(mActivity.getApplicationContext(), "Voice catalog download error.", Toast.LENGTH_LONG).show();
}
// Get the list of voice packages from the voice catalog list
List<VoicePackage> voicePackages =
VoiceCatalog.getInstance().getCatalogList();
if (voicePackages.size() == 0) {
if (DEBUG) Log.d(TAG, "Voice catalog size is 0.");
//Toast.makeText(mActivity.getApplicationContext(), "Voice catalog size is 0.", Toast.LENGTH_LONG).show();
}
long id = -1;
// select
for (VoicePackage voicePackage : voicePackages) {
if (voicePackage.getMarcCode().compareToIgnoreCase("eng") == 0) {
//if (voicePackage.isTts()) // TODO: need to figure out why always return false
{
id = voicePackage.getId();
break;
}
}
}
if (!VoiceCatalog.getInstance().isLocalVoiceSkin(id)) {
final long finalId = id;
VoiceCatalog.getInstance().downloadVoice(id, new VoiceCatalog.OnDownloadDoneListener() {
@Override
public void onDownloadDone(VoiceCatalog.Error error) {
if (error == VoiceCatalog.Error.NONE) {
//voice skin download successful
if (DEBUG) Log.d(TAG, "Download voice skin successfully.");
//Toast.makeText(mActivity.getApplicationContext(), "Voice skin download successful.", Toast.LENGTH_LONG).show();
// set the voice skin for use by navigation manager
if (VoiceCatalog.getInstance().getLocalVoiceSkin(finalId) != null) {
m_navigationManager.setVoiceSkin(VoiceCatalog.getInstance().getLocalVoiceSkin(finalId));
} else {
if (DEBUG) Log.d(TAG, "Get local voice skin error.");
//Toast.makeText(mActivity.getApplicationContext(), "Navi manager set voice skin error.", Toast.LENGTH_LONG).show();
}
} else {
if (DEBUG) Log.d(TAG, "Download voice skin failed.");
//Toast.makeText(mActivity.getApplicationContext(), "Voice skin download error.", Toast.LENGTH_LONG).show();
}
}
});
} else {
// set the voice skin for use by navigation manager
if (VoiceCatalog.getInstance().getLocalVoiceSkin(id) != null) {
m_navigationManager.setVoiceSkin(VoiceCatalog.getInstance().getLocalVoiceSkin(id));
} else {
if (DEBUG) Log.d(TAG, "Get local voice skin error.");
//Toast.makeText(mActivity.getApplicationContext(), "Navi manager set voice skin error.", Toast.LENGTH_LONG).show();
}
}
}
});
}
}
这篇关于语音目录在本地存储中不可用,用于“此处映射语音指令"功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!