How to create clear voice using pyttsx3?

129 views Asked by At

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)
    engine.runAndWait()

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

There are 0 answers