kambris commited on
Commit
98644f4
·
verified ·
1 Parent(s): 5be03e1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -4
app.py CHANGED
@@ -139,8 +139,8 @@ class SpeechAnalyzer:
139
  basic_emotions = []
140
 
141
  for segment in segments:
142
- # Get sentiment scores
143
- sentiment_result = self.sentiment_pipeline(segment)
144
  score = sentiment_result[0]['score']
145
  if sentiment_result[0]['label'] == 'POSITIVE':
146
  score = 0.5 + (score * 0.5)
@@ -148,13 +148,14 @@ class SpeechAnalyzer:
148
  score = 0.5 - (score * 0.5)
149
  sentiment_scores.append(score)
150
 
151
- # Get emotion classification
152
- emotion_result = self.emotion_classifier(segment)
153
  emotion = emotion_result[0]['label']
154
  basic_emotions.append(emotion)
155
 
156
  return sentiment_scores, basic_emotions
157
 
 
158
  def detect_named_entities(self, text):
159
  """Detect named entities in the text"""
160
  entities = self.ner_pipeline(text)
 
139
  basic_emotions = []
140
 
141
  for segment in segments:
142
+ # Get sentiment scores with truncation
143
+ sentiment_result = self.sentiment_pipeline(segment, truncation=True, max_length=512)
144
  score = sentiment_result[0]['score']
145
  if sentiment_result[0]['label'] == 'POSITIVE':
146
  score = 0.5 + (score * 0.5)
 
148
  score = 0.5 - (score * 0.5)
149
  sentiment_scores.append(score)
150
 
151
+ # Get emotion classification with truncation
152
+ emotion_result = self.emotion_classifier(segment, truncation=True, max_length=512)
153
  emotion = emotion_result[0]['label']
154
  basic_emotions.append(emotion)
155
 
156
  return sentiment_scores, basic_emotions
157
 
158
+
159
  def detect_named_entities(self, text):
160
  """Detect named entities in the text"""
161
  entities = self.ner_pipeline(text)