MahmoudAshraf97 / whisper-diarization

Automatic Speech Recognition with Speaker Diarization based on OpenAI Whisper
BSD 2-Clause "Simplified" License
2.53k stars 243 forks source link

Use os.path.splitext to fix filename-extension splitting for extensions that aren't exactly 3 chars long #114

Closed jamesqh closed 9 months ago

jamesqh commented 9 months ago

Currently filenames and extensions are split by simply cutting off the final four characters: audio.wav -> [audio][.wav]

That works great if you have a three character extension, but causes problems otherwise. For example if you're trying to diarise a .opus file (like I was), demucs will split the filename correctly, but diarize.py will split audio.opus -> [audio.][opus] and go looking for temp_outputs/htdemucs/audio./vocals.wav, which won't exist! This was slightly frustrating to figure out :)

Python's stdlib has a built in function os.path.splitext for doing this robustly, and I make here a pull request suggesting the simplest change.