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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -7
app.py CHANGED
@@ -5,7 +5,6 @@ from functools import partial
5
 
6
  import requests
7
  import pandas as pd
8
- #import plotly.express as px
9
 
10
  import torch
11
  import gradio as gr
@@ -20,7 +19,7 @@ os.environ["TOKENIZERS_PARALLELISM"] = "false"
20
  device = 0 if torch.cuda.is_available() else -1
21
 
22
  # display if the sentiment value is above these thresholds
23
- thresholds = {"joy": 0.99,"anger": 0.95,"surprise": 0.95,"sadness": 0.98,"fear": 0.95,"love": 0.99,}
24
  color_map = {"joy": "green","anger": "red","surprise": "yellow","sadness": "blue","fear": "orange","love": "purple",}
25
 
26
  # Audio components
@@ -42,19 +41,16 @@ speech_to_text = partial(
42
  emotion_pipeline = pipeline(
43
  "text-classification",
44
  model="bhadresh-savani/distilbert-base-uncased-emotion",
45
- #device=device,
46
  )
47
  summarization_pipeline = pipeline(
48
  "summarization",
49
  model="knkarthick/MEETING_SUMMARY",
50
- #device=device
51
  )
52
 
53
  def summarize(diarized, summarization_pipeline):
54
  text = ""
55
  for d in diarized:
56
  text += f"\n{d[1]}: {d[0]}"
57
-
58
  return summarization_pipeline(text)[0]["summary_text"]
59
 
60
  def sentiment(diarized, emotion_pipeline):
@@ -67,8 +63,8 @@ def sentiment(diarized, emotion_pipeline):
67
  if "Customer" in speaker_id:
68
  outputs = emotion_pipeline(sentences)
69
  for idx, (o, t) in enumerate(zip(outputs, sentences)):
70
- if o["score"] > thresholds[o["label"]]:
71
- customer_sentiments.append((t, o["label"]))
72
 
73
  return customer_sentiments
74
 
 
5
 
6
  import requests
7
  import pandas as pd
 
8
 
9
  import torch
10
  import gradio as gr
 
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
 
41
  emotion_pipeline = pipeline(
42
  "text-classification",
43
  model="bhadresh-savani/distilbert-base-uncased-emotion",
 
44
  )
45
  summarization_pipeline = pipeline(
46
  "summarization",
47
  model="knkarthick/MEETING_SUMMARY",
 
48
  )
49
 
50
  def summarize(diarized, summarization_pipeline):
51
  text = ""
52
  for d in diarized:
53
  text += f"\n{d[1]}: {d[0]}"
 
54
  return summarization_pipeline(text)[0]["summary_text"]
55
 
56
  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