你可以给这个VBScript的例子一试:
Option Explicit
Dim Contents,File,message
File = "c:\tts_text.txt"
Contents = "It didn’t work after mass shootings at a nightclub in Orlando,"&_
"college campuses in Virginia and Oregon, a church in Charleston,"&_
"or at a movie theater and high school in Colorado."&_
"Or after two lawmakers survived assassination attempts." & vbcrlf &_
"But after a gunman killed 58 people and wounded more than 500 at a Las Vegas concert," & vbcrlf &_
"Democrats are going to try again to revamp the nation’s gun laws."
' We write this contents to the file
WriteTextFile Contents, file, 0
' We read the file contents and we store it into a variable message
message = ReadFileText(File)
' Now we can speak this message with SAPI object
Speak_from_File message
'**********************************************************
Sub Speak_from_File(message)
Dim Voice
Set Voice = CreateObject("SAPI.SpVoice")
Voice.Volume = 100
Voice.Rate = 0
Voice.Speak message
End Sub
'**********************************************************
Sub WriteTextFile(sContent, sPath, lFormat)
'lFormat -2 - System default, -1 - Unicode, 0 - ASCII
With CreateObject("Scripting.FileSystemObject").OpenTextFile(sPath,2,True,lFormat)
.WriteLine sContent
.Close
End With
End Sub
'**********************************************************
Function ReadFileText(sFile)
Dim objFSO,oTS,sText
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set oTS = objFSO.OpenTextFile(sFile,1)
sText = oTS.ReadAll
oTS.close
set oTS = nothing
Set objFSO = nothing
ReadFileText = sText
End Function
'**********************************************************
https://stackoverflow.com/questions/ 854975/how-to-read-from-a-text-file-using-vbscript – aphoria
我刚刚注意到[你已经删除了你最近的问题](https://stackoverflow.com/questions/47166956/have-两个javascript-slider-to-work-at-same-time) - 我不认为删除它是必要的。我想出了为什么你最终添加了似乎是机器人垃圾邮件的东西 - 你已经触发了一个需要更多细节的编辑信息,因此决定将警告信息发布到问题中。这很混乱!如果再次发生这种情况,请考虑您可以添加的其他细节 - 在这种特殊情况下,需要详细说明您尝试的内容。 – halfer