是否有可能让 python 在另一个程序中写入文本
is it possible to get python to write text in another program
嗨,我用 vbs 脚本制作了一个文本到语音的应用程序,我在其中输入文本,它会说出我输入的内容。
我想将它连接到我的 python 应用程序,用户可以在其中输入 tts 'text'
它与撇号中的文字
这是一个例子,如果我输入
tts 'text'
这可能吗?如果可以的话,你是怎么做到的?
我知道了,我和 Rishav Kundu 在聊天室里聊天,他给了我答案
vbs 脚本有这段代码
Dim msg, sapi
msg=InputBox("Enter your text for text to speech")
Set sapi=CreateObject("sapi.spvoice")
sapi.Speak msg
改成了这个
Dim sapi
Set sapi=CreateObject("sapi.spvoice")
Set args = Wscript.Arguments
For Each arg In args
sapi.Speak arg
Next
然后在我输入的 python 脚本中
from os import system
st = input().strip()
if st.index('tts') == 0:
say = st[st.index("'"):]
say = say.replace("'","")
cmd = 'CSCRIPT <enter path to script here, forward slashes> '+ say
system(cmd)
嗨,我用 vbs 脚本制作了一个文本到语音的应用程序,我在其中输入文本,它会说出我输入的内容。
我想将它连接到我的 python 应用程序,用户可以在其中输入 tts 'text' 它与撇号中的文字 这是一个例子,如果我输入
tts 'text'
这可能吗?如果可以的话,你是怎么做到的?
我知道了,我和 Rishav Kundu 在聊天室里聊天,他给了我答案
vbs 脚本有这段代码
Dim msg, sapi
msg=InputBox("Enter your text for text to speech")
Set sapi=CreateObject("sapi.spvoice")
sapi.Speak msg
改成了这个
Dim sapi
Set sapi=CreateObject("sapi.spvoice")
Set args = Wscript.Arguments
For Each arg In args
sapi.Speak arg
Next
然后在我输入的 python 脚本中
from os import system
st = input().strip()
if st.index('tts') == 0:
say = st[st.index("'"):]
say = say.replace("'","")
cmd = 'CSCRIPT <enter path to script here, forward slashes> '+ say
system(cmd)