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
AudioContext
AudioContext
class max.pipelines.context.AudioContext(*, tokens, request_id=<factory>, model_name='', negative_tokens=None, audio_duration, num_inference_steps, guidance_scale=None, seed=None, audio_format='wav', waveform=None, status=GenerationStatus.ACTIVE)
Bases: object
A model-ready context for audio generation requests.
Like PixelContext, this carries only what the model executes
against: the caller’s text has already been through the tokenizer, and
what is left is token ids plus the numbers that size the generation.
-
Parameters:
-
- tokens (TokenBuffer) – The conditional prompt’s token ids.
- request_id (RequestID) – A unique identifier for this generation request.
- model_name (str) – Name of the model being used.
- negative_tokens (TokenBuffer | None) – The unconditional prompt’s token ids, for models that generate with classifier-free guidance.
- audio_duration (float) – Upper bound on the generated audio, in seconds. A model may stop earlier, so the waveform’s own length is the authority on what was produced. Required, because what a request leaves unset is the checkpoint’s default rather than any value this framework could pick, and the tokenizer resolves it.
- num_inference_steps (int) – Denoising steps, for models whose audio comes from a diffusion or flow-matching stage. Required, for the same reason as audio_duration.
- guidance_scale (float | None) – Classifier-free guidance scale, or None to leave it to the model. Audio models often bake distinct scales into distinct stages, and a single request-level number cannot say which one it means.
- seed (int | None) – RNG seed for the sampling the model does.
- audio_format (str) – Container the waveform is encoded into for the response.
- waveform (ndarray[tuple[Any, ...], dtype[float32]] | None) – The generated samples, once there are any.
- status (GenerationStatus)
audio_duration
audio_duration: float
audio_format
audio_format: str = 'wav'
compute_num_available_steps()
compute_num_available_steps(max_seq_len)
Returns the denoising steps, for scheduler compatibility.
guidance_scale
is_done
property is_done: bool
Whether the request has completed generation.
model_name
model_name: str = ''
negative_tokens
negative_tokens: TokenBuffer | None = None
Unconditional prompt tokens. None for models that do not guide.
num_inference_steps
num_inference_steps: int
request_id
request_id: RequestID
reset()
reset()
Resets the context’s state.
-
Return type:
-
None
seed
status
status: GenerationStatus = 'active'
tokens
tokens: TokenBuffer
Conditional prompt tokens.
update()
update(waveform)
Stores the generated samples on the context.
waveform
waveform: ndarray[tuple[Any, ...], dtype[float32]] | None = None
Generated samples in (channels, samples) layout, in [-1, 1].