{"record":{"id":"e61ea1b5dfa1ceb5","repo":"Comfy-Org/ComfyUI","slug":"no-audio-stream-found-in-response","errorCode":null,"errorMessage":"No audio stream found in response.","messagePattern":"No audio stream found in response\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"comfy_api_nodes/util/conversions.py","lineNumber":578,"sourceCode":"def _f32_pcm(wav: torch.Tensor) -> torch.Tensor:\n    \"\"\"Convert audio to float 32 bits PCM format. Copy-paste from nodes_audio.py file.\"\"\"\n    if wav.dtype.is_floating_point:\n        return wav\n    elif wav.dtype == torch.int16:\n        return wav.float() / (2**15)\n    elif wav.dtype == torch.int32:\n        return wav.float() / (2**31)\n    raise ValueError(f\"Unsupported wav dtype: {wav.dtype}\")\n\n\ndef audio_bytes_to_audio_input(audio_bytes: bytes) -> dict:\n    \"\"\"\n    Decode any common audio container from bytes using PyAV and return\n    a Comfy AUDIO dict: {\"waveform\": [1, C, T] float32, \"sample_rate\": int}.\n    \"\"\"\n    with av.open(BytesIO(audio_bytes)) as af:\n        if not af.streams.audio:\n            raise ValueError(\"No audio stream found in response.\")\n        stream = af.streams.audio[0]\n\n        in_sr = int(stream.codec_context.sample_rate)\n        out_sr = in_sr\n\n        frames: list[torch.Tensor] = []\n        n_channels = stream.channels or 1\n\n        for frame in af.decode(streams=stream.index):\n            arr = frame.to_ndarray()  # shape can be [C, T] or [T, C] or [T]\n            buf = torch.from_numpy(arr)\n            if buf.ndim == 1:\n                buf = buf.unsqueeze(0)  # [T] -> [1, T]\n            elif buf.shape[0] != n_channels and buf.shape[-1] == n_channels:\n                buf = buf.transpose(0, 1).contiguous()  # [T, C] -> [C, T]\n            elif buf.shape[0] != n_channels:\n                buf = buf.reshape(-1, n_channels).t().contiguous()  # fallback to [C, T]\n            frames.append(buf)","sourceCodeStart":560,"sourceCodeEnd":596,"githubUrl":"https://github.com/Comfy-Org/ComfyUI/blob/1c6d8d45b3693bfbb32385b410d813a7fd6be216/comfy_api_nodes/util/conversions.py#L560-L596","documentation":"audio_bytes_to_audio_input opens the downloaded bytes with PyAV and requires at least one audio stream. If af.streams.audio is empty it raises ValueError('No audio stream found in response.') because there is nothing to decode into a Comfy AUDIO dict.","triggerScenarios":"A text-to-music/speech API node downloads the response body and the bytes are not audio-with-a-stream: a video-only MP4, a JSON error object, an HTML error page, or an empty body that still parses as a container.","commonSituations":"The API returned an error payload with HTTP 200 (async job failed server-side but body is JSON); the endpoint changed to return a zip/manifest instead of raw audio; a CDN intercepting the request; wrong endpoint URL used in a custom node.","solutions":["Dump the first bytes of the response to a file and inspect with ffprobe or a text editor — if it is JSON/HTML, the upstream call failed, not the audio parsing.","Check the API node's status/job polling: confirm the job actually completed before the download step.","Re-run the request and inspect the logged response body in request logs.","If the file is real audio in an exotic container, re-export it as WAV/MP3 and feed it via Load Audio instead."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"import av\nfrom io import BytesIO\n\nwith av.open(BytesIO(audio_bytes)) as c:\n    if not c.streams.audio:\n        # inspect bytes: probably a JSON/HTML error, not audio\n        preview = audio_bytes[:64]\n        raise ValueError(f'No audio stream; body starts with: {preview!r}')","typeGuard":null,"tryCatchPattern":"try:\n    audio = audio_bytes_to_audio_input(data)\nexcept ValueError as e:\n    if 'No audio stream' in str(e):\n        # upstream returned a non-audio body; do not retry blindly\n        log.error('Non-audio response: %r', data[:200])\n        raise\n    raise","preventionTips":["Check Content-Type of media responses before decoding when the API provides it.","Confirm the generation job reached a terminal success state before downloading.","Log the first bytes of unexpected payloads for diagnosis."],"tags":["audio","pyav","api-response","validation"],"backgroundTag":null,"analyzedSha":"1c6d8d45b3693bfbb32385b410d813a7fd6be216","analyzedAt":"2026-08-14T19:37:18.893Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}