目录

class info
com.huawei.hms.mlsdk.asr.MLAsrRecognizer
语音识别器。通过startRecognizing (Intent intent)开始收听识别语音,开始前需要先设置监听器setAsrListener(MLAsrListener listener)。

Constant Summary

TypeNameDesc
StringRESULTS_RECOGNIZED用于标记语音识别结果中的文本信息对应的Key值;在onResults()中,用户通过该key值从Bundle中获取语音识别器识别到的文本。
StringRESULTS_RECOGNIZING用于标记语音识别过程中识别到的文本信息对应的Key值;在onRecognizingResults()中,用户通过该key值从Bundle中获取语音识别器识别到的文本。

Public Method Summary

Return typeMethod name
MLAsrRecognizercreateMLAsrRecognizer(Context context)
voiddestroy()
voidsetAsrListener(MLAsrListener listener)
voidstartRecognizing(Intent recognizerIntent)

Constants

Constant
public static final String RESULTS_RECOGNIZED
在onResults()中,用户通过该key值从Bundle中获取语音识别器识别到的文本。
Constant Value: “results_recognized”
Constant
public static final String RESULTS_RECOGNIZING
在onRecognizingResults()中,用户通过该key值从Bundle中获取语音识别器识别到的文本。
Constant Value: “results_recognizing”

Public Methods

Method
public static MLAsrRecognizer createAsrRecognizer(Context context)
创建一个新的语音识别器MLAsrRecognizer。

Parameters

Parameter nameParameter desc
context创建语音识别器所在的上下文。


Return

Typedesc
MLAsrRecognizer一个新的语音识别器。
Method
public void destroy()
销毁语音识别器对象。
Method
public void setAsrListener(MLAsrListener listener)
设置识别器监听回调,用于接收识别结果和错误码。

Parameters

Parameter nameParameter desc
listener用于从识别器接收结果的监听器。
Method
public void startRecognizing(Intent recognizerIntent)
开始收听语音。setAsrListener(MLAsrListener listener)设置监听器才能接收结果。

Parameters

Parameter nameParameter desc
recognizerIntent

intent中包含用于执行识别的参数。

当前携带参数如下:

Key=FEATURE:识别模式,传入字段为int类型。

Key=LANGUAGE:语言类型,传入字段为String类型。