15

I am making a pyttsx3 chat bot however this error occurred:

OSError: libespeak.so.1: cannot open shared object file: No such file or directory

This error also occurred:

KeyError: None

Here is my code:

import pyttsx3

def say(sp):
    engine = pyttsx3.init()
    engine.say(sp)
    engine.runandwait()
    
say("Hello my name is Neuron")

Does anyone know how I can fix this?

crvcio
  • 321
  • 2
  • 5
  • 11

7 Answers7

17

To install espeak on ubuntu or any of the debian based OS, enter the following command on the terminal:

sudo apt install espeak

To use pyttsx3 python library, install the following using terminal:

pip3 install pyttsx3 sudo apt install espeak pip3 install pyaudio or use sudo apt install python3-pyaudio

dust
  • 171
  • 1
  • 5
8

pyttsx3 uses the espeak library for speech synthesis.

The error says that python cannot find this library.

I work on Arch (Linux) and I solved this problem by:

sudo pacman -S espeak

For Ubuntu you can do it by:

sudo apt install espeak

For Windows unfortunately I don't know the answer. Maybe you can install the library from the internet.

Gino Mempin
  • 25,369
  • 29
  • 96
  • 135
Webkadiz
  • 117
  • 2
8

I face the same problem on my ubuntu 20.04 at first install espeak or libespeak-dev

$ sudo apt install espeak

or

$ sudo apt install libespeak-dev

and after installing pyttsx3 on my venv

$ pip install pyttsx3

and it works fine with me hope it will help.

Badrelden Ahmed
  • 106
  • 2
  • 5
3
sudo apt install libespeak-dev

This package provides eSpeak development files needed for compilation with the espeak shared library. Your code will works fine after install it. I had the same issu and I resolved it with this command.

2

For arch the problem can be solved by installing espeak-ng-extended-git

yay -S espeak-ng-extended-git
Zarif Muhtasim
  • 334
  • 2
  • 9
0

To install eSpeak on manjaro i had to install it like:

pamac install espeak-ng
R.V
  • 1
  • 2
0

use

pip install PyAudio

this will definitely help you to run you code successfully.

rajeev_inr
  • 1
  • 1
  • 2
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jun 16 '23 at 09:26