Docs /Templates/ sinapsis-huggingface-transformers

SpeechToTextTransformers

sinapsis-huggingface-transformersTransformersmodelsaudiospeechtext-to-speech

Python template · sinapsis_huggingface_transformers.templates.speech_to_text_transformers

Overview

Template to perform speech-to-text actions using the HuggingFace module through the 'transformers' architecture.

The template takes an Audio from the DataContainer and uses a speech-recognition model to transcribe the audio. Finally, it returns the text in 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
metadata
sinapsis_core.template_base.base_models.TemplateMetadata | None
Optional
Default: null
model_path
typing.Literal['openai/whisper-small']
Optional
Default: "openai/whisper-small"
torch_dtype
typing.Literal['float16', 'float32']
Optional
Default: "float16"
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

Task-specific parameters for the speech-to-text pipeline, such as `return_timestamps`.

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

If set, controls the granularity of timestamps returned with the transcribed text. Can be "char", "word", or True for segments.

typing.Union[typing.Literal['char', 'word'], bool, NoneType]
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: SpeechToTextTransformers
  class_name: SpeechToTextTransformers
  template_input: InputTemplate
  attributes:
    model_path: '/path/to/model'
    model_cache_dir: /path/to/cache/dir
    device: 'cuda'
    torch_dtype: float16
Show schema-based configuration skeleton
yaml
templates:
  - template_name: "SpeechToTextTransformers"
    class_name: "SpeechToTextTransformers"
    attributes:
      seed: null
      model_path: "openai/whisper-small"
      torch_dtype: "float16"
      model_cache_dir: "/home/ariel/.cache/sinapsis"
      pipeline_kwargs:
        device: "<required>"
        torch_dtype: "float16"
      inference_kwargs:
        generate_kwargs: null
        return_timestamps: 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.