Class: James::Outputs::Audio
- Inherits:
-
Object
- Object
- James::Outputs::Audio
- Defined in:
- lib/james/outputs/audio.rb
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Audio
constructor
Create a new audio output.
-
#say(text) ⇒ Object
Say the given text out loud.
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 = {} @output = NSSpeechSynthesizer.alloc.initWithVoice [: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 |