Class: James::Outputs::Audio

Inherits:
Object
  • Object
show all
Defined in:
lib/james/outputs/audio.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Audio

Create a new audio output.

Options:

* voice # Default is 'com.apple.speech.synthesis.voice.Alex'.


12
13
14
# File 'lib/james/outputs/audio.rb', line 12

def initialize options = {}
  @output = NSSpeechSynthesizer.alloc.initWithVoice options[:voice] || 'com.apple.speech.synthesis.voice.Alex'
end

Instance Method Details

#say(text) ⇒ Object

Say the given text out loud.

Waits for the last text to be finished



20
21
22
23
24
25
# File 'lib/james/outputs/audio.rb', line 20

def say text
  while @output.isSpeaking
    sleep 0.1
  end
  @output.startSpeakingString text
end