您的位置:首页 > 编程语言 > VB

调用windows的sapi制作单词朗读应用

2015-07-30 16:46 435 查看
不需要额外的单词语音文件,只需要几行代码,整个应用程序才不到60KB,就可以朗读无限多个英文单词,还可以自己定制要朗读的单词表,爽呆了吧?

只需要写以下几个脚本

speaker.vbs

Set s = CreateObject("sapi.spvoice")

Set fso = CreateObject("scripting.filesystemobject")

currentPath=fso.GetFile(Wscript.ScriptFullName).ParentFolder.Path

path=currentPath & "\dictionary.txt"

Set dictionaryFile=fso.OpenTextFile(path,1,TRUE)

do while dictionaryFile.AtEndOfLine <> True
line=dictionaryFile.ReadLine
s.speak line
loop

dictionaryFile.Close


start.bat
@echo off

"%SystemRoot%/System32/WScript.exe" speaker.vbs

exit

然后把单词表存在dictionary.txt文件中
双击start.bat即可运行单词朗读了
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息