-1
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.

Saureet
  • 3
  • 3
  • 2
    Why are you using `os.system()`? – InSync May 28 '23 at 10:52
  • Your rationalle is not correct. You cannot call `say` as a terminal app (unless you have something like that installed in your system... but details regarding that are missing in your question), which is what you are doing in your script. Maybe what you want in your `say`function is more something like `os.system(f'echo {text}')` – deponovo May 28 '23 at 12:29

1 Answers1

2

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

  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community May 28 '23 at 12:30