{"record":{"id":"1eff278872271bab","repo":"microsoft/VibeVoice","slug":"failed-to-load-audio-e","errorCode":null,"errorMessage":"Failed to load audio: {e}","messagePattern":"Failed to load audio: (.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"vllm_plugin/scripts/gradio_asr_demo_api_video.py","lineNumber":225,"sourceCode":"        ]\n        process = subprocess.Popen(\n            cmd, stdout=subprocess.PIPE, stderr=subprocess.DEVNULL\n        )\n        audio_bytes, _ = process.communicate()\n        audio_data = np.frombuffer(audio_bytes, dtype=np.float32)\n        \n        print(f\"[DEBUG] ffmpeg loaded: shape={audio_data.shape}, sr={target_sr}\")\n        print(f\"[DEBUG] audio range: min={audio_data.min():.6f}, max={audio_data.max():.6f}\")\n        \n        # Check for silent audio\n        if len(audio_data) == 0:\n            raise RuntimeError(\"ffmpeg returned empty audio data\")\n        if audio_data.max() == 0 and audio_data.min() == 0:\n            print(f\"[WARNING] Audio appears to be completely silent!\")\n        \n        return audio_data, target_sr\n    except Exception as e:\n        raise RuntimeError(f\"Failed to load audio: {e}\")\n\n\ndef get_file_size_mb(file_path: str) -> float:\n    \"\"\"Get file size in MB.\"\"\"\n    try:\n        return os.path.getsize(file_path) / (1024 * 1024)\n    except Exception:\n        return 0.0\n\n\ndef is_video_file(file_path: str) -> bool:\n    \"\"\"Check if the file is a video file based on extension.\"\"\"\n    ext = os.path.splitext(file_path)[1].lower()\n    return ext in COMMON_VIDEO_EXTS\n\n\ndef format_srt_time(seconds: float) -> str:\n    \"\"\"Convert seconds to SRT time format (HH:MM:SS,mmm).\"\"\"","sourceCodeStart":207,"sourceCodeEnd":243,"githubUrl":"https://github.com/microsoft/VibeVoice/blob/94da20d98b2fa7688e9cbfaf7692ddb4954f7600/vllm_plugin/scripts/gradio_asr_demo_api_video.py#L207-L243","documentation":"Catch-all wrapper in the demo's ffmpeg loader: any exception raised inside load_audio (including the 'ffmpeg returned empty audio data' RuntimeError at line 219, or np.frombuffer/min/max errors on malformed output) is re-raised as RuntimeError('Failed to load audio: {e}'). The original exception text is preserved as the suffix, so read the tail of the message to find the root cause.","triggerScenarios":"Any failure of the ffmpeg subprocess decode path: empty output (inner line-219 error), file-not-found on the input path, numpy errors from truncated float32 buffers, or OSError on malformed path objects — all surface here.","commonSituations":"Gradio demo uploads of corrupt/unsupported media; path handling bugs (relative paths resolved against the server's cwd); transient failures from partially-uploaded files in the UI.","solutions":["Read the text after 'Failed to load audio:' — it names the actual inner failure; fix that root cause (e.g. 'ffmpeg returned empty audio data' means see that error).","Validate the uploaded file before decode: exists, non-zero size, has an audio stream via ffprobe.","Convert problematic uploads to 24 kHz mono wav before feeding the demo.","If building on this script, re-raise with traceback (raise ... from e) to keep the original stack."],"exampleFix":"# before\nexcept Exception as e:\n    raise RuntimeError(f\"Failed to load audio: {e}\")\n\n# after\nexcept Exception as e:\n    raise RuntimeError(f\"Failed to load audio: {e}\") from e  # keep original stack for diagnosis","handlingStrategy":"try-catch","validationCode":"import os\n\ndef can_load(path: str) -> bool:\n    return os.path.isfile(path) and os.path.getsize(path) > 0","typeGuard":null,"tryCatchPattern":"try:\n    audio_data, sr = load_audio(path)\nexcept RuntimeError as e:\n    msg = str(e)\n    if \"empty audio data\" in msg:\n        handle_empty_or_silent(path)        # re-encode or reject file\n    elif \"No such file\" in msg or \"not exist\" in msg:\n        fix_path_and_retry(path)            # path resolution bug\n    else:\n        raise                                # unknown cause: surface it","preventionTips":["Read the suffix after 'Failed to load audio:' — it carries the true inner error.","Wrap demo uploads with file-size and ffprobe checks before invoking the loader.","Use `raise ... from e` in wrappers so stack traces survive."],"tags":["ffmpeg","error-wrapping","audio-decode","demo-script"],"backgroundTag":null,"analyzedSha":"94da20d98b2fa7688e9cbfaf7692ddb4954f7600","analyzedAt":"2026-08-15T04:12:07.418Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}