Class: TermuxRubyApi::SubSystems::Tts

Inherits:
Base
  • Object
show all
Defined in:
lib/termux_ruby_api/sub_systems/tts.rb

Instance Attribute Summary

Attributes inherited from Base

#owner

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from TermuxRubyApi::SubSystems::Base

Instance Method Details

#enginesArray <Hash>

Returns the list of available engines

Returns:

  • (Array <Hash>)


28
29
30
# File 'lib/termux_ruby_api/sub_systems/tts.rb', line 28

def engines
  owner.json_api_command('tts-engines')
end

#speak(text, engine: nil, language: nil, region: nil, variant: nil, pitch: nil, rate: nil, stream: nil) ⇒ Object

Speaks a text through the TTS system

Parameters:

  • text (String)

    the text to be spoken

  • engine (String) (defaults to: nil)

    the engine to use (see #engines)

  • language (String) (defaults to: nil)

    the string code for the language to use

  • region (String) (defaults to: nil)

    the string code for the regional variaion of the selected language

  • variant (String) (defaults to: nil)

    the voice of the selected language

  • pitch (Fixnum) (defaults to: nil)

    the desired pitch: 1 neutral. <1 more grave. >1 more acute

  • rate (Fixnum) (defaults to: nil)

    the desired speak rate. 1 neutral. <1 slower. >1 faster

  • stream (String) (defaults to: nil)

    Android audio stream to use: One of ALARM, MUSIC, NOTIFICATION, RING, SYSTEM, VOICE_CALL



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/termux_ruby_api/sub_systems/tts.rb', line 14

def speak(text, engine: nil, language: nil, region: nil, variant: nil, pitch: nil, rate: nil, stream: nil)
  args = owner.generate_args_list([['-e', engine&.to_s],
                                   ['-l', language&.to_s],
                                   ['-n', region&.to_s],
                                   ['-v', variant&.to_s],
                                   ['-p', pitch&.to_s],
                                   ['-r', rate&.to_s],
                                   ['-s', stream&.to_s]
                                  ])
  owner.api_command('tts-speak', text, *args)
end