Skip to main content

A powerful, Transformer-based text-to-speech (TTS) tool.

Project description

👉 str2speech

PyPI - Version Pepy Total Downloads PyPI - License

Overview

str2speech is a simple command-line tool for converting text to speech using Transformer-based text-to-speech (TTS) models. It supports multiple models and voice presets, allowing users to generate high-quality speech audio from text.

Latest

We now support Microsoft's Speech T5. This is a very lightweight model, and sounds pretty good. Try it out with this:

str2speech --model "microsoft/speecht5_tts" \
    --text "My dog is prettier than yours." \
    --output "t5test.wav"

We now support Spark-TTS-0.5B. This is an awesome model. Here's how you use it:

str2speech --model "SparkAudio/Spark-TTS-0.5B" \
        --text "Hello from Spark" \
        --output "sparktest.wav"

Added support for Sesame CSM-1B. Here's how to use it:

export HF_TOKEN=<your huggingface token>
str2speech --text "Hello from Sesame" --model "sesame/csm-1b"

Added support for Kokoro-82M. This is how you run it:

str2speech --text "Hello again" --model "kokoro"

This is probably the easiest way to use Kokoro TTS.


Added support for Zyphra Zonos. Try this out:

str2speech --text "Hello again" \
    --model "Zyphra/Zonos-v0.1-transformer" \
    --output helloagain.wav

Alternatively, you could write Python code to use it:

from str2speech.speaker import Speaker

speaker = Speaker("Zyphra/Zonos-v0.1-transformer")
speaker.text_to_speech("Hello, this is a test!", "output.wav")

str2speech will try to install Zonos if it doesn't detect it on your system. You might still have to install espeak-ng manually.

If you choose to install Zonos yourself, please run the following:

apt install espeak-ng
git clone https://github.com/hathibelagal-dev/Zonos.git
cd Zonos && pip install -e .

Features

  • Supports multiple TTS models, including suno/bark-small, suno/bark, and various facebook/mms-tts models.
  • Allows selection of voice presets.
  • Supports text input via command-line arguments or files.
  • Outputs speech in .wav format.
  • Works with both CPU and GPU.

Available Models

The following models are supported:

  • Sesame/CSM-1B
  • SparkAudio/Spark-TTS-0.5B
  • Zyphra/Zonos-v0.1-transformer
  • microsoft/speecht5_tts
  • Kokoro (English and Spanish only)
  • suno/bark-small (default TTS model)
  • suno/bark
  • facebook/mms-tts-eng (English only)
  • facebook/mms-tts-deu (German only)
  • facebook/mms-tts-fra (French only)
  • facebook/mms-tts-spa (Spanish only)
  • facebook/mms-tts-swe (Swedish only)

Installation

To install str2speech, first make sure you have pip installed, then run:

pip install str2speech

Usage

Command Line

Run the script via the command line:

str2speech --text "Hello, world!" --output hello.wav

Options

  • --text (-t): The text to convert to speech.
  • --file (-f): A file containing text to convert to speech.
  • --voice (-v): The voice preset to use (optional, defaults to a predefined voice).
  • --output (-o): The output .wav file name (optional, defaults to output.wav).
  • --model (-m): The TTS model to use (optional, defaults to suno/bark-small).
  • --speed (-s): The speed of the speech (optional, defaults to 1.0). Supported only by Kokoro TTS currently.

Example:

str2speech --file input.txt --output speech.wav --model suno/bark

API Usage

You can also use str2speech as a Python module:

from str2speech.speaker import Speaker

speaker = Speaker()
speaker.text_to_speech("Hello, this is a test.", "test.wav")

Tested With These Dependencies

  • transformers==4.49.0
  • torch==2.5.1+cu124
  • numpy==1.26.4
  • scipy==1.13.1

License

This project is licensed under the GNU General Public License v3 (GPLv3).

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

str2speech-0.3.6.tar.gz (26.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

str2speech-0.3.6-py3-none-any.whl (28.5 kB view details)

Uploaded Python 3

File details

Details for the file str2speech-0.3.6.tar.gz.

File metadata

  • Download URL: str2speech-0.3.6.tar.gz
  • Upload date:
  • Size: 26.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.11

File hashes

Hashes for str2speech-0.3.6.tar.gz
Algorithm Hash digest
SHA256 1cfb1169a3ad562b26076e381423cb7e601b15267e25591bf4a7a8c7314da859
MD5 b971c6c8170faa7d61dae74d575509e5
BLAKE2b-256 e07b3fcf30377c985dd8b43d9a0d4ad21c3837bf473269bc921dd312efd444a4

See more details on using hashes here.

File details

Details for the file str2speech-0.3.6-py3-none-any.whl.

File metadata

  • Download URL: str2speech-0.3.6-py3-none-any.whl
  • Upload date:
  • Size: 28.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.11

File hashes

Hashes for str2speech-0.3.6-py3-none-any.whl
Algorithm Hash digest
SHA256 838e92c319e5e0a015b4a6251e0a5e02e85fa2ac9b87d338aad0fa34e99ed1c5
MD5 8bee0add5d1f25a6dc00bef69309fb41
BLAKE2b-256 3135246199e537b52b655bf354f0685c15ea9d4579ac02ca3288c268bc79eec5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page