你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

Recognizer 类

  • java.lang.Object
    • com.microsoft.cognitiveservices.speech.Recognizer

实现

java.lang.AutoCloseable

public class Recognizer
implements java.lang.AutoCloseable

定义基类识别器,它主要包含常见事件处理程序。 注意:必须调用 close () 才能释放对象持有的基础资源。

字段摘要

修饰符和类型 字段和描述
protected boolean disposed

指示对象是否已释放的内部标志。

protected java.util.concurrent.atomic.AtomicInteger eventCounter

用于跟踪事件注册状态的内部事件计数器。

final EventHandlerImpl<SessionEventArgs> sessionStarted

定义会话启动事件的事件处理程序。

final EventHandlerImpl<SessionEventArgs> sessionStopped

为会话停止事件定义事件处理程序。

final EventHandlerImpl<RecognitionEventArgs> speechEndDetected

为检测到的语音结束事件定义事件处理程序。

final EventHandlerImpl<RecognitionEventArgs> speechStartDetected

为检测到的语音启动事件定义事件处理程序。

构造函数摘要

修饰符 构造函数 说明
protected Recognizer(AudioConfig audioInput)

创建并初始化识别器实例

方法摘要

修饰符和类型 方法和描述
protected final native long canceledSetCallback(long recoHandle)

用于设置已取消回调的内部方法。

void close()

释放关联的资源。

protected void dispose(boolean disposing)

此方法执行资源清理。

protected void doAsyncRecognitionAction(Runnable recoImplAction)

用于运行识别操作的内部方法。

SafeHandle getImpl()

返回内部识别器实例

protected final native long getPropertyBagFromRecognizerHandle(SafeHandle recoHandle, IntRef propertyHandle)

用于从识别器句柄获取属性包的内部方法。

protected long recognize()

用于开始识别一次操作的内部方法。

protected final native long recognizedSetCallback(long recoHandle)

用于设置已识别回调的内部方法。

protected final native long recognizingSetCallback(long recoHandle)

用于设置识别回调的内部方法。

protected void sessionStartedEventCallback(long eventArgs)

用于处理本机会话启动事件的内部方法。

protected final native long sessionStartedSetCallback(long recoHandle)

用于设置会话启动回调的内部方法。

protected void sessionStoppedEventCallback(long eventArgs)

用于处理本机会话停止事件的内部方法。

protected final native long sessionStoppedSetCallback(long recoHandle)

用于设置会话停止回调的内部方法。

protected void speechEndDetectedEventCallback(long eventArgs)

用于处理检测到本机语音结束事件的内部方法。

protected final native long speechEndDetectedSetCallback(long recoHandle)

用于设置检测到的语音结束回调的内部方法。

protected void speechStartDetectedEventCallback(long eventArgs)

用于处理检测到的本机语音启动事件的内部方法。

protected final native long speechStartDetectedSetCallback(long recoHandle)

用于设置语音启动检测到的回调的内部方法。

protected final native long startContinuousRecognition(SafeHandle recoHandle)

用于启动连续识别操作的内部方法。

protected final native long startKeywordRecognition(SafeHandle recoHandle, SafeHandle keywordModelHandle)

用于启动关键字 (keyword) 识别操作的内部方法。

protected final native long stopContinuousRecognition(SafeHandle recoHandle)

用于停止连续识别操作的内部方法。

protected final native long stopKeywordRecognition(SafeHandle recoHandle)

用于停止关键字 (keyword) 识别操作的内部方法。

方法继承自 java.lang.Object

java.lang.Object.clone java.lang.Object.equals java.lang.Object.finalize java.lang.Object.getClass java.lang.Object.hashCode java.lang.Object.notify java.lang.Object.notifyAll java.lang.Object.toString java.lang.Object.wait java.lang.Object.wait java.lang.Object.wait

字段详细信息

disposed

protected boolean disposed

指示对象是否已释放的内部标志。

eventCounter

protected AtomicInteger eventCounter

用于跟踪事件注册状态的内部事件计数器。

sessionStarted

public final EventHandlerImpl sessionStarted

定义会话启动事件的事件处理程序。

sessionStopped

public final EventHandlerImpl sessionStopped

为会话停止事件定义事件处理程序。

speechEndDetected

public final EventHandlerImpl speechEndDetected

为检测到的语音结束事件定义事件处理程序。

speechStartDetected

public final EventHandlerImpl speechStartDetected

为检测到的语音启动事件定义事件处理程序。

构造函数详细信息

Recognizer

protected Recognizer(AudioConfig audioInput)

创建并初始化识别器实例

Parameters:

audioInput - 与识别器关联的可选音频输入配置

方法详细信息

canceledSetCallback

protected final native long canceledSetCallback(long recoHandle)

