Making PC's speak with SAPI.SoVice(转载)

上一篇 / 下一篇  2009-10-25 11:18:15 / 个人分类:VBScript脚本

让PC读指定的文本

Set bjTTS=CreateObject("SAPI.SpVoice")
with objtts
.volume=100
.speak "Making PC's Speak with SAPI.SpVoice. Not a useful script, but a little fun never the less."
end with

'bat下可以调用
'mshta vbscript.:createobject("sapi.spvoice").speak("I LOVE YOU.")

URL:http://www.visualbasicscript.com/m63061.aspx

备注:
like all objects to be created in VBS there are more than just the 3 properties i actually use here.

SAPI.SpVoice Properties:

'.Pause = pause speaking
'.resume = resume after pause
'.Rate = speed at which voice speaks
'.Voice = you can use set and a voice value to change the voice (if multiple exist on machine)
'.Volume = volume of voice (not system volume, just voice)
'.WaitUntilDone = wait until done - dont know how else to say that ;)


how to set the 3 useful voice Properties

 'create object and then setup the properties
 Set VObj = CreateObject("SAPI.SpVoice")
   with VObj
       Set .voice = .getvoices.item(0)
       .Volume = 100
       .Rate = 3
   end with
 


Please notice that the '.getvoices.item(0)' has refrenced item 0, the getvoices is in an array (if multiple are present)

to retrive the names of the values you could do a simple call like:

 'create object and then loop for the index and name
 Set VObj = CreateObject("SAPI.SpVoice")
   For Each Voice In VObj.getvoices
       I = I + 1
       msgbox "" & (I - 1) & " - " & Voice.GetDescription
   Next
 

i dont know, its just one of those toy codes any ways

TAG:

 

评分:0

我来说两句

Open Toolbar