Package org.openhab.core.voice
Interface STTService
@NonNullByDefault
public interface STTService
This is the interface that a speech-to-text service has to implement.
- Author:
- Kelly Davis - Initial contribution
-
Method Summary
Modifier and TypeMethodDescriptiongetId()Returns a simple string that uniquely identifies this serviceReturns a localized human readable label that can be used within UIs.Obtain the audio formats supported by this STTServiceObtain the Locales available from this STTServicerecognize(STTListener sttListener, AudioStream audioStream, Locale locale, Set<String> grammars) This method starts the process of speech recognition.
-
Method Details
-
getId
String getId()Returns a simple string that uniquely identifies this service- Returns:
- an id that identifies this service
-
getLabel
Returns a localized human readable label that can be used within UIs.- Parameters:
locale- the locale to provide the label for- Returns:
- a localized string to be used in UIs
-
getSupportedLocales
Obtain the Locales available from this STTService- Returns:
- The Locales available from this service
-
getSupportedFormats
Set<AudioFormat> getSupportedFormats()Obtain the audio formats supported by this STTService- Returns:
- The audio formats supported by this service
-
recognize
STTServiceHandle recognize(STTListener sttListener, AudioStream audioStream, Locale locale, Set<String> grammars) throws STTException This method starts the process of speech recognition. The audio data of the passedAudioStreamis passed to the speech recognition engine. The recognition engine attempts to recognize speech as being spoken in the passedLocaleand containing statements specified in the passedgrammars. Recognition is indicated by firedSTTEventevents targeting the passedSTTListener. The passedAudioStreammust be of a supportedAudioFormat. In other words anAudioFormatcompatible with one returned from thegetSupportedFormats()method. The passedLocalemust be supported. That is to say it must be aLocalereturned from thegetSupportedLocales()method. The passedgrammarsmust consist of a syntactically valid grammar as specified by the JSpeech Grammar Format. Ifgrammarsis null or empty, large vocabulary continuous speech recognition is attempted.- Parameters:
sttListener- Non-nullSTTListenerthatSTTEventevents targetaudioStream- TheAudioStreamfrom which speech is recognizedlocale- TheLocalein which the target speech is spokengrammars- The JSpeech Grammar Format grammar specifying allowed statements- Returns:
- A
STTServiceHandleused to abort recognition - Throws:
STTException- if any parameter is invalid or a STT problem occurs- See Also:
-