'sayHello' 不是内部或外部命令,也不是可运行的程序或批处理文件[关闭]

问题描述 投票:0回答:1

'sayHello' is not recognized as an internal or external command, operable program or batch file.

import speech_recognition as sr
import os
def say(text):
    os.system(f"say{text}")
if __name__ == '__main__':
    print('PyCharm')
    say("Hello I am Jarvis A.I")
python text-to-speech
1个回答
0
投票

这是因为 os.system 调用了一个新的 shell。 如果你想使用 shell 打印你提供的任何文本,你需要写

import os
def say(text):
    os.system(f"echo {text}")
if __name__ == '__main__':
    print('PyCharm')
    say("Hello I am Jarvis A.I")

如果你想调用一个名为 say 的程序,

import os
def say(text):
    os.system(f"say {text}")
if __name__ == '__main__':
    print('PyCharm')
    say("Hello I am Jarvis A.I")
© www.soinside.com 2019 - 2024. All rights reserved.