Class Recognizer

    • Field Detail

      • eventCounter

        protected AtomicInteger eventCounter
        Internal event counter to track event registration status.
      • AUTH_TOKEN_EXPIRY_PROPERTY

        protected static final String AUTH_TOKEN_EXPIRY_PROPERTY
        Property name for the token expiration time in milliseconds.
        See Also:
        Constant Field Values
      • AUTH_TOKEN_ERROR_PROPERTY

        protected static final String AUTH_TOKEN_ERROR_PROPERTY
        Property name for the last authentication token error.
        See Also:
        Constant Field Values
      • AUTH_TOKEN_REFRESH_INTERVAL_MS_PROPERTY

        protected static final String AUTH_TOKEN_REFRESH_INTERVAL_MS_PROPERTY
        Property name for the token refresh interval in milliseconds.
        See Also:
        Constant Field Values
      • disposed

        protected boolean disposed
        Internal flag to indicate whether the object has been disposed.
    • Constructor Detail

      • Recognizer

        protected Recognizer​(AudioConfig audioInput,
                             com.azure.core.credential.TokenCredential tokenCredential)
        Creates and initializes an instance of a Recognizer
        Parameters:
        audioInput - An optional audio input configuration associated with the recognizer
        tokenCredential - An optional audio input configuration associated with the recognizer
    • Method Detail

      • close

        public void close()
        Dispose of associated resources. Note: close() must be called in order to release underlying resources held by the object.
        Specified by:
        close in interface AutoCloseable
      • getImpl

        public SafeHandle getImpl()
        Returns the internal recognizer instance
        Returns:
        The internal recognizer instance
      • 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.
      • recognize

        protected long recognize()
        Internal method to start recognize once operation.
        Returns:
        The native result handle of the recognition.
      • sessionStartedEventCallback

        protected void sessionStartedEventCallback​(long eventArgs)
        Internal method to handle native session started event.
        Parameters:
        eventArgs - The native event args.
      • sessionStoppedEventCallback

        protected void sessionStoppedEventCallback​(long eventArgs)
        Internal method to handle native session stopped event.
        Parameters:
        eventArgs - The native event args.
      • tokenRefreshEventCallback

        protected void tokenRefreshEventCallback​(long eventArgs)
        Internal method to handle native token refresh event.
        Parameters:
        eventArgs - The native event args.
      • speechStartDetectedEventCallback

        protected void speechStartDetectedEventCallback​(long eventArgs)
        Internal method to handle native speech start detected event.
        Parameters:
        eventArgs - The native event args.
      • speechEndDetectedEventCallback

        protected void speechEndDetectedEventCallback​(long eventArgs)
        Internal method to handle native speech end detected event.
        Parameters:
        eventArgs - The native event args.
      • setUpTokenRefreshCallback

        protected void setUpTokenRefreshCallback​(PropertyCollection property)
        Sets up a callback for the token refresh event.
        Parameters:
        property - The property collection.
      • updateAuthToken

        protected void updateAuthToken​(PropertyCollection property)
        Updates the authentication token in the given PropertyCollection.
      • startContinuousRecognition

        protected final 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.
      • stopContinuousRecognition

        protected final 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.
      • startKeywordRecognition

        protected final 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.
      • stopKeywordRecognition

        protected final 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.
      • recognizingSetCallback

        protected final long recognizingSetCallback​(long recoHandle)
        Internal method to set recognizing callback.
        Parameters:
        recoHandle - The native recognizer handle.
        Returns:
        The native result handle of the operation.
      • recognizedSetCallback

        protected final long recognizedSetCallback​(long recoHandle)
        Internal method to set recognized callback.
        Parameters:
        recoHandle - The native recognizer handle.
        Returns:
        The native result handle of the operation.
      • canceledSetCallback

        protected final long canceledSetCallback​(long recoHandle)
        Internal method to set canceled callback.
        Parameters:
        recoHandle - The native recognizer handle.
        Returns:
        The native result handle of the operation.
      • sessionStartedSetCallback

        protected final 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.
      • sessionStoppedSetCallback

        protected final 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.
      • tokenRefreshSetCallback

        protected final long tokenRefreshSetCallback​(long recoHandle)
        Internal method to set token refresh callback.
        Parameters:
        recoHandle - The native recognizer handle.
        Returns:
        The native result handle of the operation.
      • speechStartDetectedSetCallback

        protected final 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.
      • speechEndDetectedSetCallback

        protected final 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.
      • getPropertyBagFromRecognizerHandle

        protected final 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.