Speech synthesis: Difference between revisions
Content added Content deleted
(→{{header|Ruby}}: additional operating systems) |
(→{{header|Ruby}}: I have espeak for OpenBSD, but this script failed because it only checked for Linux.) |
||
Line 83:
<lang ruby>module OperatingSystem
require 'rbconfig'
module_function
def
case RbConfig::CONFIG["host_os"]
when /linux/i
Line 97 ⟶ 98:
end
end
def
def
def
end</lang>
{{libheader|win32-utils}}
{{works with|Ruby|1.9}}
Uses <code>espeak</code> on Linux, <code>say</code> on Mac, and the win32 SAPI library on Windows.
<lang ruby>load 'operating_system.rb'
Line 111 ⟶ 113:
v = Win32::SpVoice.new
v.Speak(text)
IO.popen(["espeak", "-stdin"], "w") {|pipe| pipe.puts text}▼
elsif OperatingSystem.mac?
IO.popen(["say"], "w") {|pipe| pipe.puts text}
else
# Try to run "espeak". No OperatingSystem check: "espeak" is
# for Linux but is also an optional package for BSD.
▲ IO.popen(["espeak", "-stdin"], "w") {|pipe| pipe.puts text}
end
end
|