--- title: TTSIE emoji: 🎙️ colorFrom: indigo colorTo: purple sdk: gradio sdk_version: "4.44.0" python_version: "3.10" app_file: app.py pinned: false --- ## TTSIE – Text to Speech Synthesis TTSIE is a text‑to‑speech demo built with **Tacotron 2** for mel‑spectrogram prediction and **HiFi‑GAN** as a neural vocoder, wrapped in a modern **Gradio** interface for easy experimentation and deployment on Hugging Face Spaces. ### 1. Project structure (key files) - `Imports.py` – common library imports (TensorFlow / Keras, JAX, NumPy, librosa, etc.). - `Configuration.py` – core constants (sample rate, FFT length, number of mel bins, etc.). - `preprocessing.py` – text–to–ID mappings and JAX mel computation utilities. - `Tacotron_V2_Layers.py` – Tacotron 2 encoder, decoder, attention and postnet layers. - `Vocoder_Layers.py` – HiFi‑GAN‑style generator definition. - `Model_Loading.py` – builds the encoder, decoder, postnet and vocoder Keras models. - `Weights_Loading.py` – loads the Tacotron 2 model state (`tacotron2_state_best.pkl`). - `Inference.py` – full inference loop that runs Tacotron 2 + postnet + HiFi‑GAN to produce audio. - `app.py` – Gradio UI for text input and audio output, ready for Hugging Face Spaces. - `requirements.txt` – Python dependencies for local use and Spaces. 1. **Create and activate a virtual environment** (recommended). 2. Install dependencies: ```bash pip install -r requirements.txt ``` 3. Make sure the following weight/state files are placed in this directory: - `tacotron2_state_best.pkl` - `vocoder_state_best.pkl` (If your files use different names, update them in `Weights_Loading.py` and `app.py`.) 4. Launch the Gradio app: ```bash python app.py ``` 5. Open the printed local URL in your browser and type text into the big textbox, then click **Generate** to hear the synthesized speech. ### 3. Deploying to Hugging Face Spaces 1. Create a new Space (type: **Gradio**). 2. Upload (or push via Git) at least these files to the root of the Space: - `app.py` - `requirements.txt` - `Imports.py`, `Configuration.py`, `preprocessing.py` - `Tacotron_V2_Layers.py`, `Vocoder_Layers.py`, `Model_Loading.py`, `Weights_Loading.py`, `Inference.py` - Model state files: `tacotron2_state_best.pkl`, `vocoder_state_best.pkl` 3. Ensure the Space is configured to use `app.py` as the entry point (default for Gradio Spaces). 4. Once the build finishes, the Space will display the same TTSIE interface shown in the mockup image and allow you to generate speech directly from your browser. ### 4. Notes - This project is intended for **educational and experimental** purposes. - The code focuses on clarity and end‑to‑end functionality rather than production optimization. - If you change the architecture or training setup, make sure to update the configuration constants and checkpoint loading paths accordingly.