Trouble running pyttsx3 text to speech converter
See original GitHub issueI’m trying to build a voice assistant and I’m using nuitka for speed improvement.
0.6.12.3
Python: 3.7.3 (default, Jul 25 2020, 13:03:44)
Executable: /usr/bin/python3
OS: Linux
Arch: armv7l
Here is my code:
from fuzzywuzzy import fuzz
import sys
import pyttsx3
engine = pyttsx3.init()
text = "Hairy activated"
voices = engine.getProperty("voices")
print(voices)
engine.setProperty("rate", 135)
engine.setProperty("voice", voices[10].id)
engine.say(text)
# play the speech
engine.runAndWait()
from os import environ, path
import os
#sys.path.insert(0, '/home/pi/AIY-voice-kit-python/src/examples/voice')
#from __init__ import LiveSpeech, get_model_path
from pocketsphinx import LiveSpeech, get_model_path
model_path = get_model_path()
print("active")
speech = LiveSpeech(
verbose=False,
sampling_rate=16000,
buffer_size=2048,
no_search=False,
full_utt=False,
hmm=os.path.join(model_path, 'en-us'),
lm=os.path.join(model_path, 'en-us.lm.bin'),
dic=os.path.join(model_path, 'cmudict-en-us.dict')
)
for phrase in speech:
p = str(phrase)
print(p)
r1 = (fuzz.ratio(p,"harry"))
print(r1)
ri = int(r1)
if ri > 59:
text = "Yes?"
engine.say(text)
here is the command:
python3 -m nuitka --run --follow-imports /home/pi/Desktop/AIY-projects-python/src/examples/voice/speack.py
and here is the log:
Nuitka:INFO: Starting Python compilation.
Nuitka:INFO: Completed Python level compilation and optimization.
Nuitka:INFO: Generating source code for C backend compiler.
Nuitka:INFO: Running data composer tool for optimal constant value handling.
Nuitka:INFO: Running C level backend compilation via Scons.
Nuitka-Scons:INFO: Backend C compiler: gcc (gcc).
Nuitka-Scons:INFO: Slow C compilation detected, used 60s so far, this might indicate scalability problems.
Nuitka-Scons:INFO: Running /usr/bin/ccache /usr/bin/gcc -o module.pocketsphinx.pocketsphinx.o -c -std=c11 -fvisibility=hidden -fwrapv -fpartial-inlining -ftrack-macro-expansion=0 -Wno-deprecated-declarations -fno-var-tracking -fcompare-debug-second -O3 -pipe -D__NUITKA_NO_ASSERT__ -D_NUITKA_CONSTANTS_FROM_INCBIN -D_NUITKA_FROZEN=0 -D_NUITKA_EXE -I/usr/include/python3.7m -I. -I/usr/local/lib/python3.7/dist-packages/nuitka/build/include -I/usr/local/lib/python3.7/dist-packages/nuitka/build/static_src module.pocketsphinx.pocketsphinx.c took 68.31 seconds
Nuitka-Scons:INFO: Compiled 26 C files using ccache.
Nuitka-Scons:INFO: Cached C files (using ccache) with result 'cache miss': 26
Nuitka:INFO: Keeping build directory 'speack.build'.
Nuitka:INFO: Successfully created 'speack.bin'.
Nuitka:INFO: Launching 'speack.bin'.
Traceback (most recent call last):
File "/home/pi/.local/lib/python3.7/site-packages/pyttsx3/__init__.py", line 20, in init
eng = _activeEngines[driverName]
File "/usr/lib/python3.7/weakref.py", line 137, in __getitem__
o = self.data[key]()
KeyError: None
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/pi/Desktop/AIY-projects-python/src/examples/voice/speack.py", line 4, in <module>
engine = pyttsx3.init()
File "/home/pi/.local/lib/python3.7/site-packages/pyttsx3/__init__.py", line 22, in init
eng = Engine(driverName, debug)
File "/home/pi/.local/lib/python3.7/site-packages/pyttsx3/engine.py", line 30, in __init__
self.proxy = driver.DriverProxy(weakref.proxy(self), driverName, debug)
File "/home/pi/.local/lib/python3.7/site-packages/pyttsx3/driver.py", line 50, in __init__
self._module = importlib.import_module(name)
File "/usr/lib/python3.7/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 965, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'pyttsx3.drivers'
Is there any more information you want? Please help as soon as you can.
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
Python | Text to Speech by using pyttsx3 - GeeksforGeeks
it is a very easy to use tool which converts the entered text into speech. The pyttsx3 module supports two voices first is...
Read more >i am trying to convert text to speech using pyttsx3 in python ...
Your code is no problem. It can run successfully on my Windows 10, my python version is 3.7.3. ImportError: DLL load failed while...
Read more >An Introduction to pyttsx3: A Text-To-Speech Converter for ...
This article is a guide for dummies to learn text-to-speech conversion in Python. ... Save it in a Python file, and run it....
Read more >Convert Text to Speech with Pyttsx3 and Python | by Ryan Chou
Run the engine by typing engine.runAndWait(). Code: Running it will have the default voice say whatever text you put in, be sure to...
Read more >nateshmbhat/pyttsx3: Offline Text To Speech ... - GitHub
Features : ✨ Fully OFFLINE text to speech conversion; Choose among different voices installed in your system; Control speed/rate of speech ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thank you @kayhayen
--include-package=src.modules
for me worked.This is not standalone mode, so it wouldn’t have to follow it for compilation, however, there are issues when things are mixed, compiled or not, then the loader of Python can’t load the compiled stuff, and vice versa, so far it only loads extension modules, but not sourcefiles or bytecode. This is a missing feature indeed.
The extension modules were most pressing, but this surely is annoying too. You can fix this potentially with provisions of --include-package on the trouble makers, so no mixing occurs, unless of course it’s not found at compile time.