0

So right now I'm trying to create a sound assistant (ok google, Alexa blah blah) in python. Works fine, except the sound output from that assistant. In the youtube Tutorial the dude uses os.sytsem("mpg123 audio.mp3"), the audio.mp3 is an mp3 in the same folder as the python file, and it's being created and output with these lines

tts = gTTS(text=audio, lang="de")
tts.save("audio.mp3")
os.system("mpg123 audio.mp3")

But when I run that it gives me the error that mpg123 either has been written wrong, or it couldn't be found. I installed it with pip though. So what can I do about that? Do I want my SOUND assistant to only response in text...are there other audio output ways besides mpg123?

martineau
  • 119,623
  • 25
  • 170
  • 301
TrackLab
  • 32
  • 1
  • 7
  • 1
    All the os.system command is doing is running `mpg123 audio.mp3` in a command window. And it seems like your computer can either not find this mpg123 program or the passed in path to the .mp3 file cannot be found. You might want to try running this mpg123 program on your own with a .mp3 file to test making sure that works first. – Karl Sep 01 '18 at 20:29
  • [`mpg123`](https://en.wikipedia.org/wiki/Mpg123) is a separate standalone application that apparently is not installed on your computer—so you need to find, download, and install it before being able to use it with `os.system()`. You can download it from the [mpg123.org](https://mpg123.org) website. – martineau Sep 01 '18 at 20:47
  • @martineau i already installed mpg123 through pip. pip install mpg123 but its not usable apparently. I also imported it, which is probably not needed since the person in the tutorial didnt do it either – TrackLab Sep 01 '18 at 21:21
  • [`pip`](https://pypi.org/project/pip/) is tool for installing Python packages, not os-level applications—so I don't understand what you're talking about. If `mpg123` is installed properly, you should be able to run it manually from a command-line prompt as well as a via Python `os.system()` call. – martineau Sep 01 '18 at 22:01
  • install mpg123 for linux. sudo apt-get install -y mpg123 – Tolga Sahin Aug 23 '20 at 22:43

1 Answers1

-1

Use brew install mpg123 on the terminal and your computer will start voice output right away.

RobC
  • 22,977
  • 20
  • 73
  • 80