Spaces:
Running
on
Zero
Running
on
Zero
import gradio as gr | |
import os | |
from pyannote.audio import Pipeline | |
# instantiate the pipeline | |
pipeline = Pipeline.from_pretrained( | |
"pyannote/speaker-diarization-3.1", | |
use_auth_token=os.environ["api"]) | |
def process_audio(audio): | |
# Read the uploaded audio file | |
with open(audio, "rb") as f: | |
audio_data = f.read() | |
# Save the uploaded audio file to a temporary location | |
with open("temp.wav", "wb") as f: | |
f.write(audio_data) | |
# Use the diarization pipeline to process the audio | |
diarization = pipeline("temp.wav") | |
# Remove the temporary file | |
os.remove("temp.wav") | |
# Return the diarization output | |
return str(diarization) | |
with gr.Blocks() as demo: | |
audio_input = gr.Audio(type="filepath", label="Upload Audio") | |
process_button = gr.Button("Process") | |
diarization_output = gr.Textbox(label="Diarization Output") | |
process_button.click(fn=process_audio, inputs=audio_input, outputs=diarization_output) | |
demo.launch() |