windows - When using SAPI.SpVoice to output to a WAV file, result sounds different than when outputting directly to speakers -
i'm trying write simple script run txt files through windows 7 text-to-speech engine (which has decent anna voice) , produce wav files. however, wav files don't sound nice when have output directly speakers. i've tried on 2 different windows 7 systems already. way remedy this?
script:
set x = createobject("sapi.spvoice") ' uncomment following lines output file 'set ofs = createobject("sapi.spfilestream") 'ofs.open "msg.wav", 3, vbfalse 'set x.audiooutputstream = ofs x.speak "in fall of 2003, ..."
i have admit, wondering same thing until few days ago. here solution, number '18' on first line might voice specific. i've been trying high quality version wav file long time, ran through every number (0-64), , listened of samples until found right one.
paste code below notepad, save 'sapisomething.vbs', run, , it's high quality output you're looking for. me, sound quality in file output same when speech sent straight speakers.
const sapifiletype=18 ' magic number, possibly voice specific (0 64) strtext=trim(inputbox("what want me say?","listen sapi.spfilestream.format.type quality","")) if not len(strtext)>0 wscript.quit createobject("scripting.filesystemobject") strfile=.buildpath(.getparentfoldername(wscript.scriptfullname),"sapi.spfilestream.format.type_"&sapifiletype&".wav") if .fileexists(strfile) .deletefile strfile end with createobject("sapi.spvoice") set ss=createobject("sapi.spfilestream") ss.format.type=sapifiletype ss.open strfile,3,false set .audiooutputstream=ss .speak strtext,8 .waituntildone(-1) ss.close set ss=nothing end with createobject("wmplayer.ocx"):.settings.autostart=true:.settings.volume=100:.url=strfile:do until .playstate=1:wscript.sleep 200:loop:end
Comments
Post a Comment