Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -1,21 +1,20 @@
|
|
1 |
import gradio as gr
|
2 |
import os
|
3 |
-
import torch
|
4 |
-
import io
|
5 |
-
import wavio
|
6 |
-
import numpy as np
|
7 |
from pyannote.audio import Pipeline
|
8 |
-
from pyannote.audio import Audio
|
9 |
-
from pyannote.core import Segment
|
10 |
|
|
|
11 |
pipeline = Pipeline.from_pretrained(
|
12 |
"pyannote/speaker-diarization-3.1",
|
13 |
-
use_auth_token=
|
14 |
|
15 |
def process_audio(audio):
|
|
|
|
|
|
|
|
|
16 |
# Save the uploaded audio file to a temporary location
|
17 |
with open("temp.wav", "wb") as f:
|
18 |
-
f.write(
|
19 |
|
20 |
# Use the diarization pipeline to process the audio
|
21 |
diarization = pipeline("temp.wav")
|
@@ -24,7 +23,7 @@ def process_audio(audio):
|
|
24 |
os.remove("temp.wav")
|
25 |
|
26 |
# Return the diarization output
|
27 |
-
return diarization
|
28 |
|
29 |
with gr.Blocks() as demo:
|
30 |
audio_input = gr.Audio(type="filepath", label="Upload Audio")
|
|
|
1 |
import gradio as gr
|
2 |
import os
|
|
|
|
|
|
|
|
|
3 |
from pyannote.audio import Pipeline
|
|
|
|
|
4 |
|
5 |
+
# instantiate the pipeline
|
6 |
pipeline = Pipeline.from_pretrained(
|
7 |
"pyannote/speaker-diarization-3.1",
|
8 |
+
use_auth_token="HUGGINGFACE_ACCESS_TOKEN_GOES_HERE")
|
9 |
|
10 |
def process_audio(audio):
|
11 |
+
# Read the uploaded audio file
|
12 |
+
with open(audio, "rb") as f:
|
13 |
+
audio_data = f.read()
|
14 |
+
|
15 |
# Save the uploaded audio file to a temporary location
|
16 |
with open("temp.wav", "wb") as f:
|
17 |
+
f.write(audio_data)
|
18 |
|
19 |
# Use the diarization pipeline to process the audio
|
20 |
diarization = pipeline("temp.wav")
|
|
|
23 |
os.remove("temp.wav")
|
24 |
|
25 |
# Return the diarization output
|
26 |
+
return str(diarization)
|
27 |
|
28 |
with gr.Blocks() as demo:
|
29 |
audio_input = gr.Audio(type="filepath", label="Upload Audio")
|