Spaces:
Running
on
Zero
Running
on
Zero
File size: 1,589 Bytes
8919734 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
import gradio as gr
from gryannote_audio import AudioLabeling
from gryannote_pipeline import PipelineSelector
from gryannote_rttm import RTTM
from pyannote.audio import Pipeline
import os
def apply_pipeline(pipeline: Pipeline, audio):
"""Apply specified pipeline on the indicated audio file"""
annotations = pipeline(audio)
return ((audio, annotations), (audio, annotations))
def update_annotations(data):
return rttm.on_edit(data)
with gr.Blocks() as demo:
gr.Markdown(
"[Gryannote](): The [pyannote](https://github.com/pyannote/pyannote-audio) audio labeling tool"
)
pipeline_selector = PipelineSelector(token=os.environ["HF_TOKEN"])
pipeline_selector.select(
fn=pipeline_selector.on_select,
inputs=pipeline_selector,
outputs=pipeline_selector,
preprocess=False,
postprocess=False,
)
pipeline_selector.change(
fn=pipeline_selector.on_change,
inputs=pipeline_selector,
outputs=pipeline_selector,
preprocess=False,
postprocess=False,
)
audio_labeling = AudioLabeling(
type="filepath",
interactive=True,
)
run_btn = gr.Button("Run pipeline")
rttm = RTTM()
audio_labeling.edit(
fn=update_annotations,
inputs=audio_labeling,
outputs=rttm,
preprocess=False,
postprocess=False,
)
run_btn.click(
fn=apply_pipeline,
inputs=[pipeline_selector, audio_labeling],
outputs=[audio_labeling, rttm],
)
if __name__ == "__main__":
demo.launch()
|