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

9

22

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?

Chester answered 13/12, 2020 at 11:3 Comment(1)
apt install espeakSunder
S
22

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

Sculley answered 22/2, 2021 at 12:45 Comment(0)
G
10

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.

Gruelling answered 1/3, 2022 at 22:29 Comment(1)
I was getting /usr/bin/ld: cannot find -lespeak: No such file or directory error although I installed espeak with sudo apt install espeak command on my Ubuntu 22.04. Installing the library package instead (sudo apt install libespeak-dev) solved my problem. Thanks!Zagazig
J
9

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.

Joh answered 15/12, 2020 at 13:44 Comment(0)
V
4
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.

Virile answered 9/10, 2021 at 20:21 Comment(1)
Please provide more information on what this command does, and why it works.Divergency
A
2

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

yay -S espeak-ng-extended-git
Algetic answered 7/7, 2022 at 6:58 Comment(0)
V
0

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

pamac install espeak-ng
Veach answered 18/8, 2022 at 20:40 Comment(0)
G
0

use

pip install PyAudio

this will definitely help you to run you code successfully.

Guienne answered 15/6, 2023 at 11:24 Comment(1)
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.Chalcedony
C
0

Wanted to add some information regarding answers above for arch\manjaro linux:

sudo pamac install espeak-ng

This would help to install correct library. But for python use you might use pyttsx3 which is using libespeak. And mistake happens because for espeak-ng there is no such library.

And to resolve it you need to create a symbol link to a library within espeak-ng install like

sudo ln -s /usr/lib/libespeak-ng.so.1 /usr/lib/libespeak.so.1

It will allow to "switch" calls from libespeak to libespeak-ng library.

Choric answered 27/11, 2023 at 11:58 Comment(0)
P
0

If you are on MacBook (macOS) there is a way to install it with homebrew:

Install with brew formula:

brew install espeak

# check that it works
espeak -k20 -s150 "Hello"

then you can symlink missing libespeak.dlyb to the missing libespeak.so.1.

Pitiable answered 21/4 at 21:53 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.