resemble-ai / Resemblyzer

A python package to analyze and compare voices with deep learning
Apache License 2.0
2.67k stars 419 forks source link

python3 demo02_diarization.py Error opening 'audio_data/X2zqiX6yL3I.mp3': File contains data in an unknown format #7

Closed marcoippolito closed 4 years ago

marcoippolito commented 4 years ago
(Resemblizer) (base) marco@pc:~/Resemblyzer$ python3 demo02_diarization.py
Traceback (most recent call last):
  File "/home/marco/Resemblyzer/Resemblizer/lib/python3.7/site-packages/librosa
/core/audio.py", line 127, in load
    with sf.SoundFile(path) as sf_desc:
  File "/home/marco/Resemblyzer/Resemblizer/lib/python3.7/site-packages/soundfile.py", line 
627, in __init__
    self._file = self._open(file, mode_int, closefd)
  File "/home/marco/Resemblyzer/Resemblizer/lib/python3.7/site-packages/soundfile.py", line 
1182, in _open
    "Error opening {0!r}: ".format(self.name))
  File "/home/marco/Resemblyzer/Resemblizer/lib/python3.7/site-packages/soundfile.py", line 
1355, in _error_check
    raise RuntimeError(prefix + _ffi.string(err_str).decode('utf-8', 'replace'))
RuntimeError: Error opening 'audio_data/X2zqiX6yL3I.mp3': File contains data in an unknown 
format.

During handling of the above exception, another exception occurred:

   Traceback (most recent call last):
 File "demo02_diarization.py", line 14, in <module>
    wav = preprocess_wav(wav_fpath)
  File "/home/marco/Resemblyzer/resemblyzer/audio.py", line 27, in preprocess_wav
    wav, source_sr = librosa.load(fpath_or_wav, sr=None)
  File "/home/marco/Resemblyzer/Resemblizer/lib/python3.7/site-packages/librosa
/core/audio.py", line 142, in load
    y, sr_native = __audioread_load(path, offset, duration, dtype)
  File "/home/marco/Resemblyzer/Resemblizer/lib/python3.7/site-packages/librosa
/core/audio.py", line 164, in __audioread_load
    with audioread.audio_open(path) as input_file:
  File "/home/marco/Resemblyzer/Resemblizer/lib/python3.7/site-packages/audioread  
/__init__.py", line 116, in audio_open
    raise NoBackendError()
audioread.exceptions.NoBackendError
CorentinJ commented 4 years ago

You'll need a backend for librosa. See this thread: https://github.com/librosa/librosa/issues/219#issuecomment-120087907

marcoippolito commented 4 years ago

Still struggling... :

(base) (Resemblyzer) marco@pc:~/Resemblyzer$ python3 demo02_diarization.py
Traceback (most recent call last):
  File "demo02_diarization.py", line 2, in <module>
    from demo_utils import *
  File "/home/marco/Resemblyzer/demo_utils.py", line 1, in <module>
    from mpl_toolkits.axes_grid1 import make_axes_locatable
ModuleNotFoundError: No module named 'mpl_toolkits'
(base) (Resemblyzer) marco@pc:~/Resemblyzer$ python3 demo02_diarization.py
Traceback (most recent call last):
  File "demo02_diarization.py", line 2, in <module>
    from demo_utils import *
  File "/home/marco/Resemblyzer/demo_utils.py", line 1, in <module>
    from mpl_toolkits.axes_grid1 import make_axes_locatable
ModuleNotFoundError: No module named 'mpl_toolkits'
(base) (Resemblyzer) marco@pc:~/Resemblyzer$ pip3 install mpl_toolkits
Collecting mpl_toolkits
 ERROR: Could not find a version that satisfies the requirement mpl_toolkits (from versions: none)
 ERROR: No matching distribution found for mpl_toolkits
(base) (Resemblyzer) marco@pc:~/Resemblyzer$ 

