Megosztás a következőn keresztül:


Recognizer Class

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

Implements

java.lang.AutoCloseable

public class Recognizer
implements java.lang.AutoCloseable

Defines the base class Recognizer which mainly contains common event handlers. Note: close() must be called in order to release underlying resources held by the object.

Field Summary

Modifier and Type Field and Description
protected boolean disposed

Internal flag to indicate whether the object has been disposed.

protected java.util.concurrent.atomic.AtomicInteger eventCounter

Internal event counter to track event registration status.

final EventHandlerImpl<SessionEventArgs> sessionStarted

Defines event handler for session started event.

final EventHandlerImpl<SessionEventArgs> sessionStopped

Defines event handler for session stopped event.

final EventHandlerImpl<RecognitionEventArgs> speechEndDetected

Defines event handler for speech end detected event.

final EventHandlerImpl<RecognitionEventArgs> speechStartDetected

Defines event handler for speech start detected event.

Constructor Summary

Modifier Constructor Description
protected Recognizer(AudioConfig audioInput)

Creates and initializes an instance of a Recognizer

Method Summary

Modifier and Type Method and Description
protected final native long canceledSetCallback(long recoHandle)

Internal method to set canceled callback.

void close()

Dispose of associated resources.

protected void dispose(boolean disposing)

This method performs cleanup of resources.

protected void doAsyncRecognitionAction(Runnable recoImplAction)

Internal method to run recognition operation.

SafeHandle getImpl()

Returns the internal recognizer instance

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

Internal method to get the property bag from the recognizer handle.

protected long recognize()

Internal method to start recognize once operation.

protected final native long recognizedSetCallback(long recoHandle)

Internal method to set recognized callback.

protected final native long recognizingSetCallback(long recoHandle)

Internal method to set recognizing callback.

protected void sessionStartedEventCallback(long eventArgs)

Internal method to handle native session started event.

protected final native long sessionStartedSetCallback(long recoHandle)

Internal method to set session started callback.

protected void sessionStoppedEventCallback(long eventArgs)

Internal method to handle native session stopped event.

protected final native long sessionStoppedSetCallback(long recoHandle)

Internal method to set session stopped callback.

protected void speechEndDetectedEventCallback(long eventArgs)

Internal method to handle native speech end detected event.

protected final native long speechEndDetectedSetCallback(long recoHandle)

Internal method to set speech end detected callback.

protected void speechStartDetectedEventCallback(long eventArgs)

Internal method to handle native speech start detected event.

protected final native long speechStartDetectedSetCallback(long recoHandle)

Internal method to set speech start detected callback.

protected final native long startContinuousRecognition(SafeHandle recoHandle)

Internal method to start continuous recognition operation.

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

Internal method to start keyword recognition operation.

protected final native long stopContinuousRecognition(SafeHandle recoHandle)

Internal method to stop continuous recognition operation.

protected final native long stopKeywordRecognition(SafeHandle recoHandle)

Internal method to stop keyword recognition operation.

Methods inherited from 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

Field Details

disposed

protected boolean disposed

Internal flag to indicate whether the object has been disposed.

eventCounter

protected AtomicInteger eventCounter

Internal event counter to track event registration status.

sessionStarted

public final EventHandlerImpl sessionStarted

Defines event handler for session started event.

sessionStopped

public final EventHandlerImpl sessionStopped

Defines event handler for session stopped event.

speechEndDetected

public final EventHandlerImpl speechEndDetected

Defines event handler for speech end detected event.

speechStartDetected

public final EventHandlerImpl speechStartDetected

Defines event handler for speech start detected event.

Constructor Details

Recognizer

protected Recognizer(AudioConfig audioInput)

Creates and initializes an instance of a Recognizer

Parameters:

audioInput - An optional audio input configuration associated with the recognizer

Method Details

canceledSetCallback

protected final native long canceledSetCallback(long recoHandle)

Internal method to set canceled callback.

Parameters:

recoHandle - The native recognizer handle.

Returns:

The native result handle of the operation.

close

public void close()

