Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AudioSegment.from_file(audio_path) crashes despite ffmpeg.exe hardcoded and also in the PATH #776

Open
NeilWP opened this issue Jan 31, 2024 · 0 comments

Comments

@NeilWP
Copy link

NeilWP commented Jan 31, 2024

def convert_audio_to_wav(audio_path, wav_path):
    file_extension = os.path.splitext(audio_path)[1]

    if file_extension != '.wav':
        # Specify the paths to ffmpeg and ffprobe within the virtual environment
        ffmpeg_path = r"C:\Users\nwpno\AppData\Local\ffmpeg-6.1.1\bin\ffmpeg.exe"
        ffprobe_path = r"C:\Users\nwpno\AppData\Local\ffmpeg-6.1.1\bin\ffprobe.exe"

        # Set the paths for Pydub
        AudioSegment.converter = ffmpeg_path
        AudioSegment.ffmpeg = ffmpeg_path
        AudioSegment.ffprobe = ffprobe_path

        # Perform the conversion
        audio = AudioSegment.from_file(audio_path)
        audio.export(wav_path, format='wav')
        print("Conversion successful")
    else:
        print("File is already in WAV format")

    return wav_path
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant