amirgame197 commited on
Commit
cf9f7d3
·
verified ·
1 Parent(s): 1e7b2dd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -9
app.py CHANGED
@@ -22,22 +22,25 @@ def separate_audio(audio_path, stem_count):
22
  randomnumber = str(random.randint(111111111, 999999999))
23
  paths = []
24
  if stem_count == 2:
25
- paths.append(('Accompaniment', f"{gradio_temp_path}/separated_audio/{randomnumber}/accompaniment.wav"))
26
- paths.append(('Vocals', f"{gradio_temp_path}/separated_audio/{randomnumber}/vocals.wav"))
27
  elif stem_count == 4 or stem_count == 5:
28
- paths.append(('Vocals', f"{gradio_temp_path}/separated_audio/{randomnumber}/vocals.wav"))
29
- paths.append(('Drums', f"{gradio_temp_path}/separated_audio/{randomnumber}/drums.wav"))
30
- paths.append(('Bass', f"{gradio_temp_path}/separated_audio/{randomnumber}/bass.wav"))
31
- paths.append(('Other', f"{gradio_temp_path}/separated_audio/{randomnumber}/other.wav"))
32
  if stem_count == 5:
33
- paths.append(('Piano', f"{gradio_temp_path}/separated_audio/{randomnumber}/piano.wav"))
34
 
35
- return paths
 
36
 
 
37
  iface = gr.Interface(
38
  fn=separate_audio,
39
  inputs=[gr.Audio(type="filepath"), gr.Radio([2, 4, 5])],
40
- outputs="text",
41
  )
42
 
 
43
  iface.launch()
 
22
  randomnumber = str(random.randint(111111111, 999999999))
23
  paths = []
24
  if stem_count == 2:
25
+ paths.append(gradio_temp_path + f"/separated_audio/{randomnumber}/accompaniment.wav")
26
+ paths.append(gradio_temp_path + f"/separated_audio/{randomnumber}/vocals.wav")
27
  elif stem_count == 4 or stem_count == 5:
28
+ paths.append(gradio_temp_path + f"/separated_audio/{randomnumber}/vocals.wav")
29
+ paths.append(gradio_temp_path + f"/separated_audio/{randomnumber}/drums.wav")
30
+ paths.append(gradio_temp_path + f"/separated_audio/{randomnumber}/bass.wav")
31
+ paths.append(gradio_temp_path + f"/separated_audio/{randomnumber}/other.wav")
32
  if stem_count == 5:
33
+ paths.append(gradio_temp_path + f"/separated_audio/{randomnumber}/piano.wav")
34
 
35
+ # Return the audio file paths as a list of Audio components
36
+ return [gr.Audio(file_path=path) for path in paths]
37
 
38
+ # Define the Gradio interface
39
  iface = gr.Interface(
40
  fn=separate_audio,
41
  inputs=[gr.Audio(type="filepath"), gr.Radio([2, 4, 5])],
42
+ outputs=[gr.Audio(label='Accompaniment'), gr.Audio(label='Vocals'), gr.Audio(label='Drums'), gr.Audio(label='Bass'), gr.Audio(label='Other'), gr.Audio(label='Piano')]
43
  )
44
 
45
+ # Launch the interface
46
  iface.launch()