speech

Speech模块管理语音输入功能,提供语音识别功能,可支持用户通过麦克风设备进行语音输入内容。通过plus.speech可获取语音输入管理对象。

方法:

对象:

回调方法:

权限:

permissions

{
// ...
"permissions":{
	// ...
	"Speech": {
		"description": "语音输入"
	}
}
}
			

SpeechRecognizeOptions

JSON对象,语音识别参数

interface plus.speech.SpeechRecognizeOptions {
	attribute Boolean continue;
	attribute String engine;
	attribute String lang;
	attribute Number nbest;
	attribute String punctuation;
	attribute Number timeout;
	attribute Boolean userInterface;
	attribute EventHandler onstart;
	attribute EventHandler onend;
}
				

说明:

控制语音识别引擎内部参数,在JS中为JSON对象,在启动语音识别时使用。

属性:

SpeechRecoginzeEvents

语音识别事件类型

说明:

描述语音过程的触发事件列表,可以通过调用plus.sppech.addEventListener方法进行注册监听。

常量:

RecognitionEventCallback

语音识别事件回调函数

void onEvent(event){
	// Event code
}
				

说明:

调用plus.speech.addEventListener方法监听语音识别事件的回调函数。

参数:

返回值:

void : 无

RecognitionSuccessCallback

语音识别成功回调

void onSuccess(result){
	// Recognition success code
}
				

说明:

语音识别成功时的回调函数,用于返回语音识别出的文本内容。

参数:

返回值:

void : 无

RecognitionErrorCallback

语音识别失败回调

void onError(error){
	// Recognition error code
}
				

说明:

当语音识别失败时的回调函数,用于返回语音识别失败的错误信息。

参数:

返回值:

void : 无