Compartir a través de


KeywordRecognitionModel Class

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

Implements

java.lang.AutoCloseable

public class KeywordRecognitionModel
implements java.lang.AutoCloseable

Represents a keyword recognition model for recognizing when the user says a keyword to initiate further speech recognition. Note: close() must be called in order to release underlying resources held by the object.

Method Summary

Modifier and Type Method and Description
void close()

Dispose of associated resources.

static KeywordRecognitionModel fromConfig(EmbeddedSpeechConfig embeddedSpeechConfig)

Creates a keyword recognition model using the specified embedded speech config.

static KeywordRecognitionModel fromConfig(EmbeddedSpeechConfig embeddedSpeechConfig, List<String> userDefinedWakeWords)

Creates a keyword recognition model using the specified embedded speech config and user-defined wake words.

static KeywordRecognitionModel fromFile(String fileName)

Creates a keyword recognition model using the specified filename.

static KeywordRecognitionModel fromStream(InputStream inputStream, String name, boolean isZipped)

Creates a keyword recognition model using the specified input stream.

SafeHandle getImpl()

Returns the keyword recognition model.

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

Method Details

close

public void close()

Dispose of associated resources.

fromConfig

public static KeywordRecognitionModel fromConfig(EmbeddedSpeechConfig embeddedSpeechConfig)

Creates a keyword recognition model using the specified embedded speech config.

Parameters:

embeddedSpeechConfig - Embedded speech config.

Returns:

The keyword recognition model.

fromConfig

public static KeywordRecognitionModel fromConfig(EmbeddedSpeechConfig embeddedSpeechConfig, List userDefinedWakeWords)

Creates a keyword recognition model using the specified embedded speech config and user-defined wake words.

Parameters:

embeddedSpeechConfig - Embedded speech config.
userDefinedWakeWords - User-defined wake words.

Returns:

The keyword recognition model.

fromFile

public static KeywordRecognitionModel fromFile(String fileName)

Creates a keyword recognition model using the specified filename.

Parameters:

fileName - A string that represents file name for the keyword recognition model. Note, the file can point to a zip file in which case the model will be extracted from the zip.

Returns:

The keyword recognition model being created.

fromStream

public static KeywordRecognitionModel fromStream(InputStream inputStream, String name, boolean isZipped)

Creates a keyword recognition model using the specified input stream.

Parameters:

inputStream - A stream that represents data for the keyword recognition model. Note, the file can be a zip file in which case the model will be extracted from the zip.
name - The name of the keyword. Note: The name needs to be unique for different keywords as it will be used internally to match a particular keyword spotter model. In case you are updating the keyword with a new version, add a version tag to the name or otherwise the previous version will be overwritten on disk.
isZipped - If true, the input stream is treated as a zip. false, if the input is just the kws table file.

Returns:

The keyword recognition model being created.

Throws:

java.io.IOException - In case the kws.table file was not found or the temp directory could not be created.

getImpl

public SafeHandle getImpl()

Returns the keyword recognition model.

Returns:

The implementation of the model.

Applies to