File size: 2,846 Bytes
36f1349
adf1205
5650727
 
b91b901
adf1205
 
4631e13
32c34a8
 
 
 
 
9ae2604
1c763ac
89615e5
b995d34
89615e5
b91b901
89615e5
 
 
 
5650727
adf1205
 
6b5ce4a
adf1205
 
 
 
 
 
004be7e
1829484
adf1205
 
 
 
77b5e94
7f2009a
004be7e
1bb805a
6b5ce4a
004be7e
4631e13
6eb3fe4
4631e13
 
075f4a5
4631e13
32c34a8
d25a92c
6b5ce4a
adf1205
004be7e
 
77b5e94
 
adf1205
 
004be7e
 
 
adf1205
004be7e
 
 
 
adf1205
 
6b5ce4a
adf1205
 
 
 
 
5650727
adf1205
5650727
 
b91b901
adf1205
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import gradio as gr 
from utilities.setup import get_files
#import spaces
from services.diarization import Diarizer
from services.asr import Transcriber

#@spaces.GPU
def process_meeting(audio_input, num_speakers, speaker_names):
    """
    audio_input: filepath --> str
    num_speakers: number --> int
    speaker_names: dataset --> np.array
    """
    
    print(audio_input) 
    # first, pass it through a diarization stage.
    diarization_result, label_file = diarizer.run(audio_input, num_speakers)
    # Next, pass it through a transctiption stage
    transcriber.run(audio_input)
    # After, match the diarization with the transcription

    # Finally, Clean up the docs.

    return diarization_result, label_file



def main(conf):

    with gr.Blocks(theme=gr.themes.Soft(text_size="lg")) as demo:
    
        with gr.TabItem(conf["layout"]["page_names"][0]):
            
            gr.Markdown("# 🎀 Non-Video Meeting Transcription and Speaker Diarization")
            gr.Markdown("![](file/microphone_pen_and_paper.png)")
            gr.Markdown(get_files.load_markdown_file(conf["layout"]["about"]))
        

        with gr.TabItem(conf["layout"]["page_names"][1]):
            gr.Markdown("# πŸ”Š Upload or record your meeting")
            audio_input = gr.Audio(type="filepath", label="Upload Audio File")
            num_speakers = gr.Dropdown(list(range(conf["session"]["min_speakers"], 
                                                  conf["session"]["max_speakers"])),
                                       label="Number of Speakers", 
                                       value=conf["session"]["min_speakers"])
            speaker_names = gr.Dataframe(
                label="Type your names and details. Your actual entries will be limited to the speakers you selected above.",
                headers=["Name", "Supporting Details"],
                datatype=["str", "str"],
                row_count=(5,"fixed"),
                col_count=(2, "fixed"),
                type="pandas"
            )

            process_button = gr.Button("Process")

            
        with gr.TabItem(conf["layout"]["page_names"][2]):
            gr.Markdown("# πŸ”Š View and download your meeting transcript")
            diarization_output = gr.Textbox(label="Diarization Output")
            label_file_link = gr.File(label="Download DAW Labels")


        # Process
        
        process_button.click(
            fn=process_meeting,
            inputs=[audio_input, num_speakers, speaker_names],
            outputs=[diarization_output, label_file_link]
        )

    demo.launch(server_name="0.0.0.0", allowed_paths=["/"])




if __name__ == "__main__":
    # get config
    conf = get_files.json_cfg()
    # initialize diarizer
    diarizer = Diarizer(conf)
    transcriber = Transcriber(conf)
    main(conf)