gpt4 book ai didi

vbscript - 如何在 vbscript 中暂停语音命令?我必须从相同的暂停位置播放它

转载 作者:行者123 更新时间:2023-12-02 22:07:37 27 4
gpt4 key购买 nike

  1. 如何在 vbscript 中暂停语音命令?我必须从相同的暂停位置播放它。
  2. 代码块:

    Dim Speak, Path
    Path = "string"
    Path = "C:\Users\sony\Desktop\TheReunion.txt"
    const ForReading = 1
    Set objFileToRead = CreateObject("Scripting.FileSystemObject").OpenTextFile(Path,ForReading)
    strFileText = objFileToRead.ReadAll()
    Set Speak=CreateObject("sapi.spvoice")
    Speak.Speak strFileText
    objFileToRead.Close
    Set objFileToRead = Nothing

最佳答案

在使用 LotPings 提到的 pauseresume 方法之前,您需要异步调用 speak 方法在评论中。

代码:

Dim Speak, Path
Path = "string"
Path = "C:\Users\sony\Desktop\TheReunion.txt"
const ForReading = 1
Set objFileToRead = CreateObject("Scripting.FileSystemObject").OpenTextFile(Path,ForReading)
strFileText = objFileToRead.ReadAll()
Set Speak=CreateObject("sapi.spvoice")
Speak.Speak strFileText,1 '1=Asynchronous. Click the link below for other possible values "SpeechVoiceSpeakFlags"

'Due to async call to speak method, we can proceed with the code execution while the voice is being played in the background. Now we can call pause and resume methods
wscript.sleep 5000 'voice played for 5000ms
Speak.pause 'paused
wscript.sleep 4000 'remains paused for 4000ms
Speak.resume 'resumes
objFileToRead.Close
Set objFileToRead = Nothing

SpeechVoiceSpeakFlags

关于vbscript - 如何在 vbscript 中暂停语音命令?我必须从相同的暂停位置播放它,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45902749/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com