Describe the bug
TTSModelSettings.dtype is typed as npt.DTypeLike, and the voice pipeline accepts dictionary settings such as config={"tts_settings": {"dtype": "float32"}}. Dictionary settings keep dtype as the string "float32", but StreamedAudioResult._transform_audio_buffer compares the configured dtype with == np.int16 / == np.float32. That comparison is False for the string spelling, so the pipeline raises UserError("Invalid output dtype") even though np.dtype("float32") resolves to a supported dtype.
The error is raised inside the TTS streaming task, after the text-to-speech request has already been made, and surfaces from StreamedAudioResult.stream() as a session error. Passing np.float32 directly works; the string spelling (the only one a JSON/YAML-loaded config can carry) does not.
Debug information
- Agents SDK version:
main (v0.22.0, commit 89c02c8)
- Python version: 3.11
Repro steps
import numpy as np
from agents.voice import AudioInput, VoicePipeline
from agents.voice.testing import ScriptedSTTModel, ScriptedTTSModel, ScriptedVoiceWorkflow, TTSResult, pcm16_samples
pipeline = VoicePipeline(
workflow=ScriptedVoiceWorkflow([["hi."]]),
stt_model=ScriptedSTTModel(["hello"]),
tts_model=ScriptedTTSModel([TTSResult([pcm16_samples([0, 100, -100, 0])])]),
config={"tracing_disabled": True, "tts_settings": {"buffer_size": 1, "dtype": "float32"}},
)
result = await pipeline.run(AudioInput(np.zeros(2, dtype=np.int16)))
async for event in result.stream():
print(event.type)
# agents.exceptions.UserError: Invalid output dtype
Replacing "dtype": "float32" with "dtype": np.float32 produces float32 audio as expected. "int16" fails the same way.
Expected behavior
Any dtype spelling that NumPy resolves to int16 or float32 (for example "float32", "int16", np.dtype("float32")) should produce audio in that dtype. Unsupported dtypes should keep raising UserError("Invalid output dtype").
Describe the bug
TTSModelSettings.dtypeis typed asnpt.DTypeLike, and the voice pipeline accepts dictionary settings such asconfig={"tts_settings": {"dtype": "float32"}}. Dictionary settings keepdtypeas the string"float32", butStreamedAudioResult._transform_audio_buffercompares the configured dtype with== np.int16/== np.float32. That comparison isFalsefor the string spelling, so the pipeline raisesUserError("Invalid output dtype")even thoughnp.dtype("float32")resolves to a supported dtype.The error is raised inside the TTS streaming task, after the text-to-speech request has already been made, and surfaces from
StreamedAudioResult.stream()as a session error. Passingnp.float32directly works; the string spelling (the only one a JSON/YAML-loaded config can carry) does not.Debug information
main(v0.22.0, commit 89c02c8)Repro steps
Replacing
"dtype": "float32"with"dtype": np.float32produces float32 audio as expected."int16"fails the same way.Expected behavior
Any dtype spelling that NumPy resolves to
int16orfloat32(for example"float32","int16",np.dtype("float32")) should produce audio in that dtype. Unsupported dtypes should keep raisingUserError("Invalid output dtype").