initial commit

This commit is contained in:
josch 2014-06-26 10:46:39 +02:00
commit 4111cbeffb

33
wintts.py Normal file
View file

@ -0,0 +1,33 @@
from comtypes.client import CreateObject
from comtypes.gen import SpeechLib
engine = CreateObject("SAPI.SpVoice")
engine.Rate = 1
stream = CreateObject("SAPI.SpFileStream")
import sys
inf = open(sys.argv[1])
for i,line in enumerate(inf):
outfile = "output_%03d.wav"%i
stream.Open(outfile, SpeechLib.SSFMCreateForWrite)
engine.AudioOutputStream = stream
sel=None
engine.Volume = 100
line = line.strip()
if line == "--":
s,t = "Sam","Silence"
engine.Volume = 0
else:
s,t = line.split(":", 1)
for v in engine.GetVoices():
d=v.GetDescription()
if s.lower() in d.lower():
sel=v
break
if sel:
engine.Voice = sel
else:
print("cant find voice")
exit(1)
engine.speak(t)
stream.close()