2

I have the following setup. a pygame window which reads keyboard inputs using the event.keyDown and displays some text when the right arrow key is pressed. In addition to this, the text displayed has to be spoken by eSpeak. I am doing this with the pyttsx module. When there are longer chunks of text, such as a line or a sentence, eSpeak speech scenes to be breaking before it can speak the complete text. Here is a few things I tried. trial 1: I tried putting the engine.say() and engine.runAndWait() function calls in a different function and returning a bullion value. I later checked if the bullion value was True and then proceeded with displaying the text on the pygame window.

trial 2: After calling the method that had the engine.say() and engine.runAndWait() functions, I introduced a delay of 2 seconds using the timer.sleep() function.

trial 3: I placed the engine.say() and engine.runAndWait() function calls in the main function (where I was calling the method before).

None of these have resulted in eSpeak speaking longer chunks of text completely.

I also tried having the text spoken in a separate python interpreter using the pyttsx library and it works fine.

1 Answers1

1

I have tried pyttsx for my project.

sample :

def speak(arg):
    import pyttsx
    engine = pyttsx.init()
    rate = engine.getProperty('rate')
    engine.setProperty('rate', rate-5)
    engine.say(arg)
    engine.say("   ")
    engine.runAndWait()

speak("The quick brown fox jumped over the lazy dog.")
speak("okay,alright .")
speak("I have a sound !")