Spaces:
Runtime error
Runtime error
More informative mp3 conversion outputs
Browse files
app.py
CHANGED
@@ -34,12 +34,14 @@ def get_path_to_wav_format(uploaded_file):
|
|
34 |
return Path(uploaded_file.name)
|
35 |
if ".mp3" in uploaded_file.name:
|
36 |
new_desired_path = actual_file_path.with_suffix(".wav")
|
37 |
-
|
|
|
|
|
38 |
waveform, sample_rate = torchaudio.load(actual_file_path)
|
39 |
-
st.info(f"
|
40 |
torchaudio.save(new_desired_path, waveform, sample_rate,
|
41 |
-
encoding=
|
42 |
-
bits_per_sample=
|
43 |
)
|
44 |
|
45 |
return new_desired_path
|
|
|
34 |
return Path(uploaded_file.name)
|
35 |
if ".mp3" in uploaded_file.name:
|
36 |
new_desired_path = actual_file_path.with_suffix(".wav")
|
37 |
+
encoding="PCM_S" # Prevent encoding errors. https://stackoverflow.com/questions/60352850/wave-error-unknown-format-3-arises-when-trying-to-convert-a-wav-file-into-text
|
38 |
+
bits_per_sample=16
|
39 |
+
st.info("Allosaurus requires .wav files. Converting with torchaudio, encoding={encoding}, bits_per_sample={bits_per_sample}")
|
40 |
waveform, sample_rate = torchaudio.load(actual_file_path)
|
41 |
+
st.info(f"Uploaded file sample_rate: {sample_rate}")
|
42 |
torchaudio.save(new_desired_path, waveform, sample_rate,
|
43 |
+
encoding=encoding,
|
44 |
+
bits_per_sample=bits_per_sample,
|
45 |
)
|
46 |
|
47 |
return new_desired_path
|