4

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 :)

  • That doesn't seem to be due to python directly, but linked with ALSA. Try running `aplay` with a sound file to see if that works. If not, you could try reinstalling the `alsa-utils` package. – Hacked Oct 21 '21 at 11:01
  • @Hacked I reinstalled `alsa-utils` but it still doesn't works :( – Shreyash Kashyap Oct 24 '21 at 06:29
  • then your problem might lie in the drivers and firmware. try (re)installing or updating `alsa-firmware`, `sof-firmware`, `alsa-ucm-conf`, as well as your audio drivers (btw, all the tips I'm giving you come from the Arch Wiki, you should really give it a look) – Hacked Nov 11 '21 at 19:17
  • I have the same issue on WSL :( – Leo Dec 13 '21 at 04:13
  • 1
    I have had the same issue for several years for the ROOT user in XUBUNTU. Regular users work fine. – jwzumwalt Dec 06 '22 at 18:31

1 Answers1

0

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.

VinPy
  • 36
  • 4