Files changed (1) hide show
  1. app.py +10 -0
app.py CHANGED
@@ -5,7 +5,17 @@ from vaderSentiment.vaderSentiment import SentimentIntensityAnalyzer
5
  import tempfile
6
 
7
  analyzer = SentimentIntensityAnalyzer()
 
8
 
 
 
 
 
 
 
 
 
 
9
  def analyze_text(text):
10
  score = analyzer.polarity_scores(text)
11
  if score['compound'] >= 0.05:
 
5
  import tempfile
6
 
7
  analyzer = SentimentIntensityAnalyzer()
8
+ from transformers import pipeline
9
 
10
+ # Load models
11
+ whisper = pipeline("automatic-speech-recognition", model="openai/whisper-small")
12
+ emotion_model = pipeline("text-classification", model="j-hartmann/emotion-english-distilroberta-base", return_all_scores=True)
13
+
14
+ # Use Whisper to transcribe uploaded audio
15
+ def analyze_audio(audio_file):
16
+ text = whisper(audio_file)["text"]
17
+ emotions = emotion_model(text)[0]
18
+ return text, sorted(emotions, key=lambda x: x['score'], reverse=True)
19
  def analyze_text(text):
20
  score = analyzer.polarity_scores(text)
21
  if score['compound'] >= 0.05: