NVDA + GalateaTalk

昨日の日記の続きです。gtalk.pyは今日はこんな感じになってます。

class SynthDriver(silence.SynthDriver):
	name = "gtalk"
	description = "galatea talk (experimental)"

	def initialize(self):
		os.chdir("c:\\work\\istc\\SSM\\gtalk")
		cmd = "gtalk -C ssm-win.conf"
		(self.cout, self.cin) = popen2.popen4( cmd )
		self.cin = codecs.getwriter('shift_jis')(self.cin)
		self.cin.write("prop Speak.text = NoAutoOutput\n")
		self.cin.write("prop Speak.pho = NoAutoOutput\n")
		self.cin.write("prop Speak.dur = NoAutoOutput\n")
		self.cin.write("prop Speak.stat = NoAutoOutput\n")
		self.cin.write("prop Speak.len = NoAutoOutput\n")
		self.cin.write("prop Speak.utt = NoAutoOutput\n")
		self.cin.write("set AutoPlay = YES\n")
		self.cin.flush()
		self.frame = SynthFrame()
		return True

	def speakText(self,text,wait=False,index=None):
		self.cin.write("set Text = " + text + "\n")
		self.cin.flush()
		if wait:
			s = "[speak wait]"
		else:
			s = "[speak]"
		self.frame.textCtrl.AppendText(s + text + "\n")

	def cancel(self):
		self.cin.write("set Speak = STOP\n")
		self.cin.flush()
		self.frame.textCtrl.AppendText("[cancel]\n")

	def terminate(self):
		self.cin.write("set Run = EXIT\n")
		self.cin.flush()
		if not self.frame:
			return
		self.frame.Close()
		self.frame.Destroy()
		self.frame = None
    
	def getVoiceName(self,num):
		return "gtalk voice"

で、今度は5〜6行くらいは読み上げるようになりました。カーソルで行を移動すると「音切れ」もちゃんと実現されています。ちょっと反応が遅く感じるのは GalateaTalk の処理時間の問題でしょう。

数行読み上げるとやがて止まってしまうのは GalateaTalk のコンソール出力をちゃんと読み出ししていないから不安定なのかも知れません。

そもそも cout の読み出しをどうやればいいのでしょう。別スレッドを回して non-blocking I/O でcoutを読み出して捨てる必要があるのですが、まだ Python に慣れていない私はそこでつまづいています。

ところで GalateaTalk の README には

各スロットは、プロパティとして AutoOutput か NoAutoOutput のどちらかの
値をとり、それぞれ自動出力する、自動出力しないを表す。
プロパティの値を変更するには、
    prop Text.text = NoAutoOutput
    prop Text.text = AutoOutput
のように prop コマンドによって行なう。
初期値としては、全て AutoOutput が設定されている。

と書かれているのですが、サンプルのPerlスクリプト(RUN)は

	print OUT "prop Text.text = NoAutoOutput\n";
	print OUT "prop Text.pho = NoAutoOutput\n";
	print OUT "prop Text.dur = NoAutoOutput\n";

になっています。これ Text.text ではなくて Speak.text じゃないでしょうか?

今日はここまで。