bastibe / python-soundfile

SoundFile is an audio library based on libsndfile, CFFI, and NumPy
BSD 3-Clause "New" or "Revised" License
712 stars 108 forks source link

Validate argument for `seek` is integer. #444

Open Ruben-Kruepper opened 1 month ago

Ruben-Kruepper commented 1 month ago

I've been using this excellent on my Mac for months. Now, suddenly, files that previously ran through my scripts just fine throw.

  File "/Users/ini/parsonos/palaba-server/palaba/transcription.py", line 238, in transcribe_audio
    audio_chunks = _chunk_audio(audio_file_path, tmp_path)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ini/parsonos/palaba-server/palaba/transcription.py", line 127, in _chunk_audio
    sound_file.seek(offset)
  File "/Users/ini/parsonos/palaba-server/env/lib/python3.11/site-packages/soundfile.py", line 802, in seek
    _error_check(self._errorcode)
  File "/Users/ini/parsonos/palaba-server/env/lib/python3.11/site-packages/soundfile.py", line 1407, in _error_check
    raise LibsndfileError(err, prefix=prefix)
soundfile.LibsndfileError: Internal psf_fseek() failed.

Update: I identified the issue as an invalid float argument to seek. I suggest a check to validate that arguments are in fact int. 🤓

bastibe commented 1 month ago

Thank you for the analysis. I'd be grateful if you could prepare a pull request that issues an appropriate error message.