Git Product home page Git Product logo

tts-server's Introduction

๐ŸŽค TTS-Server

This project is a Text-to-Speech (TTS) server implemented in Python using Flask. It utilizes StyleTTS2 for high-quality speech synthesis. The server facilitates the generation of speech from text with various voice styles and parameters, and manages a queue for processing TTS requests.

Features

  • Streaming generation allows for long-form narration
  • Upload your own voice style files
  • Voice cache improves generation performance
  • No direct dependency on espeak (but it's required to be installed on your system -- see prerequisites)
  • CLI client

Prerequisites

You need torch and phonemizer installed on your system / environment:

pip install phonemizer

Starting The Server

Install the server a

pip install git+https://github.com/lxe/tts-server.git

Run the server:

python -m tts_server.server

You can use --host <host> and --port <port> to specify the server's address and port. --help for more options.

HTTP API

Create New Session

  • Method: POST
  • URL: /session/new
  • Request (Form-data or JSON):
    • voice (file, optional): Upload a voice file.
    • voice (string, optional): Predefined voice name.
  • Response (JSON):
    • message: Confirmation message.
    • voice: Voice used in the session.
    • session_id: Generated session ID.

Perform TTS

  • Method: POST
  • URL: /tts
  • Request (JSON):
    • sessionId (integer, required): Session identifier.
    • text (string, required): Text to be synthesized.
    • alpha, beta, diffusion_steps, embedding_scale (floats/integers, optional): TTS parameters.
  • Response (audio/wav):
    • Binary WAV file.

Get Available Voices

  • Method: GET
  • URL: /voices
  • Response (JSON):
    • List of available voice keys.

Error Handling

  • Custom error responses for various server exceptions.

CLI Client

The server can be interacted with via CURL commands:

curl -X POST -H "Content-Type: application/json" -H "Accept: audio/wav" -d '{
  "sessionId": 12345,
  "text": "Embrace the chaos and let your words dance to the rhythm of imagination!",
  "alpha": 0.2,
  "beta": 0.4,
  "diffusion_steps": 10,
  "embedding_scale": 1.5
}' "http://localhost:5050/tts" | aplay

...or the CLI client...

python -m tts_server.cli "In a fantastical forest, flittering fireflies illuminate the night, casting a mesmerizing dance of light and shadow beneath the ancient, gnarled trees."

You can pass longer text to the cli for long-form narration:

echo "As the fireflies twinkle in harmonious rhythm, their gentle glow reveals the secrets of the woodland. Tiny creatures, hidden from sight by day, emerge to partake in this nocturnal spectacle. Frogs serenade with their melodic croaks, and owls, wise sentinels of the night, exchange hoots that echo through the enchanted forest." | python -m tts_server.cli -

Credits

This project utilizes StyleTTS2 for its text-to-speech synthesis capabilities. Special thanks to @yl4579 for creating StyleTTS2 and @fakerybakery for the styletts2-importable for inspiration on tts.py

License

This project is licensed under the MIT License - see the LICENSE file for details.

tts-server's People

Contributors

lxe avatar antoineandrieu avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.