英文:
'say' 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")
错误信息为
"'say' 不是内部或外部命令,可执行的程序或批处理文件。"
英文:
import os
def say(text):
os.system(f"say {text}")
if __name__ == '__main__':
print('PyCharm')
say("Hello I am Jarvis A.I")
Error is
'say' is not recognized as an internal or external command,
operable program or batch file.
答案1
得分: 2
'say'命令仅适用于MacOS。我在我的Mac上尝试了您的代码,它完美运行。如果您想在Windows上获得类似的功能,您需要安装第三方命令行工具并将其添加到系统PATH。尝试使用此工具:https://github.com/p-groarke/wsay。然后,您可以将其添加到PATH并使用os.system与'wsay'命令替代。
英文:
The 'say' command is only on MacOS. I tried your code on my Mac and it works just fine. If you want similar functionality on Windows, you'll need to install a 3rd party command line tool and add it to your system PATH. Try this tool: https://github.com/p-groarke/wsay. You can then add it to your PATH and use os.system with the 'wsay' command instead
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论