rajistics commited on
Commit
3a9502d
1 Parent(s): 154709a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -15
app.py CHANGED
@@ -1,10 +1,10 @@
1
  import os
2
- import re
3
- import functools
4
- from functools import partial
5
 
6
- import requests
7
- import pandas as pd
8
 
9
  import torch
10
  import gradio as gr
@@ -18,8 +18,6 @@ from utils import speech_to_text as stt
18
  os.environ["TOKENIZERS_PARALLELISM"] = "false"
19
  device = 0 if torch.cuda.is_available() else -1
20
 
21
- # display if the sentiment value is above these thresholds
22
- #thresholds = {"joy": 0.99,"anger": 0.95,"surprise": 0.95,"sadness": 0.98,"fear": 0.95,"love": 0.99,}
23
  color_map = {"joy": "green","anger": "red","surprise": "yellow","sadness": "blue","fear": "orange","love": "purple",}
24
 
25
  # Audio components
@@ -63,9 +61,7 @@ def sentiment(diarized, emotion_pipeline):
63
  if "Customer" in speaker_id:
64
  outputs = emotion_pipeline(sentences)
65
  for idx, (o, t) in enumerate(zip(outputs, sentences)):
66
- # if o["score"] > thresholds[o["label"]]:
67
  customer_sentiments.append((t, o["label"]))
68
-
69
  return customer_sentiments
70
 
71
  EXAMPLES = [["Customer_Support_Call.wav"]]
@@ -95,14 +91,9 @@ with gr.Blocks() as demo:
95
  cache_examples=True
96
  )
97
  # when example button is clicked, convert audio file to text and diarize
98
- btn.click(
99
- fn=speech_to_text,
100
- inputs=audio,
101
- outputs=diarized,
102
- )
103
  # when summarize checkboxes are changed, create summary
104
  sum_btn.click(fn=partial(summarize, summarization_pipeline=summarization_pipeline), inputs=[diarized], outputs=summary)
105
-
106
  # when sentiment button clicked, display highlighted text and plot
107
  sentiment_btn.click(fn=partial(sentiment, emotion_pipeline=emotion_pipeline), inputs=diarized, outputs=[analyzed])
108
 
 
1
  import os
2
+ #import re
3
+ #import functools
4
+ #from functools import partial
5
 
6
+ #import requests
7
+ #import pandas as pd
8
 
9
  import torch
10
  import gradio as gr
 
18
  os.environ["TOKENIZERS_PARALLELISM"] = "false"
19
  device = 0 if torch.cuda.is_available() else -1
20
 
 
 
21
  color_map = {"joy": "green","anger": "red","surprise": "yellow","sadness": "blue","fear": "orange","love": "purple",}
22
 
23
  # Audio components
 
61
  if "Customer" in speaker_id:
62
  outputs = emotion_pipeline(sentences)
63
  for idx, (o, t) in enumerate(zip(outputs, sentences)):
 
64
  customer_sentiments.append((t, o["label"]))
 
65
  return customer_sentiments
66
 
67
  EXAMPLES = [["Customer_Support_Call.wav"]]
 
91
  cache_examples=True
92
  )
93
  # when example button is clicked, convert audio file to text and diarize
94
+ btn.click(fn=speech_to_text, inputs=audio, outputs=diarized)
 
 
 
 
95
  # when summarize checkboxes are changed, create summary
96
  sum_btn.click(fn=partial(summarize, summarization_pipeline=summarization_pipeline), inputs=[diarized], outputs=summary)
 
97
  # when sentiment button clicked, display highlighted text and plot
98
  sentiment_btn.click(fn=partial(sentiment, emotion_pipeline=emotion_pipeline), inputs=diarized, outputs=[analyzed])
99