Open willwade opened 5 months ago
anyone out there had a chance to test this?!
Okay, but I need helping. Steps:
pip install
prompt for local resources?I guess I should uninstall existing py3-tts or even better try and run this from another machine?!
UPDATE: IF ANYONE IS FOLLOWING AT HOME SEE MY UPDATED COMMENT BELOW!!
import pyttsx3
engine = pyttsx3.init('espeak')
voices = engine.getProperty('voices')
for voice in voices:
engine.setProperty('voice', voice.id)
engine.say('The quick brown fox jumped over the lazy dog.')
engine.runAndWait()
Now in usual py3-tts does this work? In my experience at least it didnt. So now lets try my PR
gh repo clone thevickypedia/py3-tts
cd py3-tts
git fetch origin pull/6/head:MASTER
(or using your GitHub desktop app and getting the pull request 6)
then try it out. You shouldnt have to uninstall py3-tts but if you want you can. the key is this
cd py3-tts
pip install -e .
now in the same shell session try our test.py
If test.py works you can try other things like event loops eg
import pyttsx3
def onStart(name):
print 'starting', name
def onWord(name, location, length):
print 'word', name, location, length
def onEnd(name, completed):
print 'finishing', name, completed
engine = pyttsx3.init('espeak')
engine.connect('started-utterance', onStart)
engine.connect('started-word', onWord)
engine.connect('finished-utterance', onEnd)
engine.say('The quick brown fox jumped over the lazy dog.')
engine.runAndWait()
What it should do? Work! Previously it just wouldnt sound out anything or complain about no dll/so file..
Hi, I've just tested it on my Windows 11 Pro; well it does not work: I could do and observe everyting as you wrote but when I tried "now in the same shell session try our test.py.". I got some kind of "frozen bootstrap" message. Restarted my laptop (just in case an environment variable was missing after freshly installed eSpeak) and got the same message. See attached file pyttsx3_init_eSpeak.txt.
In the files I attached, ~\py3-tts
is just the abbreviation of the path to where gh repo clone
did it.
↠ What puzzles me is that even trying pyttsx3 locally, when I do SpeakerStatus.engine = pyttsx3.init()
,
it still rings back to Python's installation folder (or just seems to tell me so) as I still get, see file pyttsx3_init_default.txt
PermissionError: [Errno 13] Permission denied: 'C:\\Program Files\\Python311\\Lib\\site-packages\\comtypes\\gen\\_C866CA3A_32F7_11D2_9602_00C04F8EE628_0_5_4.py'
So that at least makes me think that import pyttsx3
does not always import everything from the PR instead of ringing back to my installation folder(s).
File 2. pyttsx3_init_default.txt
Chances are that I can get this working on an older laptop where I suppose I didn't install any pyttsx3 yet so that on an empty ground it doesn't get confused.
My bad. try this
Install eSpeak-ng https://github.com/espeak-ng/espeak-ng/blob/master/docs/guide.md#installation . if on a Mac just note the homebrew build out there isnt working on Apple Silicon - so you may need to install from source (its painless!) https://github.com/espeak-ng/espeak-ng/blob/master/docs/building.md (Same as last time)
Now use virtualenv
python -m venv venv
source venv/bin/activate # On Windows use `venv\Scripts\activate`
now pip install from my repo (this PR)
pip install git+https://github.com/willwade/py3-tts.git@master#egg=py3-tts
Save the below to a file eg test_pyttsx3.py
import pyttsx3
def onStart(name):
print('starting', name)
def onWord(name, location, length):
print('word', name, location, length)
def onEnd(name, completed):
print('finishing', name, completed)
engine = pyttsx3.init('espeak')
engine.connect('started-utterance', onStart)
engine.connect('started-word', onWord)
engine.connect('finished-utterance', onEnd)
engine.say('The quick brown fox jumped over the lazy dog.')
engine.runAndWait()
run it
python test_pyttsx3.py
What should it do?
Speak - but also print out
word None 33 3 word None 37 4 word None 42 3 finishing None True starting None word None 1 3 word None 5 5 word None 11 5 word None 17 3
To avoid confusion, I just summarize the following steps to test
Fixed on Windows in my opinion!
To avoid confusion, I just summarize the following steps to test
- Install eSpeak X64 on Windows 11
- Follow steps from above comment eSpeak support #6 (comment)
- eSpeak plays, no error occurs!
Fixed on Windows in my opinion!
yay! many thanks. I've been testing this on windows and Linux. There are a LOT of open issues in pyttsx3 that relate to this so I like to think we have crushed a lot in this PR :)
Docker - WIP - instructions
https://gist.github.com/willwade/218ec9e356ae4c77b55ef282f051844d
NB: Im no docker expert.. It will at least show you word timings emitted.. so something is working...
NB: I dont mean to pile on any pressure but I'm looking at forking this repo to fix this issue more long term if this isnt accepted..(its causing headaches to keep linking to my repo in downstream projects needing eSpeak). there are so many forks of this library I dont really want to..
NB: I dont mean to pile on any pressure but I'm looking at forking this repo to fix this issue more long term if this isnt accepted..(its causing headaches to keep linking to my repo in downstream projects needing eSpeak). there are so many forks of this library I dont really want to..
I know, and, as it is better to be honest, it'll be much better if someone else can test it on a recent Linux environment. Why not try and ask via LinkedIn?
@willwade thanks for these contributions i'm pyttsx3 maintainer, can you please raise this pr to pyttsx3 repo ? if it works well , will get it merged and release it.
@willwade thanks for these contributions i'm pyttsx3 maintainer, can you please raise this pr to pyttsx3 repo ? if it works well , will get it merged and release it.
yay. for sure! :)
have published newer version with recent bug fix PRs merged to pyttsx3 in the latest version. Please check it out when you can 😃
~eSpeak does have one remaining issue. WordEvents are emitted but they occur BEFORE the words are spoken aloud.~ (fixed here)
Please check my code. I've had a lot of debug code in my work which I think I have stripped out