Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
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 |
-
|
17 |
-
|
18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
|
20 |
# Return the diarization output
|
21 |
return diarization
|
22 |
|
23 |
with gr.Blocks() as demo:
|
24 |
-
audio_input = gr.
|
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()
|