Skip to content

Windows 11 Bug #209

@aifeifei798

Description

@aifeifei798

.....\lib\site-packages\autosub_init_.py", line 185, in extract_audio
raise Exception("Dependency not found: ffmpeg")


chang the init.py

import shutil
def extract_audio(filename, channels=1, rate=16000):
    """
    Extract audio from an input file to a temporary WAV file.
    """
    temp = tempfile.NamedTemporaryFile(suffix='.wav', delete=False)
    if not os.path.isfile(filename):
        print(f"The given file does not exist: {filename}")
        raise Exception(f"Invalid filepath: {filename}")
    
    # Use shutil.which to find ffmpeg (cross-platform compatible)
    ffmpeg_path = shutil.which("ffmpeg")
    if not ffmpeg_path:
        print("ffmpeg: Executable not found on machine.")
        raise Exception("Dependency not found: ffmpeg")
    
    # Use the full path to ffmpeg in the command
    command = [ffmpeg_path, "-y", "-i", filename,
               "-ac", str(channels), "-ar", str(rate),
               "-loglevel", "error", temp.name]
    
    # On Windows, shell=True is needed
    use_shell = os.name == "nt"
    
    subprocess.check_output(command, stdin=open(os.devnull), shell=use_shell)
    return temp.name, rate

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions