public class SpeechUtility
extends com.iflytek.cloud.msc.module.SpeechInterface
本类为SDK入口类,除Setting
、Version
类外,第一次使用任意一个其
他的业务类前,都至少创建一次本类的实例,以初始化SDK。
本类使用单例,调用者使用本类的对象,只需要通过createUtility(Context, java.lang.String)
创建
一次对象后,便可一直使用该对象,直到通过调用destroy()
进行单例对象销毁。调
用者可通过getUtility()
获取当前已经创建的单例。在销毁本类的单例对象后,
需要先通过createUtility(Context, java.lang.String)
再次创建单例对象,方可再使用。
SpeechRecognizer
,
SpeechSynthesizer
,
SpeechUnderstander
,
TextUnderstander
,
SpeakerVerifier
限定符和类型 | 字段和说明 |
---|---|
static java.lang.String |
TAG_RESOURCE_CONTENT
本地资源信息JSON格式的字符串类型
|
static java.lang.String |
TAG_RESOURCE_RESULT
本地资源信息JSON返回的result
|
static java.lang.String |
TAG_RESOURCE_RET
本地资源信息JSON返回的code
|
限定符和类型 | 方法和说明 |
---|---|
boolean |
checkServiceInstalled()
检查服务安装状态
|
static SpeechUtility |
createUtility(Context context,
java.lang.String params)
创建配置单例
创建配置单例,同时,也是初始化SDK的操作。
|
boolean |
destroy()
销毁单例对象
通过本函数,销毁由
createUtility(Context, java.lang.String) 创建的单例对象,同时也是逆
初始化SDK。 |
java.lang.String |
getComponentUrl()
直接获取组件下载地址
|
com.iflytek.cloud.msc.module.SpeechInterface.ENGINE_MODE |
getEngineMode()
获得引擎选择模式
|
java.lang.String |
getParameter(java.lang.String key)
获取MSC引擎的状态参数
|
java.lang.String |
getPlusLocalInfo(java.lang.String key)
key可设置的参数有:
SpeechConstant.PLUS_LOCAL_ALL :所有资源
SpeechConstant.PLUS_LOCAL_TTS :合成资源}
SpeechConstant.PLUS_LOCAL_ASR :识别资源}
SpeechConstant.PLUS_LOCAL_IVW :唤醒资源}
|
int |
getServiceVersion()
获取服务的版本信息
|
static SpeechUtility |
getUtility()
获取配置单例
通过函数获取已创建的单例对象。
|
int |
openEngineSettings(java.lang.String engineName)
打开引擎设置下载页面
|
java.lang.String[] |
queryAvailableEngines()
查询本地组件支持的引擎列表
引擎列表:local.tts,cloud.tts,local.asr,cloud.asr,local.nlu,cloud.nlu
更多请参考开发者网站:。 |
boolean |
setParameter(java.lang.String key,
java.lang.String value)
设置MSC引擎的状态参数
|
public static final java.lang.String TAG_RESOURCE_CONTENT
public static final java.lang.String TAG_RESOURCE_RET
public static final java.lang.String TAG_RESOURCE_RESULT
public static SpeechUtility createUtility(Context context, java.lang.String params)
创建配置单例,同时,也是初始化SDK的操作。
注册应用请前往开发者网站,。params
- 启动参数,包含以下参数:SpeechConstant.APPID
,必须,如:12345678;SpeechConstant.LIB_NAME
,可选,如:mylibname;public static SpeechUtility getUtility()
通过函数获取已创建的单例对象。当单例对象未创建时,将返回null,此时应先通过
createUtility(Context, java.lang.String)
创建单例对象。
createUtility(Context, java.lang.String)
,
destroy()
public boolean destroy()
通过本函数,销毁由createUtility(Context, java.lang.String)
创建的单例对象,同时也是逆
初始化SDK。
在调用本函数进行销毁前,应先保证所有业务的会话均已结束,否则可能引起在 当前应用的生命周期内,无法再使用SDK进行业务会话的问题。
在调用本函数成功销毁对象后,所有业务会话在下一次通过createUtility(Context, java.lang.String)
创建实例前,将不能再使用。
createUtility(Context, java.lang.String)
,
getUtility()
public boolean checkServiceInstalled()
SpeechConstant.ENGINE_MODE
public java.lang.String[] queryAvailableEngines()
引擎列表:local.tts,cloud.tts,local.asr,cloud.asr,local.nlu,cloud.nlu
更多请参考开发者网站:。
如果返回为空,则表示需要提示用户下载组件,如果返回的引擎不满足需求,则通知组件下载引擎。
public int openEngineSettings(java.lang.String engineName)
engineNames
- 引擎名称public java.lang.String getComponentUrl()
public boolean setParameter(java.lang.String key, java.lang.String value)
setParameter
在类中 com.iflytek.cloud.msc.module.SpeechInterface
key
- 参数名称value
- 参数值SpeechConstant
public java.lang.String getParameter(java.lang.String key)
getParameter
在类中 com.iflytek.cloud.msc.module.SpeechInterface
key
- 参数名称SpeechConstant
public java.lang.String getPlusLocalInfo(java.lang.String key) throws JSONException
key可设置的参数有:
SpeechConstant.PLUS_LOCAL_ALL
:所有资源
SpeechConstant.PLUS_LOCAL_TTS
:合成资源}
SpeechConstant.PLUS_LOCAL_ASR
:识别资源}
SpeechConstant.PLUS_LOCAL_IVW
:唤醒资源}
key
- JSONException
public com.iflytek.cloud.msc.module.SpeechInterface.ENGINE_MODE getEngineMode()
SpeechConstant.ENGINE_MODE
public int getServiceVersion()