'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")
这是因为 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")