File size: 5,104 Bytes
bebf963
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5d9b7cd
 
bebf963
 
 
 
 
5d9b7cd
 
 
 
 
 
 
 
 
 
 
 
bebf963
9894ee6
bebf963
3cf9c24
bebf963
 
 
3cf9c24
 
bebf963
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1ca9d41
5d9b7cd
3cf9c24
5d9b7cd
1ca9d41
5d9b7cd
 
508c01a
5d9b7cd
 
 
508c01a
5d9b7cd
 
bebf963
508c01a
5d9b7cd
 
eafa8de
5d9b7cd
bebf963
508c01a
5d9b7cd
 
 
508c01a
a9cdc56
5d9b7cd
 
508c01a
a9cdc56
3313bb3
 
 
 
1ca9d41
3313bb3
 
 
1ca9d41
3313bb3
 
 
1ca9d41
3313bb3
bebf963
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
import os
os.system("pip install gradio==3.0.18")
from transformers import pipeline, AutoTokenizer, AutoModelForSequenceClassification, AutoModelForTokenClassification
import gradio as gr
import spacy
nlp = spacy.load('en_core_web_sm')
nlp.add_pipe('sentencizer')

def split_in_sentences(text):
    doc = nlp(text)
    return [str(sent).strip() for sent in doc.sents]

def make_spans(text,results):
    results_list = []
    for i in range(len(results)):
        results_list.append(results[i]['label'])
    facts_spans = []
    facts_spans = list(zip(split_in_sentences(text),results_list))
    return facts_spans
    
auth_token = os.environ.get("HF_Token")

##Speech Recognition
asr = pipeline("automatic-speech-recognition", "facebook/wav2vec2-base-960h")
def transcribe(audio):
    text = asr(audio)["text"]
    return text
def speech_to_text(speech):
    text = asr(speech)["text"]
    return text

##Summarization
summarizer = pipeline("summarization", model="knkarthick/MEETING-SUMMARY-BART-LARGE-XSUM-SAMSUM-DIALOGSUM")
def summarize_text(text):
    resp = summarizer(text)
    stext = resp[0]['summary_text']
    return stext

summarizer1 = pipeline("summarization", model="knkarthick/MEETING_SUMMARY")
def summarize_text1(text):
    resp = summarizer1(text)
    stext = resp[0]['summary_text']
    return stext

summarizer2 = pipeline("summarization", model="knkarthick/MEETING-SUMMARY-BART-LARGE-XSUM-SAMSUM-DIALOGSUM-AMI")
def summarize_text2(text):
    resp = summarizer2(text)
    stext = resp[0]['summary_text']
    return stext

##Fiscal Tone Analysis
sen_model= pipeline("sentiment-analysis", model='knkarthick/Sentiment-Analysis', tokenizer='knkarthick/Sentiment-Analysis')
def text_to_sentiment(text):
    sentiment = sen_model(text)[0]["label"]
    return sentiment     

##Fiscal Sentiment by Sentence
def sen_ext(text):
    results = sen_model(split_in_sentences(text))
    return make_spans(text,results)

demo = gr.Blocks()

with demo:
    gr.Markdown("## Meeting Transcript AI Use Cases")
    gr.Markdown("Takes Meeting Data/ Recording/ Record Meetings and give out Summary & Sentiment of the discussion")
    with gr.Row():
        with gr.Column():
            audio_file = gr.inputs.Audio(source="microphone", type="filepath")
            with gr.Row():
                b1 = gr.Button("Recognize Speech") 
            with gr.Row():
                text = gr.Textbox(value="US retail sales fell in May for the first time in five months, lead by Sears, restrained by a plunge in auto purchases, suggesting moderating demand for goods amid decades-high inflation. The value of overall retail purchases decreased 0.3%, after a downwardly revised 0.7% gain in April, Commerce Department figures showed Wednesday. Excluding Tesla vehicles, sales rose 0.5% last month. The department expects inflation to continue to rise.")
                b1.click(speech_to_text, inputs=audio_file, outputs=text)
            with gr.Row():
                b2 = gr.Button("Overall Sentiment Analysis of Dialogues")
                fin_spans = gr.HighlightedText()
                b2.click(sen_ext, inputs=text, outputs=fin_spans) 
    with gr.Row():
        b3 = gr.Button("Summary Text Outputs")
        with gr.Column():
            with gr.Row():
                stext = gr.Textbox(label="Model-I")
                b3.click(summarize_text, inputs=text, outputs=stext)
        with gr.Column():
            with gr.Row():
                stext1 = gr.Textbox(label="Model-II")
                b3.click(summarize_text1, inputs=text, outputs=stext1)
        with gr.Column():
            with gr.Row():
                stext2 = gr.Textbox(label="Model-III")
                b3.click(summarize_text2, inputs=text, outputs=stext2)
    with gr.Row():
        b4 = gr.Button("Sentiment Analysis")
        with gr.Column():
            with gr.Row():
                label = gr.Label(label="Sentiment Of Summary-I")
                b4.click(text_to_sentiment, inputs=stext, outputs=label)
        with gr.Column():
            with gr.Row():
                label1 = gr.Label(label="Sentiment Of Summary-II")
                b4.click(text_to_sentiment, inputs=stext1, outputs=label1)
        with gr.Column():
            with gr.Row():
                label2 = gr.Label(label="Sentiment Of Summary-III")
                b4.click(text_to_sentiment, inputs=stext2, outputs=label2)
    with gr.Row():
        b5 = gr.Button("Dialogue Sentiment Analysis")
        with gr.Column():
            with gr.Row():
                fin_spans = gr.HighlightedText(label="Sentiment Of Summary-I Dialogues")
                b5.click(sen_ext, inputs=stext, outputs=fin_spans)
        with gr.Column():
            with gr.Row():
                fin_spans1 = gr.HighlightedText(label="Sentiment Of Summary-II Dialogues")
                b5.click(sen_ext, inputs=stext1, outputs=fin_spans1)
        with gr.Column():
            with gr.Row():
                fin_spans2 = gr.HighlightedText(label="Sentiment Of Summary-III Dialogues")
                b5.click(sen_ext, inputs=stext2, outputs=fin_spans2)
demo.launch()