How to create clear voice using pyttsx3 in Ubuntu22.04?

I just used pyttsx3 for generating voice from the text with below code in Ubuntu 22.04.
The voice was cracked and it was not clear when playing audio file.
But I got the clean audio file when running the same code in Windows 10.
How to create clear voice using pyttsx3 in Ubuntu 22.04?

import pyttsx3

engine = pyttsx3.init("espeak")
voices = engine.getProperty('voices')
engine.setProperty('rate', 160)
engine.setProperty("voice", voices[11].id)

# Save audio file
def speak(text):
    engine.say(text)
    engine.save_to_file(text, "output.wav")
    engine.runAndWait()

speak("Hello world and this is a test.")

Try running espeak from the terminal and see if you have the same issue without python being envolved.

I just tested. It has same issue in audio

Ok now you know it is not a python problem.

You need to get help on fixing espeak on ubuntu.

1 Like

Thank you.
I tried to fix espeak. But yet it outputs the unclear audio.
Could you assist me what I have to do?

Please ask for help on a ubuntu forum. I am not a ubuntu user.

Got it. I will do.
Thank you