java.lang.Object
org.openhab.core.model.script.actions.Voice

@NonNullByDefault public class Voice extends Object
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

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static String
    Interprets the given text.
    static String
    interpret(Object text, @Nullable String interpreters)
    Interprets the given text with a given Human Language Interpreter.
    static String
    interpret(Object text, String interpreters, @Nullable String sink)
    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
    say(Object text)
    Says the given text.
    static void
    say(Object text, float volume)
     
    static void
    say(Object text, @Nullable String voice)
    Says the given text with a given voice.
    static void
    say(Object text, @Nullable String voice, float volume)
     
    static void
    say(Object text, @Nullable String voice, @Nullable String sink)
    Says the given text with a given voice through the given sink.
    static void
    say(Object text, @Nullable String voice, @Nullable String sink, float volume)
     
    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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Voice

      public Voice()
  • Method Details

    • say

      public static void say(Object text)
      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

      public static void say(Object text, @Nullable PercentType volume)
      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 speak
      volume - The volume to be used
    • say

      public static void say(Object text, float volume)
    • say

      public static void say(Object text, @Nullable String voice)
      Says the given text with a given voice. This method uses the default audio sink to play the audio.
      Parameters:
      text - The text to speak
      voice - 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

      public static void say(Object text, @Nullable String voice, PercentType volume)
      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 speak
      voice - 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

      public static void say(Object text, @Nullable String voice, float volume)
    • say

      public static void say(Object text, @Nullable String voice, @Nullable String sink)
      Says the given text with a given voice through the given sink.
      Parameters:
      text - The text to speak
      voice - 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 speak
      voice - 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
      volume - The volume to be used
    • say

      public static void say(Object text, @Nullable String voice, @Nullable String sink, float volume)
    • interpret

      public static String interpret(Object text)
      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

      public static String interpret(Object text, @Nullable String interpreters)
      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 interpret
      interpreters - Comma separated list of human language text interpreters to use
    • interpret

      public static String interpret(Object text, String interpreters, @Nullable String sink)
      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 interpret
      interpreters - Comma separated list of human language text interpreters to use
      sink - The name of audio sink to be used to play the error message
    • startDialog

      public 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.
      Parameters:
      source - the name of audio source to use or null to use the default source
      sink - 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 service
      stt - the speech-to-text service to use or null to use the default service
      tts - the text-to-speech service to use or null to use the default service
      voice - the voice to use or null to use the default voice or any voice provided by the text-to-speech service matching the locale
      interpreters - comma separated list of human language text interpreters to use or null to use the default service
      source - the name of audio source to use or null to use the default source
      sink - the name of audio sink to use or null to use the default sink
      locale - the locale to use or null to use the default locale
      keyword - the keyword to use during keyword spotting or null to use the default keyword
      listeningItem - the item to switch ON while listening to a question
    • stopDialog

      public static void stopDialog(@Nullable String source)
      Stops dialog processing for a given audio source.
      Parameters:
      source - the name of audio source or null to consider the default audio source
    • listenAndAnswer

      public 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.
      Parameters:
      source - the name of audio source to use or null to use the default source
      sink - 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 service
      tts - the text-to-speech service to use or null to use the default service
      voice - the voice to use or null to use the default voice or any voice provided by the text-to-speech service matching the locale
      interpreters - comma separated list of human language text interpreters to use or null to use the default service
      source - the name of audio source to use or null to use the default source
      sink - the name of audio sink to use or null to use the default sink
      locale - the locale to use or null to use the default locale
      listeningItem - the item to switch ON while listening to a question