Dispose of associated resources. Note: close() must be called in order to release underlying resources held by the object.

dispose

protected void dispose(boolean disposing)

This method performs cleanup of resources. The Boolean parameter disposing indicates whether the method is called from Dispose (if disposing is true) or from the finalizer (if disposing is false). Derived classes should override this method to dispose resource if needed.

Parameters:

disposing - Flag to request disposal.

doAsyncRecognitionAction

protected void doAsyncRecognitionAction(Runnable recoImplAction)

Internal method to run recognition operation.

Parameters:

recoImplAction - The runnable of the recognition operation.

getImpl

public SafeHandle getImpl()

Returns the internal recognizer instance

Returns:

The internal recognizer instance

getPropertyBagFromRecognizerHandle

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

Internal method to get the property bag from the recognizer handle.

Parameters:

recoHandle - The native recognizer handle.
propertyHandle - The native property handle.

Returns:

The native result handle of the operation.

recognize

protected long recognize()

Internal method to start recognize once operation.

Returns:

The native result handle of the recognition.

recognizedSetCallback

protected final native long recognizedSetCallback(long recoHandle)

Internal method to set recognized callback.

Parameters:

recoHandle - The native recognizer handle.

Returns:

The native result handle of the operation.

recognizingSetCallback

protected final native long recognizingSetCallback(long recoHandle)

Internal method to set recognizing callback.

Parameters:

recoHandle - The native recognizer handle.

Returns:

The native result handle of the operation.

sessionStartedEventCallback

protected void sessionStartedEventCallback(long eventArgs)

Internal method to handle native session started event.

Parameters:

eventArgs - The native event args.

sessionStartedSetCallback

protected final native long sessionStartedSetCallback(long recoHandle)

Internal method to set session started callback.

Parameters:

recoHandle - The native recognizer handle.

Returns:

The native result handle of the operation.

sessionStoppedEventCallback

protected void sessionStoppedEventCallback(long eventArgs)

Internal method to handle native session stopped event.

Parameters:

eventArgs - The native event args.

sessionStoppedSetCallback

protected final native long sessionStoppedSetCallback(long recoHandle)

Internal method to set session stopped callback.

Parameters:

recoHandle - The native recognizer handle.

Returns:

The native result handle of the operation.

speechEndDetectedEventCallback

protected void speechEndDetectedEventCallback(long eventArgs)

Internal method to handle native speech end detected event.

Parameters:

eventArgs - The native event args.

speechEndDetectedSetCallback

protected final native long speechEndDetectedSetCallback(long recoHandle)

Internal method to set speech end detected callback.

Parameters:

recoHandle - The native recognizer handle.

Returns:

The native result handle of the operation.

speechStartDetectedEventCallback

protected void speechStartDetectedEventCallback(long eventArgs)

Internal method to handle native speech start detected event.

Parameters:

eventArgs - The native event args.

speechStartDetectedSetCallback

protected final native long speechStartDetectedSetCallback(long recoHandle)

Internal method to set speech start detected callback.

Parameters:

recoHandle - The native recognizer handle.

Returns:

The native result handle of the operation.

startContinuousRecognition

protected final native long startContinuousRecognition(SafeHandle recoHandle)

Internal method to start continuous recognition operation.

Parameters:

recoHandle - The native recognizer handle.

Returns:

The native result handle of the operation.

startKeywordRecognition

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

Internal method to start keyword recognition operation.

Parameters:

recoHandle - The native recognizer handle.
keywordModelHandle - The native keyword model handle.

Returns:

The native result handle of the operation.

stopContinuousRecognition

protected final native long stopContinuousRecognition(SafeHandle recoHandle)

Internal method to stop continuous recognition operation.

Parameters:

recoHandle - The native recognizer handle.

Returns:

The native result handle of the operation.

stopKeywordRecognition

protected final native long stopKeywordRecognition(SafeHandle recoHandle)

Internal method to stop keyword recognition operation.

Parameters:

recoHandle - The native recognizer handle.

Returns:

The native result handle of the operation.

Applies to