KeywordRecognizer Class

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

Implements

java.lang.AutoCloseable

public final class KeywordRecognizer
implements java.lang.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

Modifier and Type Field and Description
final EventHandlerImpl<SpeechRecognitionCanceledEventArgs> canceled

The signal for events relating to the cancellation of an interaction.

final EventHandlerImpl<KeywordRecognitionEventArgs> recognized

The signal for events related to the recognition of keywords

Constructor Summary

Constructor Description
KeywordRecognizer(AudioConfig audioConfig)

Creates a new instance of a keyword recognizer.

Method Summary

Modifier and Type Method and Description
void close()

Dispose of associated resources.

SafeHandle getImpl()

Internal method to get the underlying handle to the keyword recognizer.

PropertyCollection getProperties()

The collection of properties and their values defined for KeywordRecognizer.

java.util.concurrent.Future<KeywordRecognitionResult> recognizeOnceAsync(KeywordRecognitionModel model)

Starts a keyword recognition session.

java.util.concurrent.Future<java.lang.Void> stopRecognitionAsync()

Stops a currently active keyword recognition session.

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

canceled

public final EventHandlerImpl 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.

recognized

public final EventHandlerImpl recognized

The signal for events related to the recognition of keywords

Constructor Details

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 Details

close

public void close()

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

getImpl

public SafeHandle getImpl()

Internal method to get the underlying handle to the keyword recognizer.

Returns:

the native handle to the underlying object.

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 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 stopRecognitionAsync()

Stops a currently active keyword recognition session.

Returns:

A task representing the asynchronous operation that stops the recognition.

Applies to