Delik commited on
Commit
ce1f6bf
1 Parent(s): 090acab

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -3
app.py CHANGED
@@ -14,7 +14,7 @@ except Exception as e:
14
  pipeline = None
15
 
16
  @spaces.GPU
17
- def process_audio(audio):
18
  if pipeline is None:
19
  return "Error: Pipeline not initialized"
20
 
@@ -28,7 +28,15 @@ def process_audio(audio):
28
 
29
  # Use the diarization pipeline to process the audio
30
  try:
31
- diarization = pipeline("temp.wav")
 
 
 
 
 
 
 
 
32
  except Exception as e:
33
  return f"Error processing audio: {e}"
34
 
@@ -40,9 +48,12 @@ def process_audio(audio):
40
 
41
  with gr.Blocks() as demo:
42
  audio_input = gr.Audio(type="filepath", label="Upload Audio")
 
 
 
43
  process_button = gr.Button("Process")
44
  diarization_output = gr.Textbox(label="Diarization Output")
45
 
46
- process_button.click(fn=process_audio, inputs=audio_input, outputs=diarization_output)
47
 
48
  demo.launch()
 
14
  pipeline = None
15
 
16
  @spaces.GPU
17
+ def process_audio(audio, num_speakers, min_speakers, max_speakers):
18
  if pipeline is None:
19
  return "Error: Pipeline not initialized"
20
 
 
28
 
29
  # Use the diarization pipeline to process the audio
30
  try:
31
+ params = {}
32
+ if num_speakers > 0:
33
+ params["num_speakers"] = num_speakers
34
+ if min_speakers > 0:
35
+ params["min_speakers"] = min_speakers
36
+ if max_speakers > 0:
37
+ params["max_speakers"] = max_speakers
38
+
39
+ diarization = pipeline("temp.wav", **params)
40
  except Exception as e:
41
  return f"Error processing audio: {e}"
42
 
 
48
 
49
  with gr.Blocks() as demo:
50
  audio_input = gr.Audio(type="filepath", label="Upload Audio")
51
+ num_speakers_input = gr.Number(label="Number of Speakers", value=0)
52
+ min_speakers_input = gr.Number(label="Minimum Number of Speakers", value=0)
53
+ max_speakers_input = gr.Number(label="Maximum Number of Speakers", value=0)
54
  process_button = gr.Button("Process")
55
  diarization_output = gr.Textbox(label="Diarization Output")
56
 
57
+ process_button.click(fn=process_audio, inputs=[audio_input, num_speakers_input, min_speakers_input, max_speakers_input], outputs=diarization_output)
58
 
59
  demo.launch()