đą Kitten TTS Mini 0.1
Open-source realistic text-to-speech with 80M parameters
import gradio as gr import numpy as np import soundfile as sf import tempfile import os from kittentts import KittenTTS # Initialize the TTS model print("Loading Kitten TTS Mini model...") tts_model = KittenTTS("KittenML/kitten-tts-mini-0.1") print("Model loaded successfully!") # Available voices from the README AVAILABLE_VOICES = [ 'expr-voice-2-m', 'expr-voice-2-f', 'expr-voice-3-m', 'expr-voice-3-f', 'expr-voice-4-m', 'expr-voice-4-f', 'expr-voice-5-m', 'expr-voice-5-f' ] def generate_speech(text, voice): """Generate speech from text using Kitten TTS Mini""" if not text.strip(): return None, "Please enter some text to synthesize." # Check character limit if len(text) > 457: return None, f"â Text is too long ({len(text)} characters). Please limit to 457 characters or less." try: # Generate audio print(f"Generating audio for: '{text[:50]}...' with voice: {voice}") audio = tts_model.generate(text, voice=voice) # Create temporary file with tempfile.NamedTemporaryFile(delete=False, suffix='.wav') as tmp_file: sf.write(tmp_file.name, audio, 24000) return tmp_file.name, f"â Successfully generated audio with {voice} ({len(text)} characters)" except Exception as e: error_msg = f"â Error generating audio: {str(e)}" print(error_msg) return None, error_msg def create_interface(): """Create the Gradio interface""" with gr.Blocks( title="đą Kitten TTS Mini", theme=gr.themes.Soft(), css=""" .main-header { text-align: center; margin-bottom: 2rem; } .info-box { background: var(--background-fill-secondary); color: var(--body-text-color); padding: 1rem; border-radius: 10px; border-left: 4px solid #4285f4; margin: 1rem 0; } .info-box h3, .info-box h4 { color: var(--body-text-color) !important; margin-top: 0; } .info-box ul, .info-box li, .info-box p { color: var(--body-text-color) !important; } .footer-box { background: var(--background-fill-secondary); color: var(--body-text-color); padding: 1rem; border-radius: 10px; margin: 2rem 0; text-align: center; } .footer-box p, .footer-box a { color: var(--body-text-color) !important; } .footer-box a:hover { color: #4285f4 !important; } """ ) as demo: # Header gr.HTML("""
Open-source realistic text-to-speech with 80M parameters
Format: expr-voice-{number}-{gender}