Module: YandexSpeechApi::Sounds

Defined in:
lib/yandex_speech/sounds.rb

Class Method Summary collapse

Class Method Details

.play(srs) ⇒ Object

Parameters:

  • srs (String)


8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/yandex_speech/sounds.rb', line 8

def self.play(srs)
  file = Tempfile.new 'yandex_speech_temp_file.mp3'
  file << srs
  file.close

  case operation_system
  when :linux
    exec "mpg123 -q '#{file.path}'"
  when :mac_os
    exec "afplay '#{file.path}'"
  end

  file.unlink
end