Easy to use python wrapper for the Kokoro text-to-speech system.
- Easy to use and setup
- Integrates with your existing python projects
- Multiple voice options
- Adjustable speech speed
Install the required package:
pip install kokoro-tts
pip install soundfilefrom tts import TextToSpeech
# Initialize TTS (will use GPU if available)
tts = TextToSpeech()
# Generate speech
tts.generate_audio(
text="Hello, this is a test of the text to speech system.",
voice='heart', # Available voices: 'heart', 'michael', 'emma', 'george'
speed=1.0, # Speed range: 0.5 to 2.0
output_file='output.wav'
)Initialize the TTS system.
use_gpu: Optional boolean to force GPU (True) or CPU (False). If None, will use GPU if available.
Generate audio from text and save to file.
text: Text to convert to speechvoice: Voice ID to use (default: 'heart')speed: Speech speed multiplier, range 0.5 to 2.0 (default: 1.0)output_file: Output WAV file path (default: 'output.wav')- Returns: Boolean indicating success or failure
The following voices are available:
- 'heart'
- 'michael'
- 'emma'
- 'george'
Kokoro supports many more voices and languages.You can add more when necessary.
Please refer to the Kokoro package license for usage terms and conditions.