Class KeywordRecognizer

  • All Implemented Interfaces:
    AutoCloseable

    public final class KeywordRecognizer
    extends Object
    implements AutoCloseable
    Performs keyword recognition on the speech input. Note: close() must be called in order to release underlying resources held by the object.
    • Constructor Detail

      • KeywordRecognizer

        public KeywordRecognizer​(AudioConfig audioConfig)
        Creates a new instance of a keyword recognizer. If no audio config is provided as input parameter, it will be equivalent to calling with a config constructed with AudioConfig::FromDefaultMicrophoneInput.
        Parameters:
        audioConfig - audio configuration.
    • Method Detail

      • getProperties

        public PropertyCollection getProperties()
        The collection of properties and their values defined for KeywordRecognizer.
        Returns:
        The collection of properties and their values defined for KeywordRecognizer.
      • recognizeOnceAsync

        public Future<KeywordRecognitionResult> recognizeOnceAsync​(KeywordRecognitionModel model)
        Starts a keyword recognition session. This session will last until the first keyword is recognized. When this happens, Recognized event will be raised and the session will end. To rearm the keyword, the method needs to be called again after the event is emitted. Note: If no keyword is detected in the input, the task will never resolve unless StopRecognition method is called.
        Parameters:
        model - The keyword recognition model that specifies the keyword to be recognized.
        Returns:
        A task representing the keyword recognition operation. The task returns a value of KeywordRecognitionResult.
      • stopRecognitionAsync

        public Future<Void> stopRecognitionAsync()
        Stops a currently active keyword recognition session.
        Returns:
        A task representing the asynchronous operation that stops the recognition.
      • 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()
        Internal method to get the underlying handle to the keyword recognizer.
        Returns:
        the native handle to the underlying object.