Recognizer Class
- java.
lang. Object - com.
microsoft. cognitiveservices. speech. Recognizer
- com.
Implements
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
Event |
sessionStarted
Defines event handler for session started event. |
final
Event |
sessionStopped
Defines event handler for session stopped event. |
final
Event |
speechEndDetected
Defines event handler for speech end detected event. |
final
Event |
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. |
Safe |
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
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
Defines event handler for session started event.
sessionStopped
public final EventHandlerImpl
Defines event handler for session stopped event.
speechEndDetected
public final EventHandlerImpl
Defines event handler for speech end detected event.
speechStartDetected
public final EventHandlerImpl
Defines event handler for speech start detected event.
Constructor Details
Recognizer
protected Recognizer(AudioConfig audioInput)
Creates and initializes an instance of a Recognizer
Parameters:
Method Details
canceledSetCallback
protected final native long canceledSetCallback(long recoHandle)
Internal method to set canceled callback.
Parameters:
Returns:
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:
doAsyncRecognitionAction
protected void doAsyncRecognitionAction(Runnable recoImplAction)
Internal method to run recognition operation.
Parameters:
getImpl
public SafeHandle getImpl()
Returns the internal recognizer instance
Returns:
getPropertyBagFromRecognizerHandle
protected final native long getPropertyBagFromRecognizerHandle(SafeHandle recoHandle, IntRef propertyHandle)
Internal method to get the property bag from the recognizer handle.
Parameters:
Returns:
recognize
protected long recognize()
Internal method to start recognize once operation.
Returns:
recognizedSetCallback
protected final native long recognizedSetCallback(long recoHandle)
Internal method to set recognized callback.
Parameters:
Returns:
recognizingSetCallback
protected final native long recognizingSetCallback(long recoHandle)
Internal method to set recognizing callback.
Parameters:
Returns:
sessionStartedEventCallback
protected void sessionStartedEventCallback(long eventArgs)
Internal method to handle native session started event.
Parameters:
sessionStartedSetCallback
protected final native long sessionStartedSetCallback(long recoHandle)
Internal method to set session started callback.
Parameters:
Returns:
sessionStoppedEventCallback
protected void sessionStoppedEventCallback(long eventArgs)
Internal method to handle native session stopped event.
Parameters:
sessionStoppedSetCallback
protected final native long sessionStoppedSetCallback(long recoHandle)
Internal method to set session stopped callback.
Parameters:
Returns:
speechEndDetectedEventCallback
protected void speechEndDetectedEventCallback(long eventArgs)
Internal method to handle native speech end detected event.
Parameters:
speechEndDetectedSetCallback
protected final native long speechEndDetectedSetCallback(long recoHandle)
Internal method to set speech end detected callback.
Parameters:
Returns:
speechStartDetectedEventCallback
protected void speechStartDetectedEventCallback(long eventArgs)
Internal method to handle native speech start detected event.
Parameters:
speechStartDetectedSetCallback
protected final native long speechStartDetectedSetCallback(long recoHandle)
Internal method to set speech start detected callback.
Parameters:
Returns:
startContinuousRecognition
protected final native long startContinuousRecognition(SafeHandle recoHandle)
Internal method to start continuous recognition operation.
Parameters:
Returns:
startKeywordRecognition
protected final native long startKeywordRecognition(SafeHandle recoHandle, SafeHandle keywordModelHandle)
Internal method to start keyword recognition operation.
Parameters:
Returns:
stopContinuousRecognition
protected final native long stopContinuousRecognition(SafeHandle recoHandle)
Internal method to stop continuous recognition operation.
Parameters:
Returns:
stopKeywordRecognition
protected final native long stopKeywordRecognition(SafeHandle recoHandle)
Internal method to stop keyword recognition operation.
Parameters:
Returns:
Applies to
Azure SDK for Java