jone commited on
Commit
0b1a866
1 Parent(s): 915d50b
Files changed (1) hide show
  1. app.py +9 -5
app.py CHANGED
@@ -16,13 +16,17 @@ os.system('./separate_scripts/download_checkpoints.sh')
16
  def inference(audio):
17
  input_path = audio.name
18
  print(f"The audio file name is: {audio.name}")
19
- if input_path.endswith(".mp3"):
20
- output_path = os.path.splitext(input_path)[0] + ".wav"
21
- os.system(f"ffmpeg -y -loglevel panic -i {input_path} -acodec pcm_s16le -ar 44100 {output_path}")
22
- input_path = output_path
23
 
24
  # read the file and get the sample rate and data
25
- rate, data = wavfile.read(input_path)
 
 
 
 
 
 
26
 
27
  # save the result
28
  wavfile.write('foo_left.wav', rate, data)
 
16
  def inference(audio):
17
  input_path = audio.name
18
  print(f"The audio file name is: {audio.name}")
19
+ output_path = os.path.splitext(input_path)[0] + ".wav"
20
+ os.system(f"ffmpeg -y -loglevel panic -i {input_path} -acodec pcm_s16le -ar 44100 {output_path}")
 
 
21
 
22
  # read the file and get the sample rate and data
23
+ # rate, data = wavfile.read(output_path)
24
+ try:
25
+ # try to read the file and get the sample rate and data
26
+ rate, data = wavfile.read(output_path)
27
+ except:
28
+ # if an exception occurs, read the original file instead
29
+ rate, data = wavfile.read(input_path)
30
 
31
  # save the result
32
  wavfile.write('foo_left.wav', rate, data)