SUSE_audio_assistant/test/pyttsx_test.py
Alex Lau (AvengerMoJo) 7ba9d8d3db
Just MVT demo for the concept of AI audio assistant.
Signed-off-by: Alex Lau (AvengerMoJo) <alau@suse.com>
2023-11-10 02:26:16 +08:00

20 lines
474 B
Python

import pyttsx3
def text_to_speech(text):
# Initialize the TTS engine
engine = pyttsx3.init()
# Set properties (optional)
engine.setProperty('rate', 130) # Speed of speech
engine.setProperty('volume', 0.6) # Volume level (0.0 to 1.0)
# Convert text to speech
engine.say(text)
# Wait for the speech to finish
engine.runAndWait()
# Example usage
text = "Hello, this is a simple text-to-speech example in Python."
text_to_speech(text)