‘say’未被识别为内部或外部命令、可操作的程序或批处理文件。

huangapple go评论63阅读模式
英文:

'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

huangapple
  • 本文由 发表于 2023年5月28日 18:46:12
  • 转载请务必保留本文链接:https://go.coder-hub.com/76351080.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定