Files
truetype 770843f9c0 feat: Supertonic 3 TTS demo locale
- Demo Gradio con interfaccia web (B)
- Server HTTP con API nativa e OpenAI-compatibile (C)
- 31 lingue, italiano incluso
- 99M parametri, CPU-only, ONNX Runtime
2026-05-24 17:38:36 +02:00

88 lines
2.3 KiB
Python

import os
import uuid
import gradio as gr
from supertonic import TTS
OUTPUT_DIR = "outputs"
os.makedirs(OUTPUT_DIR, exist_ok=True)
# The first run downloads the Supertonic model assets automatically.
tts = TTS(auto_download=True)
SUPPORTED_LANGUAGES = {
"Italiano": "it",
"Inglese": "en",
"Spagnolo": "es",
"Francese": "fr",
"Tedesco": "de",
"Portoghese": "pt",
}
VOICES = ["M1", "M2", "M3", "M4", "M5", "F1", "F2", "F3", "F4", "F5"]
def generate_audio(text: str, language_label: str, voice: str):
"""Generate a local WAV file with Supertonic TTS."""
if not text or not text.strip():
return None, "Inserisci un testo prima di generare l'audio."
lang = SUPPORTED_LANGUAGES.get(language_label, "it")
style = tts.get_voice_style(voice)
wav, _duration = tts.synthesize(
text.strip(),
voice_style=style,
lang=lang,
)
output_path = os.path.join(OUTPUT_DIR, f"supertonic_{uuid.uuid4().hex[:8]}.wav")
tts.save_audio(wav, output_path)
return output_path, f"Audio generato correttamente: {output_path}"
with gr.Blocks(title="Supertonic Local Demo") as demo:
gr.Markdown(
"""
# Supertonic Local Demo
Mini pannello locale per generare audio con Supertonic TTS.
Scrivi un testo, scegli lingua e voce, poi genera un file WAV direttamente sul tuo PC.
"""
)
with gr.Row():
with gr.Column():
text_input = gr.Textbox(
label="Testo",
lines=8,
value="Ciao, questo è un test vocale in italiano generato localmente con Supertonic.",
)
language_input = gr.Dropdown(
choices=list(SUPPORTED_LANGUAGES.keys()),
value="Italiano",
label="Lingua",
)
voice_input = gr.Dropdown(
choices=VOICES,
value="M1",
label="Voce",
)
generate_button = gr.Button("Genera audio")
with gr.Column():
audio_output = gr.Audio(label="Audio generato", type="filepath")
status_output = gr.Textbox(label="Stato")
generate_button.click(
fn=generate_audio,
inputs=[text_input, language_input, voice_input],
outputs=[audio_output, status_output],
)
if __name__ == "__main__":
demo.launch(server_name="0.0.0.0")