I have a problem with pyttx3. what should i do? [duplicate] - python

This question already has answers here:
python text to speech using pyttsx
(3 answers)
Closed 1 year ago.
Ubuntu is installed on my laptop.
import pyttsx3
engine=pyttsx3.init()
engine.say('Sa1lly sells seashells by the seashore.')
/usr/bin/python3 /home/shohruz/Desktop/Development/solo.py
Traceback (most recent call last):
File "/home/shohruz/.local/lib/python3.8/site-packages/pyttsx3/__init__.py", line 20, in init
eng = _activeEngines[driverName]
File "/usr/lib/python3.8/weakref.py", line 131, in __getitem__
o = self.data[key]()
KeyError: None
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/shohruz/Desktop/Development/solo.py", line 2, in <module>
engine=pyttsx3.init()
File "/home/shohruz/.local/lib/python3.8/site-packages/pyttsx3/__init__.py", line 22, in init
eng = Engine(driverName, debug)
File "/home/shohruz/.local/lib/python3.8/site-packages/pyttsx3/engine.py", line 30, in __init__
self.proxy = driver.DriverProxy(weakref.proxy(self), driverName, debug)
File "/home/shohruz/.local/lib/python3.8/site-packages/pyttsx3/driver.py", line 50, in __init__
self._module = importlib.import_module(name)
File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 783, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/home/shohruz/.local/lib/python3.8/site-packages/pyttsx3/drivers/espeak.py", line 9, in <module>
from . import _espeak, toUtf8, fromUtf8
File "/home/shohruz/.local/lib/python3.8/site-packages/pyttsx3/drivers/_espeak.py", line 18, in <module>
dll = cdll.LoadLibrary('libespeak.so.1')
File "/usr/lib/python3.8/ctypes/__init__.py", line 451, in LoadLibrary
return self._dlltype(name)
File "/usr/lib/python3.8/ctypes/__init__.py", line 373, in __init__
self._handle = _dlopen(self._name, mode)
OSError: libespeak.so.1: cannot open shared object file: No such file or directory
1.That is the problem. Please help me...
I have installed pyttx3 with sudo pip install pyttsx3 command.
I have installed both 2 versions of pyttsx. pyttsx and pyttsx3. But when i changed pyttsx3 to pyttsx the "no module named 'engine'" error will appear.

import pyttsx3
engine = pyttsx3.init()
engine.say("Sa1lly sells seashells by the seashore")
engine.runAndWait()
This is under windows but should not make any difference
or try this it works on my site
Version used:
Python 3.9.5 (tags/v3.9.5:0a7dcbd, May 3 2021, 17:27:52) [MSC v.1928 64 bit (AMD64)] on win32

Related

I am making a virtual assisstant and i get an error - ImportError: No system module 'pywintypes' (pywintypes39.dll)

I am making a Virtual Assistant and I am using the module pyttsx3 with sapi5.
My code -
engine = pyttsx3.init('sapi5')
voices = engine.getProperty('voices')
engine.setProperty('voice', voices[1].id)
It gives an error -
Traceback (most recent call last):
File "C:\Users\Admin\AppData\Roaming\Python\Python39\site-packages\pyttsx3\__init__.py", line 20, in init
eng = _activeEngines[driverName]
File "C:\Program Files\Python39\lib\weakref.py", line 134, in __getitem__
o = self.data[key]()
KeyError: 'sapi5'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "d:\Python projects\JARVIS\Jarvis.py", line 18, in <module>
engine = pyttsx3.init('sapi5')
File "C:\Users\Admin\AppData\Roaming\Python\Python39\site-packages\pyttsx3\__init__.py", line 22, in init
eng = Engine(driverName, debug)
File "C:\Users\Admin\AppData\Roaming\Python\Python39\site-packages\pyttsx3\engine.py", line 30, in __init__
self.proxy = driver.DriverProxy(weakref.proxy(self), driverName, debug)
File "C:\Users\Admin\AppData\Roaming\Python\Python39\site-packages\pyttsx3\driver.py", line 50, in __init__
self._module = importlib.import_module(name)
File "C:\Program Files\Python39\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 790, in exec_module
File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
File "C:\Users\Admin\AppData\Roaming\Python\Python39\site-packages\pyttsx3\drivers\sapi5.py", line 10, in <module>
import pythoncom
File "C:\Users\Admin\AppData\Roaming\Python\Python39\site-packages\pythoncom.py", line 2, in <module>
import pywintypes
File "C:\Users\Admin\AppData\Roaming\Python\Python39\site-packages\win32\lib\pywintypes.py", line 105, in <module>
__import_pywin32_system_module__("pywintypes", globals())
File "C:\Users\Admin\AppData\Roaming\Python\Python39\site-packages\win32\lib\pywintypes.py", line 87, in __import_pywin32_system_module__
raise ImportError("No system module '%s' (%s)" % (modname, filename))
ImportError: No system module 'pywintypes' (pywintypes39.dll)
Can someone help me please? Also I am using Windows 10, Python 3 and the module pyttsx3.
Thanks In Advance!