(base) (Resemblyzer) marco@pc:~/Resemblyzer$ conda install -c conda-forge mpl_toolkits
Collecting package metadata (current_repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Collecting package metadata (repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.

PackagesNotFoundError: The following packages are not available from current channels:

  - mpl_toolkits

Current channels:

   - https://conda.anaconda.org/conda-forge/linux-64
  - https://conda.anaconda.org/conda-forge/noarch
  - https://repo.anaconda.com/pkgs/main/linux-64
  - https://repo.anaconda.com/pkgs/main/noarch
  - https://repo.anaconda.com/pkgs/r/linux-64
  - https://repo.anaconda.com/pkgs/r/noarch

To search for alternate channels that may provide the conda package you're looking for, navigate to
https://anaconda.org
and use the search bar at the top of the page.
CorentinJ commented 4 years ago

Thank you for reporting that, I believe this is due to your matplotlib version mismatching mine. I have 3.1.1, what is yours (pip freeze | grep matplotlib)?

marcoippolito commented 4 years ago

Solved that problem by installing matplotlib (version 3.1.1) (I discovered it was not installed). But now got new issue:

(Resemblyzer) marco@pc:~/Resemblyzer$ python3 demo02_diarization.py
Traceback (most recent call last):
  File "/home/marco/Resemblyzer/Resemblyzer/lib/python3.7/site-packages/librosa
/core/audio.py", line 127, in load
    with sf.SoundFile(path) as sf_desc:
  File "/home/marco/Resemblyzer/Resemblyzer/lib/python3.7/site-packages/soundfile.py", line 
627, in __init__
    self._file = self._open(file, mode_int, closefd)
  File "/home/marco/Resemblyzer/Resemblyzer/lib/python3.7/site-packages/soundfile.py", line 
1182, in _open
    "Error opening {0!r}: ".format(self.name))
  File "/home/marco/Resemblyzer/Resemblyzer/lib/python3.7/site-packages/soundfile.py", line 
1355, in _error_check
    raise RuntimeError(prefix + _ffi.string(err_str).decode('utf-8', 'replace'))
RuntimeError: Error opening 'audio_data/X2zqiX6yL3I.mp3': File contains data in an unknown 
format.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "demo02_diarization.py", line 14, in <module>
    wav = preprocess_wav(wav_fpath)
  File "/home/marco/Resemblyzer/resemblyzer/audio.py", line 27, in preprocess_wav
    wav, source_sr = librosa.load(fpath_or_wav, sr=None)
  File "/home/marco/Resemblyzer/Resemblyzer/lib/python3.7/site-packages/librosa
/core/audio.py", line 142, in load
    y, sr_native = __audioread_load(path, offset, duration, dtype)
  File "/home/marco/Resemblyzer/Resemblyzer/lib/python3.7/site-packages/librosa
/core/audio.py", line 164, in __audioread_load
    with audioread.audio_open(path) as input_file:
  File "/home/marco/Resemblyzer/Resemblyzer/lib/python3.7/site-packages/audioread
/__init__.py", line 116, in audio_open
    raise NoBackendError()
audioread.exceptions.NoBackendError
CorentinJ commented 4 years ago

You still need to install a backend

marcoippolito commented 4 years ago
(Resemblyzer) (base) marco@pc:~/Resemblyzer$ conda install -c conda-forge audioread
Collecting package metadata (current_repodata.json): done
Solving environment: done

# All requested packages already installed.

(base) (Resemblyzer) marco@pc:~/Resemblyzer$ python3 demo02_diarization.py
Loaded the voice encoder model on cpu in 0.06 seconds.
Running the continuous embedding on cpu, this might take a while...
Traceback (most recent call last):
  File "demo02_diarization.py", line 42, in <module>
    interactive_diarization(similarity_dict, wav, wav_splits)
  File "/home/marco/Resemblyzer/demo_utils.py", line 171, in interactive_diarization
    play_wav(wav, blocking=False)
  File "/home/marco/Resemblyzer/demo_utils.py", line 35, in play_wav
    sd.play(wav, sampling_rate, blocking=blocking)
  File "/home/marco/Resemblyzer/Resemblyzer/lib/python3.7/site-packages/sounddevice.py", line
 154, in play
    **kwargs)
  File "/home/marco/Resemblyzer/Resemblyzer/lib/python3.7/site-packages/sounddevice.py", line
 2417, in start_stream
    **kwargs)
  File "/home/marco/Resemblyzer/Resemblyzer/lib/python3.7/site-packages/sounddevice.py", line
 1374, in __init__
    **_remove_self(locals()))
 File "/home/marco/Resemblyzer/Resemblyzer/lib/python3.7/site-packages/sounddevice.py", line 
697, in __init__
    extra_settings, samplerate)
  File "/home/marco/Resemblyzer/Resemblyzer/lib/python3.7/site-packages/sounddevice.py", line 
2490, in _get_stream_parameters
    info = query_devices(device)
  File "/home/marco/Resemblyzer/Resemblyzer/lib/python3.7/site-packages/sounddevice.py", line 
488, in query_devices
    raise PortAudioError('Error querying device {0}'.format(device))
sounddevice.PortAudioError: Error querying device -1
CorentinJ commented 4 years ago

Good catch, you will either need to put an audio output device or disable the calls to sd.play in demo_utils. I'll fix that later

CorentinJ commented 4 years ago

With cdd51df126dc5304a04ad6b01ca0811575c8809b, you should now be fine. It should only print an error when trying to play the audio but the program should work.

yunfei-shi commented 4 years ago

I solve it by install ffmpeg on ubuntu18.04: sudo apt install ffmpeg.