用于设置已取消回调的内部方法。

Parameters:

recoHandle - 本机识别器句柄。

Returns:

操作的本机结果句柄。

close

public void close()

释放关联的资源。 注意:必须调用 close () 才能释放对象持有的基础资源。

dispose

protected void dispose(boolean disposing)

此方法执行资源清理。 布尔参数释放指示是否从 dispose (调用方法(如果释放为 true) )或从终结器 ((如果释放为 false) )。 如果需要,派生类应重写此方法以释放资源。

Parameters:

disposing - 请求处置的标志。

doAsyncRecognitionAction

protected void doAsyncRecognitionAction(Runnable recoImplAction)

用于运行识别操作的内部方法。

Parameters:

recoImplAction - 识别操作的可运行项。

getImpl

public SafeHandle getImpl()

返回内部识别器实例

Returns:

内部识别器实例

getPropertyBagFromRecognizerHandle

protected final native long getPropertyBagFromRecognizerHandle(SafeHandle recoHandle, IntRef propertyHandle)

用于从识别器句柄获取属性包的内部方法。

Parameters:

recoHandle - 本机识别器句柄。
propertyHandle - 本机属性句柄。

Returns:

操作的本机结果句柄。

recognize

protected long recognize()

用于开始识别一次操作的内部方法。

Returns:

识别的本机结果句柄。

recognizedSetCallback

protected final native long recognizedSetCallback(long recoHandle)

用于设置已识别回调的内部方法。

Parameters:

recoHandle - 本机识别器句柄。

Returns:

操作的本机结果句柄。

recognizingSetCallback

protected final native long recognizingSetCallback(long recoHandle)

用于设置识别回调的内部方法。

Parameters:

recoHandle - 本机识别器句柄。

Returns:

操作的本机结果句柄。

sessionStartedEventCallback

protected void sessionStartedEventCallback(long eventArgs)

用于处理本机会话启动事件的内部方法。

Parameters:

eventArgs - 本机事件参数。

sessionStartedSetCallback

protected final native long sessionStartedSetCallback(long recoHandle)

用于设置会话启动回调的内部方法。

Parameters:

recoHandle - 本机识别器句柄。

Returns:

操作的本机结果句柄。

sessionStoppedEventCallback

protected void sessionStoppedEventCallback(long eventArgs)

用于处理本机会话停止事件的内部方法。

Parameters:

eventArgs - 本机事件参数。

sessionStoppedSetCallback

protected final native long sessionStoppedSetCallback(long recoHandle)

用于设置会话停止回调的内部方法。

Parameters:

recoHandle - 本机识别器句柄。

Returns:

操作的本机结果句柄。

speechEndDetectedEventCallback

protected void speechEndDetectedEventCallback(long eventArgs)

用于处理检测到本机语音结束事件的内部方法。

Parameters:

eventArgs - 本机事件参数。

speechEndDetectedSetCallback

protected final native long speechEndDetectedSetCallback(long recoHandle)

用于设置检测到的语音结束回调的内部方法。

Parameters:

recoHandle - 本机识别器句柄。

Returns:

操作的本机结果句柄。

speechStartDetectedEventCallback

protected void speechStartDetectedEventCallback(long eventArgs)

用于处理检测到的本机语音启动事件的内部方法。

Parameters:

eventArgs - 本机事件参数。

speechStartDetectedSetCallback

protected final native long speechStartDetectedSetCallback(long recoHandle)

用于设置语音启动检测到的回调的内部方法。

Parameters:

recoHandle - 本机识别器句柄。

Returns:

操作的本机结果句柄。

startContinuousRecognition

protected final native long startContinuousRecognition(SafeHandle recoHandle)

用于启动连续识别操作的内部方法。

Parameters:

recoHandle - 本机识别器句柄。

Returns:

操作的本机结果句柄。

startKeywordRecognition

protected final native long startKeywordRecognition(SafeHandle recoHandle, SafeHandle keywordModelHandle)

用于启动关键字 (keyword) 识别操作的内部方法。

Parameters:

recoHandle - 本机识别器句柄。
keywordModelHandle - 本机关键字 (keyword) 模型句柄。

Returns:

操作的本机结果句柄。

stopContinuousRecognition

protected final native long stopContinuousRecognition(SafeHandle recoHandle)

用于停止连续识别操作的内部方法。

Parameters:

recoHandle - 本机识别器句柄。

Returns:

操作的本机结果句柄。

stopKeywordRecognition

protected final native long stopKeywordRecognition(SafeHandle recoHandle)

用于停止关键字 (keyword) 识别操作的内部方法。

Parameters:

recoHandle - 本机识别器句柄。

Returns:

操作的本机结果句柄。

适用于