Package org.openhab.core.voice
Interface KSService
- All Known Subinterfaces:
KSEdgeService
@NonNullByDefault
public interface KSService
This is the interface that a keyword spotting service has to implement.
- Author:
- Kelly Davis - Initial contribution, Kai Kreuzer - Refactored to use AudioStream
-
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 KSServiceObtain the Locales available from this KSServicespot
(KSListener ksListener, AudioStream audioStream, Locale locale, String keyword) This method starts the process of keyword spotting The audio data of the passedAudioStream
is passed to the keyword spotting engine.
-
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 KSService- Returns:
- The Locales available from this service
-
getSupportedFormats
Set<AudioFormat> getSupportedFormats()Obtain the audio formats supported by this KSService- Returns:
- The audio formats supported by this service
-
spot
KSServiceHandle spot(KSListener ksListener, AudioStream audioStream, Locale locale, String keyword) throws KSException This method starts the process of keyword spotting The audio data of the passedAudioStream
is passed to the keyword spotting engine. The keyword spotting attempts to spotkeyword
as being spoken in the passedLocale
. Spotted keyword is indicated by firedKSEvent
events targeting the passedKSListener
. The passedAudioStream
must be of a supportedAudioFormat
. In other words anAudioFormat
compatible with one returned from thegetSupportedFormats()
method. The passedLocale
must be supported. That is to say it must be aLocale
returned from thegetSupportedLocales()
method. The passedkeyword
is the keyword which should be spotted. The method is supposed to return fast, i.e. it should only start the spotting as a background process.- Parameters:
ksListener
- Non-nullKSListener
thatKSEvent
events targetaudioStream
- TheAudioStream
from which keywords are spottedlocale
- TheLocale
in which the target keywords are spokenkeyword
- The keyword which to spot- Returns:
- A
KSServiceHandle
used to abort keyword spotting - Throws:
A
-KSException
if any parameter is invalid or a problem occursKSException
-