cdleong commited on
Commit
74e2a8d
·
1 Parent(s): 87d6449

More informative mp3 conversion outputs

Browse files
Files changed (1) hide show
  1. app.py +6 -4
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
- st.info(new_desired_path)
 
 
38
  waveform, sample_rate = torchaudio.load(actual_file_path)
39
- st.info(f"waveform, sample_rate: {waveform}, {sample_rate}")
40
  torchaudio.save(new_desired_path, waveform, sample_rate,
41
- 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
42
- bits_per_sample=16,
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