IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /get-started.md). For the complete documentation index, see llms.txt.
Skip to main content
For the complete documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /get-started.md).

Python class

OutputAudioContent

OutputAudioContent

class max.pipelines.request.OutputAudioContent(*, type='output_audio', audio_url=None, audio_data=None, format=None, sample_rate=None, num_samples=None, samples=None)

source

Bases: BaseModel

Audio content generated by the model in output messages.

Parameters:

audio_data

audio_data: str | None

source

audio_url

audio_url: str | None

source

format

format: str | None

source

from_numpy_samples()

classmethod from_numpy_samples(samples, *, sample_rate, format=None)

source

Creates internal audio content from a raw waveform.

Parameters:

  • samples (ndarray[tuple[Any, ...], dtype[float32]]) – A float32 array with shape [channels, samples] holding values in [-1, 1].
  • sample_rate (int) – Sample rate of the waveform, in hertz.
  • format (str | None) – Optional container metadata, typically "wav".

Returns:

An OutputAudioContent carrying the raw waveform, for the route to encode into a container.

Raises:

ValueError – If the dtype, rank, or sample rate is invalid.

Return type:

OutputAudioContent

model_config

model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'frozen': True}

source

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

num_samples

num_samples: int | None

source

sample_rate

sample_rate: int | None

source

samples

samples: SkipJsonSchema[npt.NDArray[np.float32] | None]

source

type

type: Literal['output_audio']

source