Class KeywordRecognizer
- java.lang.Object
-
- com.microsoft.cognitiveservices.speech.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.
-
-
Field Summary
Fields Modifier and Type Field Description EventHandlerImpl<SpeechRecognitionCanceledEventArgs>canceledThe signal for events relating to the cancellation of an interaction.EventHandlerImpl<KeywordRecognitionEventArgs>recognizedThe signal for events related to the recognition of keywords
-
Constructor Summary
Constructors Constructor Description KeywordRecognizer(AudioConfig audioConfig)Creates a new instance of a keyword recognizer.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Dispose of associated resources.SafeHandlegetImpl()Internal method to get the underlying handle to the keyword recognizer.PropertyCollectiongetProperties()The collection of properties and their values defined for KeywordRecognizer.Future<KeywordRecognitionResult>recognizeOnceAsync(KeywordRecognitionModel model)Starts a keyword recognition session.Future<Void>stopRecognitionAsync()Stops a currently active keyword recognition session.
-
-
-
Field Detail
-
recognized
public final EventHandlerImpl<KeywordRecognitionEventArgs> recognized
The signal for events related to the recognition of keywords
-
canceled
public final EventHandlerImpl<SpeechRecognitionCanceledEventArgs> canceled
The signal for events relating to the cancellation of an interaction. The event indicates if the reason is a direct cancellation or an error.
-
-
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:
closein interfaceAutoCloseable
-
getImpl
public SafeHandle getImpl()
Internal method to get the underlying handle to the keyword recognizer.- Returns:
- the native handle to the underlying object.
-
-