Class KeywordRecognitionModel
- java.lang.Object
-
- com.microsoft.cognitiveservices.speech.KeywordRecognitionModel
-
- All Implemented Interfaces:
AutoCloseable
public class KeywordRecognitionModel extends Object implements 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
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Dispose of associated resources.static KeywordRecognitionModelfromFile(String fileName)Creates a keyword recognition model using the specified filename.static KeywordRecognitionModelfromStream(InputStream inputStream, String name, boolean isZipped)Creates a keyword recognition model using the specified input stream.SafeHandlegetImpl()Returns the keyword recognition model.
-
-
-
Method Detail
-
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) throws IOException
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:
IllegalArgumentException- In case the kws.table file was not found or the temp directory could not be created.IOException- If the name of the kws contains an illegal separator char, or in case the temp path and/or names are not valid.
-
close
public void close()
Dispose of associated resources.- Specified by:
closein interfaceAutoCloseable
-
getImpl
public SafeHandle getImpl()
Returns the keyword recognition model.- Returns:
- The implementation of the model.
-
-