dspy.Audio¶
dspy.Audio
¶
Bases: Type
Functions¶
description() -> str
classmethod
¶
extract_custom_type_from_annotation(annotation)
classmethod
¶
Extract all custom types from the annotation.
This is used to extract all custom types from the annotation of a field, while the annotation can
have arbitrary level of nesting. For example, we detect Tool
is in list[dict[str, Tool]]
.
Source code in dspy/adapters/types/base_type.py
format() -> list[dict[str, Any]]
¶
Source code in dspy/adapters/types/audio.py
from_array(array: Any, sampling_rate: int, format: str = 'wav') -> Audio
classmethod
¶
Process numpy-like array and encode it as base64. Uses sampling rate and audio format for encoding.
Source code in dspy/adapters/types/audio.py
from_file(file_path: str) -> Audio
classmethod
¶
Read local audio file and encode it as base64.
Source code in dspy/adapters/types/audio.py
from_url(url: str) -> Audio
classmethod
¶
Download an audio file from URL and encode it as base64.
Source code in dspy/adapters/types/audio.py
serialize_model()
¶
validate_input(values: Any) -> Any
classmethod
¶
Validate input for Audio, expecting 'data' and 'audio_format' keys in dictionary.
Source code in dspy/adapters/types/audio.py
:::