Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
@@ -52,22 +52,16 @@ speech_to_text = partial(
|
|
52 |
whisper_device=whisper_device
|
53 |
)
|
54 |
|
55 |
-
def summarize(diarized,
|
56 |
"""
|
57 |
diarized: a list of tuples. Each tuple has a string to be displayed and a label for highlighting.
|
58 |
The start/end times are not highlighted [(speaker text, speaker id), (start time/end time, None)]
|
59 |
check is a list of speaker ids whose speech will get summarized
|
60 |
"""
|
61 |
|
62 |
-
if len(check) == 0:
|
63 |
-
return ""
|
64 |
-
|
65 |
text = ""
|
66 |
for d in diarized:
|
67 |
-
|
68 |
-
text += f"\n{d[1]}: {d[0]}"
|
69 |
-
elif d[1] in check:
|
70 |
-
text += f"\n{d[0]}"
|
71 |
|
72 |
# inner function cached because outer function cannot be cached
|
73 |
@functools.lru_cache(maxsize=128)
|
@@ -122,10 +116,8 @@ with gr.Blocks() as demo:
|
|
122 |
|
123 |
gr.Markdown("**Call Transcript:**")
|
124 |
diarized = gr.HighlightedText(label="Call Transcript")
|
125 |
-
gr.Markdown("
|
126 |
-
|
127 |
-
choices=["Customer", "Support"], show_label=False, type="value"
|
128 |
-
)
|
129 |
summary = gr.Textbox(lines=4)
|
130 |
sentiment_btn = gr.Button("Get Customer Sentiment")
|
131 |
analyzed = gr.HighlightedText(color_map=color_map)
|
@@ -146,7 +138,7 @@ with gr.Blocks() as demo:
|
|
146 |
outputs=diarized,
|
147 |
)
|
148 |
# when summarize checkboxes are changed, create summary
|
149 |
-
|
150 |
|
151 |
# when sentiment button clicked, display highlighted text and plot
|
152 |
sentiment_btn.click(fn=partial(sentiment, emotion_pipeline=emotion_pipeline), inputs=diarized, outputs=[analyzed])
|
|
|
52 |
whisper_device=whisper_device
|
53 |
)
|
54 |
|
55 |
+
def summarize(diarized, summarization_pipeline):
|
56 |
"""
|
57 |
diarized: a list of tuples. Each tuple has a string to be displayed and a label for highlighting.
|
58 |
The start/end times are not highlighted [(speaker text, speaker id), (start time/end time, None)]
|
59 |
check is a list of speaker ids whose speech will get summarized
|
60 |
"""
|
61 |
|
|
|
|
|
|
|
62 |
text = ""
|
63 |
for d in diarized:
|
64 |
+
text += f"\n{d[1]}: {d[0]}"
|
|
|
|
|
|
|
65 |
|
66 |
# inner function cached because outer function cannot be cached
|
67 |
@functools.lru_cache(maxsize=128)
|
|
|
116 |
|
117 |
gr.Markdown("**Call Transcript:**")
|
118 |
diarized = gr.HighlightedText(label="Call Transcript")
|
119 |
+
gr.Markdown("Summarize Speaker")
|
120 |
+
sum_btn = gr.Button("Get Summary")
|
|
|
|
|
121 |
summary = gr.Textbox(lines=4)
|
122 |
sentiment_btn = gr.Button("Get Customer Sentiment")
|
123 |
analyzed = gr.HighlightedText(color_map=color_map)
|
|
|
138 |
outputs=diarized,
|
139 |
)
|
140 |
# when summarize checkboxes are changed, create summary
|
141 |
+
sum_btn.click(fn=partial(summarize, summarization_pipeline=summarization_pipeline), inputs=[diarized], outputs=summary)
|
142 |
|
143 |
# when sentiment button clicked, display highlighted text and plot
|
144 |
sentiment_btn.click(fn=partial(sentiment, emotion_pipeline=emotion_pipeline), inputs=diarized, outputs=[analyzed])
|