system('espeak...
thing the only line of code you use for the text to speech? If so, it might not exit until it is finished talking. There is a very simple fix for this, and I'll tell you if this turns out to be your problem. :)
require "Gosu"
require "Texplay"
load "Emotion cadrant.rb"
class Alpha < Gosu::Window
def initialize
super(1024,768,false)
end
def start
$screen = Screen.new(0,448)
@val = 0
@back = Gosu::Image.new($window,"fond.png",false)
show
end
def update
$screen.speak("Bonjour") if @val == 50
Kernel.system('espeak -vfr "bonjour"') if @val == 50 ########
@val += 1
end
def draw
@back.draw(0,0,0)
$screen.draw
end
end
$window = Alpha.new
$window.start
def update
thread = Thread.fork do
# Changed this part a bit to remove a duplicate for you
if @val == 50
$screen.speak("Bonjour")
Kernel.system('espeak -vfr "bonjour"')
end
end
thread.run
@val += 1
end
system
waits for the program being called to finish, so your program is hanging there because it's waiting for espeak. If you want to let espeak run in the background and not wait for it to finish, there are a couple of ways to do it, but here's one:# create a new child process
pid = fork do
# call espeak. exec never returns, so the child process effectively ends here.
exec('espeak', 'bonjour')
end
# detach the child process; we aren't interested in waiting for it.
Process.detach pid
system(…)
works on Windows as do threads, which is why I assume Jwosty's answer would work there, but I could be mistaken. C:$espeak = Thread.fork {
loop do
if $ttstext != ""
sentenc = 'espeak -vfr+m3 "' + $ttstext + '"'
$ttstext.clear
Kernel.system(sentenc)
end
end}
Dir.chdir File.dirname(__FILE__)
Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill