File size: 1,088 Bytes
b36aae4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import gradio as gr

speakers = [
    "Speaker 1",
    "Speaker 2",
]

def format_speaker(speaker, text):
    return f"{speaker}: {text}"

def mock_diarization(audio):
    return [
        {
            "speaker": "Speaker 1",
            "text": "Hello, how are you?",
        },
        {
            "speaker": "Speaker 2",
            "text": "I'm fine, thank you!",
        },
        {
            "speaker": "Speaker 1",
            "text": "What's your name?",
        },
        {
            "speaker": "Speaker 2",
            "text": "My name is John Doe.",
        },
        {
            "speaker": "Speaker 1",
            "text": "Nice to meet you!",
        },
        {
            "speaker": "Speaker 2",
            "text": "Nice to meet you!",
        },
    ]

demo = gr.Interface(
    fn=mock_diarization,
    inputs=[gr.Audio(sources=["microphone"])],
    outputs=[gr.Dialogue(speakers=speakers, tags=None, formatter=format_speaker)],
    title="Mock Speech Diarization",
    description="Mock speech diarization",
)

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