Docs /Templates/ sinapsis-data-readers

AudioReaderPydub

sinapsis-data-readerscommunityaudioreaderspydubsoundfile

Python template · sinapsis_data_readers.templates.audio_readers.audio_reader_pydub

Overview

Audio reader for reading audio data directly from bytes or files using Pydub.

This class can read audio data from either a bytes object or a file path, using the Pydub library. When reading from bytes, it retains the data in byte format. When reading from a file, it converts the audio data to a NumPy array.

Capabilities

Capabilities: not set

Installation

Install the published package using pip or uv.

Terminalbash
pip install sinapsis-data-readers==1.0.0
uv pip install sinapsis-data-readers==1.0.0
uv add sinapsis-data-readers==1.0.0

Configuration

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

source
str
Optional
Default: "f8beca0a-1ed4-4fd3-a751-cbbda0405dca"
metadata
sinapsis_core.template_base.base_models.TemplateMetadata | None
Optional
Default: null
root_dir
str | None
Optional
Default: null
from_bytes

Flag to determine if the file is in bytes. Defaults to True. audio_reader_format (Literal["wav", "raw", "pcm"] | None) Format of the source audio file, if not provided will be automatically detected. Defaults to None.

bool
Optional
Default: false
audio_file_pathRequired
str
Required
Default: null
sample_rate_khz

Sample rate in khz for the processed audio. Defaults to 16hkz.

int
Optional
Default: 16
audio_reader_format
typing.Optional[typing.Literal['wav', 'raw', 'pcm']]
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: AudioReaderPydub
      class_name: AudioReaderPydub
      template_input: InputTemplate
      attributes:
        audio_file_path: '/path/to/file.mp3'
        source: 'source/of/file'
        sample_rate_khz: 16
        from_bytes: false
Show schema-based configuration skeleton
yaml
templates:
  - template_name: "AudioReaderPydub"
    class_name: "AudioReaderPydub"
    attributes:
      source: "f8beca0a-1ed4-4fd3-a751-cbbda0405dca"
      root_dir: null
      from_bytes: false
      audio_file_path: "<required>"
      sample_rate_khz: 16
      audio_reader_format: null

Inheritance

Immediate parent: sinapsis_data_readers.templates.audio_readers.base_audio_reader._AudioBaseReader

Environment variables

Environment definitions belong to their canonical Python modules.

No directly related environment variables listed.