I'm Having Problem in pydroid 3 on my android device with espeak library

code:
So This is my pydroid3 python script and when i try to run it
import pyttsx3
speaker = pyttsx3.init()
speaker.say("Mama I Can Talk ")
speaker.runAndWait()
error:
This is the error that occurs every time even though i downloaded all the espeak libraries (python_espeak) and all
File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.8/site-packages/pyttsx3/__init__.py", line 20, in init
eng = _activeEngines[driverName]
File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.8/weakref.py", line 131, in __getitem__
o = self.data[key]()
KeyError: None
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/data/user/0/ru.iiec.pydroid3/files/accomp_files/iiec_run/iiec_run.py", line 31, in <module>
start(fakepyfile,mainpyfile)
File "/data/user/0/ru.iiec.pydroid3/files/accomp_files/iiec_run/iiec_run.py", line 30, in start
exec(open(mainpyfile).read(), __main__.__dict__)
File "<string>", line 2, in <module>
File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.8/site-packages/pyttsx3/__init__.py", line 22, in init
eng = Engine(driverName, debug)
File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.8/site-packages/pyttsx3/engine.py", line 30, in __init__ self.proxy = driver.DriverProxy(weakref.proxy(self), driverName, debug)
File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.8/site-packages/pyttsx3/driver.py", line 50, in __init__ self._module = importlib.import_module(name)
File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.8/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 783, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.8/site-packages/pyttsx3/drivers/espeak.py", line 9, in <module>
from . import _espeak, toUtf8, fromUtf8
File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.8/site-packages/pyttsx3/drivers/_espeak.py", line 18, in <module>
dll = cdll.LoadLibrary('libespeak.so.1')
File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.8/ctypes/__init__.py", line 451, in LoadLibrary
return self._dlltype(name)
File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.8/ctypes/__init__.py", line 373, in __init__
self._handle = _dlopen(self._name, mode)
OSError: dlopen failed: library "libespeak.so.1" not found```
Sorry pyttsx3 will not work on android. Install QPython and use the inbuilt modules in it. It neither support pyttsx3 but they use the phone's tts. So you can use that for tts

importing gnuradio while using pycharm on ubuntu

I would like to make calls from python to blocks in gnuradio 3.8 from PyCharm CE 2019.2 on Ubuntu 18.04. The project interpreter set in Pycharm is the virtual environment created when the pycharm project was created. I have seen suggestions (How do I import modules in pycharm?) to add a line like:
/home/my_name/devel/gnuradio3_8/lib/python3.6/dist-packages
to the interpreter path (under File->Settings->Project:my_proj->Project Interpreter->Gear Symbol->Show All->Show Paths for Selected Interpreter).
From the python console, this results in the following error when I attempt to import gnuradio blocks:
PyDev console: starting.
Python 3.6.8 (default, Oct 7 2019, 12:59:55)
[GCC 8.3.0] on linux
import gnuradio
from gnuradio import blocks
Traceback (most recent call last):
File "/home/my_name/devel/gnuradio3_8/lib/python3.6/dist-packages/gnuradio/blocks/blocks_swig0.py", line 14, in swig_import_helper
return importlib.import_module(mname)
File "/usr/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 658, in _load_unlocked
File "<frozen importlib._bootstrap>", line 571, in module_from_spec
File "<frozen importlib._bootstrap_external>", line 922, in create_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
ImportError: libgnuradio-blocks.so.3.8.0: cannot open shared object file: No such file or directory
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/my_name/devel/gnuradio3_8/lib/python3.6/dist-packages/gnuradio/blocks/__init__.py", line 32, in <module>
from .blocks_swig import *
File "/snap/pycharm-community/167/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 21, in do_import
module = self._system_import(name, *args, **kwargs)
File "/home/my_name/devel/gnuradio3_8/lib/python3.6/dist-packages/gnuradio/blocks/blocks_swig.py", line 24, in <module>
from .blocks_swig0 import *
File "/snap/pycharm-community/167/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 21, in do_import
module = self._system_import(name, *args, **kwargs)
File "/home/my_name/devel/gnuradio3_8/lib/python3.6/dist-packages/gnuradio/blocks/blocks_swig0.py", line 17, in <module>
_blocks_swig0 = swig_import_helper()
File "/home/my_name/devel/gnuradio3_8/lib/python3.6/dist-packages/gnuradio/blocks/blocks_swig0.py", line 16, in swig_import_helper
return importlib.import_module('_blocks_swig0')
File "/usr/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
ModuleNotFoundError: No module named '_blocks_swig0'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/my_name/devel/gnuradio3_8/lib/python3.6/dist-packages/gnuradio/blocks/blocks_swig0.py", line 14, in swig_import_helper
return importlib.import_module(mname)
File "/usr/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 658, in _load_unlocked
File "<frozen importlib._bootstrap>", line 571, in module_from_spec
File "<frozen importlib._bootstrap_external>", line 922, in create_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
ImportError: libgnuradio-blocks.so.3.8.0: cannot open shared object file: No such file or directory
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "/snap/pycharm-community/167/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 21, in do_import
module = self._system_import(name, *args, **kwargs)
File "/home/my_name/devel/gnuradio3_8/lib/python3.6/dist-packages/gnuradio/blocks/__init__.py", line 36, in <module>
from .blocks_swig import *
File "/snap/pycharm-community/167/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 21, in do_import
module = self._system_import(name, *args, **kwargs)
File "/home/my_name/devel/gnuradio3_8/lib/python3.6/dist-packages/gnuradio/blocks/blocks_swig.py", line 24, in <module>
from .blocks_swig0 import *
File "/snap/pycharm-community/167/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 21, in do_import
module = self._system_import(name, *args, **kwargs)
File "/home/my_name/devel/gnuradio3_8/lib/python3.6/dist-packages/gnuradio/blocks/blocks_swig0.py", line 17, in <module>
_blocks_swig0 = swig_import_helper()
File "/home/my_name/devel/gnuradio3_8/lib/python3.6/dist-packages/gnuradio/blocks/blocks_swig0.py", line 16, in swig_import_helper
return importlib.import_module('_blocks_swig0')
File "/usr/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
ModuleNotFoundError: No module named '_blocks_swig0'
I believe that I have libgnuradio installed:
~/devel/gnuradio3_8/lib$ ls
cmake libgnuradio-qtgui.so.3.8.0
libgnuradio-analog.so libgnuradio-qtgui.so.3.8.0.0
libgnuradio-analog.so.3.8.0 libgnuradio-runtime.so
libgnuradio-analog.so.3.8.0.0 libgnuradio-runtime.so.3.8.0
libgnuradio-audio.so libgnuradio-runtime.so.3.8.0.0
libgnuradio-audio.so.3.8.0 libgnuradio-trellis.so
libgnuradio-audio.so.3.8.0.0 libgnuradio-trellis.so.3.8.0
libgnuradio-blocks.so libgnuradio-trellis.so.3.8.0.0
libgnuradio-blocks.so.3.8.0 libgnuradio-uhd.so
libgnuradio-blocks.so.3.8.0.0 libgnuradio-uhd.so.3.8.0
libgnuradio-channels.so libgnuradio-uhd.so.3.8.0.0
libgnuradio-channels.so.3.8.0 libgnuradio-utilities.so
libgnuradio-channels.so.3.8.0.0 libgnuradio-utilities.so.1.0.0git
libgnuradio-digital.so libgnuradio-utilities.so.v1.0-compat-xxx-xunknown
libgnuradio-digital.so.3.8.0 libgnuradio-vocoder.so
libgnuradio-digital.so.3.8.0.0 libgnuradio-vocoder.so.3.8.0
libgnuradio-dtv.so libgnuradio-vocoder.so.3.8.0.0
libgnuradio-dtv.so.3.8.0 libgnuradio-wavelet.so
libgnuradio-dtv.so.3.8.0.0 libgnuradio-wavelet.so.3.8.0
libgnuradio-fec.so libgnuradio-wavelet.so.3.8.0.0
libgnuradio-fec.so.3.8.0 libgnuradio-zeromq.so
libgnuradio-fec.so.3.8.0.0 libgnuradio-zeromq.so.3.8.0
libgnuradio-fft.so libgnuradio-zeromq.so.3.8.0.0
libgnuradio-fft.so.3.8.0 libuhd.so
libgnuradio-fft.so.3.8.0.0 libuhd.so.3.14.1
libgnuradio-filter.so libvolk.so
libgnuradio-filter.so.3.8.0 libvolk.so.2.0
libgnuradio-filter.so.3.8.0.0 pkgconfig
libgnuradio-pmt.so python2.7
libgnuradio-pmt.so.3.8.0 python3
libgnuradio-pmt.so.3.8.0.0 python3.6
libgnuradio-qtgui.so uhd
What is the right way to import gnuradio?
ImportError: libgnuradio-blocks.so.3.8.0: cannot open shared object file: No such file or directory
Yes. I have gnuradio3.7 in the usual place and 3.8 is here under my home directory
You need to add the path were you've installed gnuradio libs (~/devel/gnuradio3_8/lib) to the LD_LIBRARY_PATH environment variable.
I'm not familiar with pycharm but from your terminal you could execute
$ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:~/devel/gnuradio3_8/lib
and then start pycharm from the same terminal or add the same to your ~/.bash_profile
In case you've installed gnuradio using pybombs there will be A setup_env.sh script in ~/devel/gnuradio3_8 that you could source from the terminal
$ source setup_env.sh

shell_plus installed with Django giving error - ImportError: cannot import name 'Type

I am getting the following error when trying to launch shell_plus after installing django_extensions. Here are the steps i followed
1-Installed django_extensions using
pip install django_extensions
2-Added django_extensions to installed apps
Then I get the following error
$ ./manage.py shell_plus
Traceback (most recent call last):
File "./manage.py", line 15, in <module>
execute_from_command_line(sys.argv)
File "/Users/admin/Development/project/virtual/lib/python3.5/site-packages/django/core/management/__init__.py", line 371, in execute_from_command_line
utility.execute()
File "/Users/admin/Development/project/virtual/lib/python3.5/site-packages/django/core/management/__init__.py", line 365, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Users/admin/Development/project/virtual/lib/python3.5/site-packages/django/core/management/__init__.py", line 216, in fetch_command
klass = load_command_class(app_name, subcommand)
File "/Users/admin/Development/project/virtual/lib/python3.5/site-packages/django/core/management/__init__.py", line 36, in load_command_class
module = import_module('%s.management.commands.%s' % (app_name, name))
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 986, in _gcd_import
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 662, in exec_module
File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
File "/Users/admin/Development/project/virtual/lib/python3.5/site-packages/django_extensions/management/commands/shell_plus.py", line 14, in <module>
from django_extensions.management.shells import import_objects
File "/Users/admin/Development/project/virtual/lib/python3.5/site-packages/django_extensions/management/shells.py", line 5, in <module>
from typing import ( # NOQA
ImportError: cannot import name 'Type'
Any suggestions on what might be going wrong ?
Python 3.5 comes with its own version of typing module. What is most likely happening is that you have the other typing module specified in your requirements (the one that doesn't include Type class) and its getting picked up by django_extensions instead of the native Python one. Check your installed modules, or try running:
pip uninstall typing

I am getting error when using pyttsx3.2.6 library

I am new to python, I am trying to use python offline text to speech library pyttsx3. While i am running following script
import pyttsx3
engine = pyttsx3.init()
engine.say("I am talking now ");
engine.setProperty('rate',100)
engine.runAndWait();
I am getting following error:
Traceback (most recent call last):
File "C:\Users\care\AppData\Local\Programs\Python\Python35-32\lib\site-packages\pyttsx3\__init__.py", line 44, in init
eng = _activeEngines[driverName]
File "C:\Users\care\AppData\Local\Programs\Python\Python35-32\lib\weakref.py", line 131, in __getitem__
o = self.data[key]()
KeyError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\care\AppData\Local\Programs\Python\Python35-32\Scripts\hello.py", line 2, in <module>
engine = pyttsx3.init()
File "C:\Users\care\AppData\Local\Programs\Python\Python35-32\lib\site-packages\pyttsx3\__init__.py", line 46, in init
eng = Engine(driverName, debug)
File "C:\Users\care\AppData\Local\Programs\Python\Python35-32\lib\site-packages\pyttsx3\engine.py", line 52, in __init__
self.proxy = driver.DriverProxy(weakref.proxy(self), driverName, debug)
File "C:\Users\care\AppData\Local\Programs\Python\Python35-32\lib\site-packages\pyttsx3\driver.py", line 75, in __init__
self._module = importlib.import_module(name)
File "C:\Users\care\AppData\Local\Programs\Python\Python35-32\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 986, in _gcd_import
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 662, in exec_module
File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
File "C:\Users\care\AppData\Local\Programs\Python\Python35-32\lib\site-packages\pyttsx3\drivers\sapi5.py", line 3, in <module>
import win32com.client
File "C:\Users\care\AppData\Local\Programs\Python\Python35-32\lib\site-packages\win32com\__init__.py", line 5, in <module>
import win32api, sys, os
ImportError: No module named 'win32api'
Its just solved my problem by restarting python shell and placing pythoncom35.dll and pywintypes35.dll from C:\Users\care\AppData\Local\Programs\Python\Python35-32\Lib\site-packages\pypiwin32 to C:\Users\care\AppData\Local\Programs\Python\Python35-32\Lib\site-packages\win32

Categories