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.1.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.1-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for sinapsis_csm-0.1.1.tar.gz
Algorithm Hash digest
SHA256 cd51ddd1d686a149a6fc22ff2c65da75d4b1c56287c804e0352640d064a3425c
MD5 d2e6dc5fc2de10e316bed5fb6d484d2b
BLAKE2b-256 872ce8b741d63e0885a2029b1fae84101fd0aae24c2796a209478d0df6bac39d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for sinapsis_csm-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2efc16cb32fbf8301d0784632262c0461b7509987388ff5f9bfc95c71244926f
MD5 be88bc636a368f5b04bc8f182e5e7cc3
BLAKE2b-256 5c9b3ce19f586a7f7eee81f6eb2d6f7b265d23a22fe904ec684f6ef5b9bafb01

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