File size: 846 Bytes
a9b52e3
074b1c4
50c57e9
 
 
 
 
f0061fc
 
 
 
50c57e9
f0061fc
50c57e9
f0061fc
 
 
 
 
 
 
a9b52e3
 
50c57e9
 
 
074b1c4
a9b52e3
074b1c4
a9b52e3
 
 
 
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
import gradio as gr
from pyannote_viewer import PyannoteViewer
from pyannote.audio import Pipeline
import os


def apply_pipeline(audio: str) -> tuple:
    # pipeline = Pipeline.from_pretrained(
    #     "pyannote/speech-separation-ami-1.0", use_auth_token=os.environ["HF_TOKEN"]
    # )

    pipeline = Pipeline.from_pretrained(
        "pyannote/speaker-diarization-3.1", use_auth_token=os.environ["HF_TOKEN"]
    )


    outputs = pipeline(audio)
    if isinstance(outputs, tuple):
        return outputs
    else:
        return (outputs, audio)


with gr.Blocks() as demo:
    audio = gr.Audio(type="filepath")
    btn = gr.Button("Apply separation pipeline")
    pyannote_viewer = PyannoteViewer(interactive=False)

    btn.click(fn=apply_pipeline, inputs=[audio], outputs=[pyannote_viewer])


if __name__ == "__main__":
    demo.launch()