ATH-MaaS/Pixelle-Video · error · FileNotFoundError

参考音频不存在: {reference_audio_path}

Error message

参考音频不存在: {reference_audio_path}

What it means

generate_video() validates that reference_audio_path exists on disk before submitting the DashScope task. If the file is missing, a FileNotFoundError naming the path is raised. Note the guard is skipped when reference_audio_path is None/empty and for 'happyhorse' models where audio is intentionally dropped.

Source

Thrown at pixelle_video/services/api_services/video_dashscope.py:194

        if VideoSynthesis is None:
            raise RuntimeError("dashscope package not installed. Run: pip install dashscope")

        if image_path and not os.path.exists(image_path):
            raise FileNotFoundError(f"输入图片不存在: {image_path}")
        if last_image_path and not os.path.exists(last_image_path):
            raise FileNotFoundError(f"尾帧图片不存在: {last_image_path}")
        if first_clip_path and not os.path.exists(first_clip_path):
            raise FileNotFoundError(f"输入视频片段不存在: {first_clip_path}")
        if reference_image_path and not os.path.exists(reference_image_path):
            raise FileNotFoundError(f"参考图片不存在: {reference_image_path}")
        for ref_image_path in reference_image_paths or []:
            if ref_image_path and not os.path.exists(ref_image_path):
                raise FileNotFoundError(f"参考图片不存在: {ref_image_path}")
        for ref_video_path in reference_video_paths or []:
            if ref_video_path and not os.path.exists(ref_video_path):
                raise FileNotFoundError(f"参考视频不存在: {ref_video_path}")
        if reference_audio_path and not os.path.exists(reference_audio_path):
            raise FileNotFoundError(f"参考音频不存在: {reference_audio_path}")
        if audio_path and not os.path.exists(audio_path):
            raise FileNotFoundError(f"驱动音频不存在: {audio_path}")

        logger.info(f"DashscopeVideoClient: model={model}, prompt={prompt[:60]}...")

        if self._is_text_to_video_model(model):
            call_kwargs = {
                "api_key": self.api_key,
                "model": model,
                "prompt": prompt,
                "duration": duration,
                "watermark": watermark,
            }
            if negative_prompt:
                call_kwargs["negative_prompt"] = negative_prompt
            if resolution:
                call_kwargs["resolution"] = resolution
            if video_ratio:

View on GitHub (pinned to 848b054e4f)

Solutions

  1. Verify os.path.exists(reference_audio_path) in the same working directory/process before the call.
  2. Make the path absolute or anchor it to the project base directory.
  3. Confirm the audio-generation step succeeded and flushed/closed the file before calling generate_video.
  4. Check Docker/host volume mounts for the audio directory.

Example fix

// before
client.generate_video(prompt=p, reference_audio_path="out/tts.mp3")
// after
audio = os.path.abspath("out/tts.mp3")
assert os.path.isfile(audio), f"missing reference audio: {audio}"
client.generate_video(prompt=p, reference_audio_path=audio)
Defensive patterns

Strategy: validation

Validate before calling

if reference_audio_path and not os.path.isfile(reference_audio_path):
    raise FileNotFoundError(f"reference audio missing: {reference_audio_path}")

Type guard

def has_reference_audio(p: str | None) -> bool:
    return p is None or os.path.isfile(p)

Try / catch

try:
    client.generate_video(prompt=p, reference_audio_path=audio)
except FileNotFoundError as e:
    logger.error("reference audio missing: %s", e)
    raise

Prevention

When it happens

Trigger: generate_video() called with a non-None reference_audio_path that does not exist at os.path.exists() time.

Common situations: TTS/audio-preparation step failed upstream; audio written to a temp dir that was cleaned; relative path vs different CWD; container missing the mounted audio directory; wrong extension or path separator on Windows.

Understand the failure class

Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.

Related errors


AI-assisted analysis of ATH-MaaS/Pixelle-Video@848b054e4f (2026-08-30). Data as JSON: /api/errors/6b56959825eda56a. Report an issue: GitHub.