TTS-samples / README.md
Luigi's picture
add app.py then update readme
1c2eb44
metadata
title: TTS Samples
emoji: πŸš€
colorFrom: red
colorTo: red
sdk: docker
app_port: 8501
tags:
  - streamlit
pinned: false
short_description: TTS Samples
license: mit

TTS Samples Player (Streamlit)

This Streamlit app lets you play pre-generated TTS WAV samples in a Hugging Face Space.

Folder structure

  • app.py: Streamlit application code.
  • requirements.txt: dependencies.
  • tts_smaples/: folder containing subfolders per TTS provider, each with .wav files.
    • Example:
      tts_smaples/
      β”œβ”€β”€ azure/
      β”‚   β”œβ”€β”€ HsiaoChen.wav
      β”‚   β”œβ”€β”€ HsiaoYu.wav
      β”‚   └── YunJhe.wav
      β”œβ”€β”€ google/
      β”‚   └── Sulafat.wav
      β”œβ”€β”€ openai/
      β”‚   └── Nova.wav
      └── yating/
          └── Yating.wav
      

Deployment in Hugging Face Spaces

  1. Create a new Space using the Streamlit SDK.
  2. Commit the repository with:
    • app.py
    • requirements.txt (containing streamlit)
    • tts_smaples/ folder with your .wav samples.
  3. HF Spaces will install dependencies and serve the Streamlit app automatically.
  4. Open the Space URL; you should see a dropdown to select provider/voice and play the audio.

Extending

  • Generate TTS on the fly: add a st.text_input or st.text_area and a β€œGenerate” button; in its callback, run your TTS engine, save to a temp file or return raw bytes, and pass to st.audio(...).
  • Styling/Layout: use st.sidebar for selections, or columns/containers for layout.
  • Additional formats: you can support .mp3 or other audio formats; adjust the file extension check and st.audio format argument accordingly.
  • Caching: if generation is expensive, cache results with @st.cache_data or @st.cache_resource.
  • Large files: if your WAV files are large, consider their size for client bandwidth; you may offer compressed versions or stream.

5. Testing locally

Before pushing:

  1. Ensure you have Python installed and a virtualenv.
  2. pip install -r requirements.txt
  3. Ensure your tts_smaples/ folder is in the same directory.
  4. Run:
    streamlit run app.py