Skip to main content

Text to speech using CSM TTS model

Project description



Sinapsis CSM

🐍 Installation🚀 Features📚 Usage example📙 Documentation🔍 License

This Sinapsis CSM package integrates a lightweight, efficient text-to-speech engine using the CSM model. It provides a simple template to convert input text into speech using Sinapsis.


🐍 Installation

[!IMPORTANT] Sinapsis project requires Python 3.10 or higher.

Install using your preferred package manager. We strongly recommend using uv. To install uv, refer to the official documentation.

Install with uv:

uv pip install sinapsis-csm --extra-index-url https://pypi.sinapsis.tech

Or with raw pip:

pip install sinapsis-csm --extra-index-url https://pypi.sinapsis.tech

[!IMPORTANT] Templates in each package may require additional dependencies. For development, we recommend installing the package with all the optional dependencies:

With uv:

uv pip install sinapsis-csm[all] --extra-index-url https://pypi.sinapsis.tech

Or with raw pip:

pip install sinapsis-csm[all] --extra-index-url https://pypi.sinapsis.tech

To run this package you need a HuggingFace token. See the official instructions and set it using

export HF_TOKEN=<token-provided-by-hf>

and test it through the cli or the webapp.

Access to the following models is needed:


🚀 Features

Templates Supported

  • CSMTTS: Converts text into speech using the CSM model.

    Attributes
    • speaker_id (int, default: 0): Speaker identity index.
    • max_audio_length_ms (int, default: 10000): Max audio length in milliseconds.
    • device ("cpu" or "cuda", default: "cpu"): Device used for inference.
    • context (context: list[str] | None = None): Optional list of past utterances for context.
    • sample_rate_hz (int, default: 24000): Output audio sample rate.

📚 Usage example

This example shows how to use the CSMTTS template to convert text into speech and save it to disk.

Agent config
agent:
  name: csm_tts_agent
  description: Agent that synthesizes speech from text using the CSM model.

templates:
  - template_name: InputTemplate
    class_name: InputTemplate
    attributes: {}

  - template_name: TextInput
    class_name: TextInput
    template_input: InputTemplate
    attributes:
      text: "Hi, my name is Taylor and this is Sinapsis"

  - template_name: CSMTTS
    class_name: CSMTTS
    template_input: TextInput
    attributes:
      speaker_id: 0
      max_audio_length_ms: 10000
      device: cpu
      context: null
      sample_rate_hz: 24000

  - template_name: AudioWriterSoundFile
    class_name: AudioWriterSoundFile
    template_input: CSMTTS
    attributes:
      save_dir: csm_tts
      extension: wav

To run the config, use:

sinapsis run packages/sinapsis_csm/src/sinapsis_csm/configs/csm_agent.yml

[!NOTE] The TextInput and AudioWriterSoundFile templates come from the sinapsis-data-readers and sinapsis-data-writers packages. Make sure they are installed to use this example.


🌐 Webapp

The webapp included in this project showcases the modularity of the CSM template for speech generation tasks.

[!IMPORTANT] To run the app you first need to clone this repository:

git clone git@github.com:Sinapsis-ai/sinapsis-speech.git
cd sinapsis-speech

[!NOTE] If you'd like to enable external app sharing in Gradio, export GRADIO_SHARE_APP=True

🐳 Docker

IMPORTANT This docker image depends on the sinapsis-nvidia:base image. Please refer to the official sinapsis instructions to Build with Docker.

  1. Build the sinapsis-speech image:
docker compose -f docker/compose.yaml build
  1. Start the app container:
docker compose -f docker/compose_apps.yaml up -d sinapsis-csm
  1. Check the logs
docker logs -f sinapsis-csm
  1. The logs will display the URL to access the webapp, e.g.,::
Running on local URL:  http://127.0.0.1:7860

NOTE: The url may be different, check the output of logs.

  1. To stop the app:
docker compose -f docker/compose_apps.yaml down
💻 UV

To run the webapp using the uv package manager, follow these steps:

  1. Sync the virtual environment:
uv sync --frozen
  1. Install the wheel:
uv pip install sinapsis-speech[all] --extra-index-url https://pypi.sinapsis.tech
  1. Run the webapp:
uv run webapps/packet_tts_apps/csm_tts_app.py
  1. The terminal will display the URL to access the webapp (e.g.):
Running on local URL:  http://127.0.0.1:7860

NOTE: The URL may vary; check the terminal output for the correct address.

📙 Documentation

Documentation is available on the Sinapsis website.

Tutorials and guides for different templates and agents are available at docs.sinapsis.tech/tutorials.


🔍 License

This project is licensed under the AGPLv3 license, which encourages open collaboration and sharing. For more details, please refer to the LICENSE file.

For commercial use, please refer to our official Sinapsis website for information on obtaining a commercial license.

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

sinapsis_csm-0.1.0.tar.gz (8.1 kB view details)

Uploaded Source

Built Distribution

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

sinapsis_csm-0.1.0-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

File details

Details for the file sinapsis_csm-0.1.0.tar.gz.

File metadata

  • Download URL: sinapsis_csm-0.1.0.tar.gz
  • Upload date:
  • Size: 8.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.5.16

File hashes

Hashes for sinapsis_csm-0.1.0.tar.gz
Algorithm Hash digest
SHA256 4f273301def80bd743a5099a9bd03ee9cc92fc2248472e01bc98085403a52321
MD5 a55955378e1c9d0d73c31615aba719ed
BLAKE2b-256 9dc1cadb1a4341c25db950270c8b4124e4b94014b1901a09fd45d616fe678f9f

See more details on using hashes here.

File details

Details for the file sinapsis_csm-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for sinapsis_csm-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9c1bcab4d0690244ea8c633bc3f38a5c0f139ce879e029ddc8e05c547178fc63
MD5 0a341568ea75e039a44150f10d1ff570
BLAKE2b-256 3f006b21b5e728f2b563c1e467365317c6bc7ea79e75163986047f12ea4f1109

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