Skip to content

Commit c524fd8

Browse files
correct librosa import
1 parent 62b497c commit c524fd8

File tree

1 file changed

+16
-1
lines changed
  • src/diffusers/pipelines/audio_diffusion

1 file changed

+16
-1
lines changed

src/diffusers/pipelines/audio_diffusion/mel.py

+16-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,19 @@
2323

2424
import numpy as np # noqa: E402
2525

26-
import librosa # noqa: E402
26+
27+
try:
28+
import librosa # noqa: E402
29+
30+
_librosa_can_be_imported = True
31+
_import_error = ""
32+
except Exception as e:
33+
_librosa_can_be_imported = False
34+
_import_error = (
35+
f"Cannot import librosa because {e}. Make sure to correctly install librosa to be able to install it."
36+
)
37+
38+
2739
from PIL import Image # noqa: E402
2840

2941

@@ -60,6 +72,9 @@ def __init__(
6072
self.set_resolution(x_res, y_res)
6173
self.audio = None
6274

75+
if not _librosa_can_be_imported:
76+
raise ValueError(_import_error)
77+
6378
def set_resolution(self, x_res: int, y_res: int):
6479
"""Set resolution.
6580

0 commit comments

Comments
 (0)