Class: Belphanior::Servant::Speech::Adaptors::Espeak

Inherits:
Object
  • Object
show all
Defined in:
lib/belphanior/servant/speech/espeak.rb

Defined Under Namespace

Classes: Exception

Instance Method Summary collapse

Constructor Details

#initialize(syscall = nil) ⇒ Espeak



10
11
12
13
14
15
# File 'lib/belphanior/servant/speech/espeak.rb', line 10

def initialize(syscall=nil)
  @syscall = syscall
  if not @syscall
    @syscall=Kernel
  end
end

Instance Method Details

#say(message, speech_properties = {}) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/belphanior/servant/speech/espeak.rb', line 17

def say(message, speech_properties={})
  args=""
  if speech_properties.has_key?(:voice)
    args += "-v \"#{speech_properties[:voice]}\" "
  end
  command_line = "espeak #{args}\"#{message}\""
  result = @syscall.system(command_line)
  if not result
    raise Exception,
    "Error in say: Tried to shell '#{command_line}', but "
    "result was '#{$?}'"
  end
end