pythonpython-3.xmodulepipmanjaro

aplay: main:831: audio open error: No such file or directory


When I run this code:

import pyttsx3
engine = pyttsx3.init()
engine.say("Hello, World!")
engine.runAndWait()

It shows:

aplay: main:831: audio open error: No such file or directory

I have pyttsx3==2.90 installed on my system(Manjaro 21.1.2 Pahvo).

I have tried reinstalling pip and pyttsx3 too, and I also checked the syntax several times and everything seems fine.

Any suggestions will help a lot :)


Solution

  • I solved the problem by adding those lines to my script:

      os.system('sudo apt install -y espeak')
      os.system('sudo apt-get -y update')
      os.system('sudo apt-get install -y alsa-utils')
      os.system('sudo apt-get install -y software-properties-common')
      os.system('sudo apt-get install -y ffmpeg')
    

    Alternatively you can run those commands in your terminal as well. Had no more issues after that.