Docs /Templates/ sinapsis-huggingface-transformers

TextToSpeechTransformers

sinapsis-huggingface-transformersTransformersmodelsaudiospeechtext-to-speech

Python template · sinapsis_huggingface_transformers.templates.text_to_speech_transformers

Overview

The template generates an audio from a prompt that is passed through the text packet in the DataContainer. It uses the transformers architecture and a HuggingFace model to produce the audio. Finally, it sends the audio through the DataContainer

Capabilities

Capabilities: not set

Installation

Install the published package using pip or uv.

Terminalbash
pip install sinapsis-huggingface-transformers==1.0.0
uv pip install sinapsis-huggingface-transformers==1.0.0
uv add sinapsis-huggingface-transformers==1.0.0

Configuration

Effective fields from the inspector schema, including nested Pydantic model fields.

seed
int | None
Optional
Default: null
n_words

The number of words per sentence when splitting the input text into smaller chunks. If not specified, sentences will be split based on punctuation.

int | None
Optional
Default: null
metadata
sinapsis_core.template_base.base_models.TemplateMetadata | None
Optional
Default: null
model_path
typing.Literal['suno/bark', 'suno/bark-small', 'ResembleAI/chatterbox']
Optional
Default: "suno/bark"
sample_rate

The sample rate (in Hz) for the generated audio. If not provided, the sample rate will be determined dynamically from the model.

int | None
Optional
Default: null
torch_dtype
typing.Literal['float16', 'float32']
Optional
Default: "float16"
use_embeddings

Whether to use speaker embeddings during audio generation. Defaults to `False`. If set to `True`, embeddings must be provided for each text packet.

bool
Optional
Default: false
model_cache_dir
str
Optional
Default: "/home/ariel/.cache/sinapsis"
pipeline_kwargs
PipelineKwargs
Optional
Default: null
deviceRequired
typing.Literal['cuda', 'cpu']
Required
Default: null
torch_dtype
typing.Literal['float16', 'float32', 'auto']
Optional
Default: "float16"
inference_kwargs
BaseInferenceKwargs
Optional
Default: null
generate_kwargs

A dictionary of advanced parameters passed directly to the model's `generate` method for fine-tuning the pipeline generation.

dict[str, typing.Any] | None
Optional
Default: null

Configuration example

Example from the Python docstring:

yaml
agent:
  name: my_test_agent
templates:
- template_name: InputTemplate
  class_name: InputTemplate
  attributes: {}
- template_name: TextToSpeechTransformers
  class_name: TextToSpeechTransformers
  template_input: InputTemplate
  attributes:
    model_path: '/path/to/model'
    model_cache_dir: /path/to/cache/dir
    device: 'cuda'
    torch_dtype: float16
    use_embeddings: false
    sample_rate: 16000
    n_words: 10
Show schema-based configuration skeleton
yaml
templates:
  - template_name: "TextToSpeechTransformers"
    class_name: "TextToSpeechTransformers"
    attributes:
      seed: null
      n_words: null
      model_path: "suno/bark"
      sample_rate: null
      torch_dtype: "float16"
      use_embeddings: false
      model_cache_dir: "/home/ariel/.cache/sinapsis"
      pipeline_kwargs:
        device: "<required>"
        torch_dtype: "float16"
      inference_kwargs:
        generate_kwargs: null

Inheritance

Immediate parent: sinapsis_huggingface_transformers.templates.base_transformers.TransformersBase

Environment variables

Environment definitions belong to their canonical Python modules.

No directly related environment variables listed.