Delik commited on
Commit
76efec6
1 Parent(s): f60dd49

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -7
app.py CHANGED
@@ -11,20 +11,26 @@ pipeline = Pipeline.from_pretrained(
11
  "pyannote/speaker-diarization-3.1",
12
  use_auth_token=os.environ['api'])
13
 
14
-
15
-
16
- def process_audio(audio):
17
- # Use the diarization pipeline to process the audio
18
- diarization = pipeline(audio)
 
 
 
 
 
 
19
 
20
  # Return the diarization output
21
  return diarization
22
 
23
  with gr.Blocks() as demo:
24
- audio_input = gr.Audio(label="Upload Audio") # Remove source="upload"
25
  process_button = gr.Button("Process")
26
  diarization_output = gr.JSON(label="Diarization Output")
27
 
28
  process_button.click(fn=process_audio, inputs=audio_input, outputs=diarization_output)
29
 
30
- demo.launch()
 
11
  "pyannote/speaker-diarization-3.1",
12
  use_auth_token=os.environ['api'])
13
 
14
+ def process_audio(audio_file):
15
+ # Save the uploaded audio file to a temporary location
16
+ temp_file = "temp_audio.wav"
17
+ with open(temp_file, "wb") as f:
18
+ f.write(audio_file.read())
19
+
20
+ # Use the diarization pipeline to process the audio file
21
+ diarization = pipeline(temp_file)
22
+
23
+ # Remove the temporary file
24
+ os.remove(temp_file)
25
 
26
  # Return the diarization output
27
  return diarization
28
 
29
  with gr.Blocks() as demo:
30
+ audio_input = gr.File(label="Upload Audio", file_types=["audio"])
31
  process_button = gr.Button("Process")
32
  diarization_output = gr.JSON(label="Diarization Output")
33
 
34
  process_button.click(fn=process_audio, inputs=audio_input, outputs=diarization_output)
35
 
36
+ demo.launch()