Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -4,30 +4,28 @@ import torch
|
|
4 |
import io
|
5 |
from pyannote.audio import Pipeline
|
6 |
from pyannote.audio import Audio
|
7 |
-
from pyannote.audio.pipelines.utils.hook import TimingHook
|
8 |
from pyannote.core import Segment
|
9 |
|
10 |
pipeline = Pipeline.from_pretrained(
|
11 |
"pyannote/speaker-diarization-3.1",
|
12 |
use_auth_token=os.environ['api'])
|
13 |
|
14 |
-
def process_audio(
|
15 |
# Save the uploaded audio file to a temporary location
|
16 |
-
|
17 |
-
|
18 |
-
f.write(audio_file.read())
|
19 |
|
20 |
-
# Use the diarization pipeline to process the audio
|
21 |
-
diarization = pipeline(
|
22 |
|
23 |
# Remove the temporary file
|
24 |
-
os.remove(
|
25 |
|
26 |
# Return the diarization output
|
27 |
return diarization
|
28 |
|
29 |
with gr.Blocks() as demo:
|
30 |
-
audio_input = gr.
|
31 |
process_button = gr.Button("Process")
|
32 |
diarization_output = gr.JSON(label="Diarization Output")
|
33 |
|
|
|
4 |
import io
|
5 |
from pyannote.audio import Pipeline
|
6 |
from pyannote.audio import Audio
|
|
|
7 |
from pyannote.core import Segment
|
8 |
|
9 |
pipeline = Pipeline.from_pretrained(
|
10 |
"pyannote/speaker-diarization-3.1",
|
11 |
use_auth_token=os.environ['api'])
|
12 |
|
13 |
+
def process_audio(audio):
|
14 |
# Save the uploaded audio file to a temporary location
|
15 |
+
with open("temp.wav", "wb") as f:
|
16 |
+
f.write(audio)
|
|
|
17 |
|
18 |
+
# Use the diarization pipeline to process the audio
|
19 |
+
diarization = pipeline("temp.wav")
|
20 |
|
21 |
# Remove the temporary file
|
22 |
+
os.remove("temp.wav")
|
23 |
|
24 |
# Return the diarization output
|
25 |
return diarization
|
26 |
|
27 |
with gr.Blocks() as demo:
|
28 |
+
audio_input = gr.Audio(label="Upload Audio")
|
29 |
process_button = gr.Button("Process")
|
30 |
diarization_output = gr.JSON(label="Diarization Output")
|
31 |
|