Spaces:
Build error
Build error
Jeremy Hummel
commited on
Commit
·
f8fb3c0
1
Parent(s):
fd93546
add support for int32 audio
Browse files- visualize.py +6 -2
visualize.py
CHANGED
@@ -41,7 +41,9 @@ def visualize(audio_file,
|
|
41 |
print(audio.dtype)
|
42 |
print(audio.shape)
|
43 |
if audio.dtype == np.int16:
|
44 |
-
audio = audio.astype(np.float32, order='C') /
|
|
|
|
|
45 |
audio = audio.T
|
46 |
audio = librosa.to_mono(audio)
|
47 |
audio = librosa.resample(audio, orig_sr=sr, target_sr=target_sr, res_type="kaiser_best")
|
@@ -185,7 +187,9 @@ def visualize(audio_file,
|
|
185 |
#Save video
|
186 |
sr, audio = audio_file
|
187 |
if audio.dtype == np.int16:
|
188 |
-
audio = audio.astype(np.float32, order='C') /
|
|
|
|
|
189 |
with AudioArrayClip(audio, sr) as aud: # from a numeric array
|
190 |
pass # Close is implicitly performed by context manager.
|
191 |
|
|
|
41 |
print(audio.dtype)
|
42 |
print(audio.shape)
|
43 |
if audio.dtype == np.int16:
|
44 |
+
audio = audio.astype(np.float32, order='C') / 2**15
|
45 |
+
elif audio.dtype == np.int32:
|
46 |
+
audio = audio.astype(np.float32, order='C') / 2**31
|
47 |
audio = audio.T
|
48 |
audio = librosa.to_mono(audio)
|
49 |
audio = librosa.resample(audio, orig_sr=sr, target_sr=target_sr, res_type="kaiser_best")
|
|
|
187 |
#Save video
|
188 |
sr, audio = audio_file
|
189 |
if audio.dtype == np.int16:
|
190 |
+
audio = audio.astype(np.float32, order='C') / 2**15
|
191 |
+
elif audio.dtype == np.int32:
|
192 |
+
audio = audio.astype(np.float32, order='C') / 2**31
|
193 |
with AudioArrayClip(audio, sr) as aud: # from a numeric array
|
194 |
pass # Close is implicitly performed by context manager.
|
195 |
|