python text to speech using pyttsx
Asked Answered
T

4

32

I want to use my raspberry pi to announce some text. i have installed pyttsx but not able to use it.i am using python2.7

my program:

import pyttsx
engine= pyttsx.init()
engine.setProperty('rate',70)
voices=engine.getProperty('voices')
for voice in voices:
    print "Using voice:", repr(voice)
    engine.setProperty('voice',voice.id)
    engine.say("Hello Hello Hello")
engine.runAndWait()

but i am getting this error:

Traceback (most recent call last):
File "/home/pi/announce.py", line 2, in <module>
engine= pyttsx.init()
File "/usr/local/lib/python2.7/dist-packages/pyttsx-1.1-     py2.7.egg/pyttsx/__init__.py", line 39, in init
eng = Engine(driverName, debug)
File "/usr/local/lib/python2.7/dist-packages/pyttsx-1.1- py2.7.egg/pyttsx/engine.py", line 45, in __init__
 self.proxy = driver.DriverProxy(weakref.proxy(self), driverName, debug)
 File "/usr/local/lib/python2.7/dist-packages/pyttsx-1.1-p   y2.7.egg/pyttsx/driver.py", line 64, in __init__
  self._module = __import__(name, globals(), locals(), [driverName])
  File "/usr/local/lib/python2.7/dist-packages/pyttsx-1.1-py2.7.egg/pyttsx/drivers/espeak.py", line 19, in <module>
   import _espeak
   File "/usr/local/lib/python2.7/dist-packages/pyttsx-1.1-py2.7.egg/pyttsx/drivers/_espeak.py", line 24, in <module>
   dll = cdll.LoadLibrary('libespeak.so.1')
   File "/usr/lib/python2.7/ctypes/__init__.py", line 443, in LoadLibrary
    return self._dlltype(name)
   File "/usr/lib/python2.7/ctypes/__init__.py", line 365, in __init__
   self._handle = _dlopen(self._name, mode)
OSError: libespeak.so.1: cannot open shared object file: No such file or directory
Tetroxide answered 10/9, 2015 at 10:34 Comment(2)
You have to install the linux package python-espeak too. (sudo apt-get install python-espeak)Clothes
Thank you sir .now its work fine @ sebastian stiglerTetroxide
M
49

It's because you don't have espeak installed on your system. That's why it is giving error

libespeak.so.1 error: no such file or directory found.

Try to install espeak using:

sudo apt-get update && sudo apt-get install espeak
Madelina answered 25/3, 2016 at 20:10 Comment(0)
H
9

If you're using Ubuntu or another Debian-based distro, Use this

sudo apt install libespeak1
Hypogeous answered 16/11, 2019 at 19:47 Comment(0)
I
0

Try this one:: Run on Ubuntu/Linux Terminal,

1.pip install pyttsx3 ,

2.sudo apt install libespeak1

You must have successfully installed.

Integrity answered 23/8, 2020 at 13:27 Comment(0)
L
-2

I'm connecting to Kali through xrdp using Microsoft Remote Desktop on MACOS 10.11 El Capitain and I was having trouble getting pyttsx3 to pick up the driver for the xrdp audio (xrdp sink) in python 3.11. This was the best answer that googs had and it resolved my issue:

sudo apt install libespeak1
Loyola answered 24/2, 2023 at 18:21 Comment(1)
This has already been posted in two other answers.Caveator

© 2022 - 2024 — McMap. All rights reserved.