Class Voice
java.lang.Object
org.openhab.core.model.script.actions.Voice
The static methods of this class are made available as functions in the scripts.
This allows a script to use voice features.
- Author:
- Kai Kreuzer - Initial contribution, Christoph Weitkamp - Added parameter to adjust the volume
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
Interprets the given text.static String
Interprets the given text with a given Human Language Interpreter.static String
Interprets the given text with a given Human Language Interpreter.static void
listenAndAnswer
(@Nullable String source, @Nullable String sink) Executes a simple dialog sequence without keyword spotting for a given audio source using default speech-to-text service, default text-to-speech service, default human language text interpreter and default locale.static void
listenAndAnswer
(@Nullable String stt, @Nullable String tts, @Nullable String voice, @Nullable String interpreters, @Nullable String source, @Nullable String sink, @Nullable String locale, @Nullable String listeningItem) Executes a simple dialog sequence without keyword spotting for a given audio source.static void
Says the given text.static void
static void
Says the given text with a given voice.static void
static void
Says the given text with a given voice through the given sink.static void
static void
say
(Object text, @Nullable String voice, @Nullable String sink, @Nullable PercentType volume) Says the given text with a given voice and the given volume through the given sink.static void
say
(Object text, @Nullable String voice, PercentType volume) Says the given text with a given voice and the given volume.static void
say
(Object text, @Nullable PercentType volume) Says the given text with the given volume.static void
startDialog
(@Nullable String source, @Nullable String sink) Starts dialog processing for a given audio source using default keyword spotting service, default speech-to-text service, default text-to-speech service and default human language text interpreter.static void
startDialog
(@Nullable String ks, @Nullable String stt, @Nullable String tts, @Nullable String voice, @Nullable String interpreters, @Nullable String source, @Nullable String sink, @Nullable String locale, @Nullable String keyword, @Nullable String listeningItem) Starts dialog processing for a given audio source.static void
stopDialog
(@Nullable String source) Stops dialog processing for a given audio source.
-
Constructor Details
-
Voice
public Voice()
-
-
Method Details
-
say
Says the given text. This method uses the default voice and the default audio sink to play the audio.- Parameters:
text
- The text to speak
-
say
Says the given text with the given volume. This method uses the default voice and the default audio sink to play the audio.- Parameters:
text
- The text to speakvolume
- The volume to be used
-
say
-
say
Says the given text with a given voice. This method uses the default audio sink to play the audio.- Parameters:
text
- The text to speakvoice
- The name of the voice to use or null, if the default voice should be used. If the voiceId is fully qualified (i.e. with a tts prefix), the according TTS service will be used, otherwise the voiceId is assumed to be available on the default TTS service.
-
say
Says the given text with a given voice and the given volume. This method uses the default audio sink to play the audio.- Parameters:
text
- The text to speakvoice
- The name of the voice to use or null, if the default voice should be used. If the voiceId is fully qualified (i.e. with a tts prefix), the according TTS service will be used, otherwise the voiceId is assumed to be available on the default TTS service.volume
- The volume to be used
-
say
-
say
Says the given text with a given voice through the given sink.- Parameters:
text
- The text to speakvoice
- The name of the voice to use or null, if the default voice should be used. If the voiceId is fully qualified (i.e. with a tts prefix), the according TTS service will be used, otherwise the voiceId is assumed to be available on the default TTS service.sink
- The name of audio sink to be used to play the audio or null, if the default sink should be used
-
say
public static void say(Object text, @Nullable String voice, @Nullable String sink, @Nullable PercentType volume) Says the given text with a given voice and the given volume through the given sink.- Parameters:
text
- The text to speakvoice
- The name of the voice to use or null, if the default voice should be used. If the voiceId is fully qualified (i.e. with a tts prefix), the according TTS service will be used, otherwise the voiceId is assumed to be available on the default TTS service.sink
- The name of audio sink to be used to play the audio or null, if the default sink should be usedvolume
- The volume to be used
-
say
-
interpret
Interprets the given text. This method uses the default Human Language Interpreter and passes the text to it. In case of interpretation error, the error message is played using the default audio sink.- Parameters:
text
- The text to interpret
-
interpret
Interprets the given text with a given Human Language Interpreter. In case of interpretation error, the error message is played using the default audio sink.- Parameters:
text
- The text to interpretinterpreters
- Comma separated list of human language text interpreters to use
-
interpret
Interprets the given text with a given Human Language Interpreter. In case of interpretation error, the error message is played using the given audio sink. If sink parameter is null, the error message is simply not played.- Parameters:
text
- The text to interpretinterpreters
- Comma separated list of human language text interpreters to usesink
- The name of audio sink to be used to play the error message
-
startDialog
Starts dialog processing for a given audio source using default keyword spotting service, default speech-to-text service, default text-to-speech service and default human language text interpreter.- Parameters:
source
- the name of audio source to use or null to use the default sourcesink
- the name of audio sink to use or null to use the default sink
-
startDialog
public static void startDialog(@Nullable String ks, @Nullable String stt, @Nullable String tts, @Nullable String voice, @Nullable String interpreters, @Nullable String source, @Nullable String sink, @Nullable String locale, @Nullable String keyword, @Nullable String listeningItem) Starts dialog processing for a given audio source.- Parameters:
ks
- the keyword spotting service to use or null to use the default servicestt
- the speech-to-text service to use or null to use the default servicetts
- the text-to-speech service to use or null to use the default servicevoice
- the voice to use or null to use the default voice or any voice provided by the text-to-speech service matching the localeinterpreters
- comma separated list of human language text interpreters to use or null to use the default servicesource
- the name of audio source to use or null to use the default sourcesink
- the name of audio sink to use or null to use the default sinklocale
- the locale to use or null to use the default localekeyword
- the keyword to use during keyword spotting or null to use the default keywordlisteningItem
- the item to switch ON while listening to a question
-
stopDialog
Stops dialog processing for a given audio source.- Parameters:
source
- the name of audio source or null to consider the default audio source
-
listenAndAnswer
Executes a simple dialog sequence without keyword spotting for a given audio source using default speech-to-text service, default text-to-speech service, default human language text interpreter and default locale.- Parameters:
source
- the name of audio source to use or null to use the default sourcesink
- the name of audio sink to use or null to use the default sink
-
listenAndAnswer
public static void listenAndAnswer(@Nullable String stt, @Nullable String tts, @Nullable String voice, @Nullable String interpreters, @Nullable String source, @Nullable String sink, @Nullable String locale, @Nullable String listeningItem) Executes a simple dialog sequence without keyword spotting for a given audio source.- Parameters:
stt
- the speech-to-text service to use or null to use the default servicetts
- the text-to-speech service to use or null to use the default servicevoice
- the voice to use or null to use the default voice or any voice provided by the text-to-speech service matching the localeinterpreters
- comma separated list of human language text interpreters to use or null to use the default servicesource
- the name of audio source to use or null to use the default sourcesink
- the name of audio sink to use or null to use the default sinklocale
- the locale to use or null to use the default localelisteningItem
- the item to switch ON while listening to a question
-