GUIDE

Build a text-to-speech web app with Gradio

A small web page where you type text and hear it in a natural voice is a classic first AI project, a handy internal tool and a good demo for a product. Gradio turns a Python function into such a page in a few lines, and the free SuperClonica engine supplies the voice on an ordinary processor.

This guide shows the minimal app, how to add voices and settings, and how to host it for free; our own demo on Hugging Face Spaces is built exactly this way.

What you build

Everything runs inside your Python process: texts are not sent to any speech service.

  • A text box, a voice picker and a player with a download button.
  • Ten stock voices and any catalog voice you own.
  • Runs on a laptop, a server or a free cloud CPU.
  • No graphics card and no paid API.

Hear the voices first

Before you code, listen to voices on their pages: type a line of 30 to 100 characters, choose the language and press Voice it. In a few seconds you know which voices to offer in your app.

The minimal app

Gradio’s Audio output takes a pair of sample rate and audio array, so return (rate, audio), in that order.

  • Install both packages: python -m pip install superclonica-cpu gradio.
  • Write the app: import gradio as gr; from superclonica import Superclonica; tts = Superclonica(); def speak(text, voice): audio, rate = tts.synthesize(text, voice=voice, lang="en"); return (rate, audio) — then gr.Interface(fn=speak, inputs=[gr.Textbox(label="Text"), gr.Dropdown(["F1", "F2", "M1", "M2"], label="Voice")], outputs=gr.Audio()).launch().
  • Run the file with Python and open the local address Gradio prints.
  • The first run downloads the Supertonic 3 model, about 385 MB; later runs start in seconds.

Voices, speed and many users

Add catalog voices by passing the path of a voice file instead of F1 or F2, and offer a language dropdown with the codes of the 31 supported languages. Speed can be changed on the engine, for example tts.speed = 1.1, from 0.7 to 2.0. Create the engine once at the top of the file, and when several people use the app at the same time, wrap the call in a threading lock so requests take turns.

Host it free

Hugging Face Spaces runs Gradio apps on free CPU hardware: put the file in a Space as app.py with a requirements.txt that lists superclonica-cpu, and the Space builds it. Our own SuperClonica demo runs this way on two shared CPU cores. Limit the text length in a public app, and offer only voices you are allowed to share: the stock voices are free under the model license, while catalog voices you bought are for your own projects.