-
Notifications
You must be signed in to change notification settings - Fork 46
Expand file tree
/
Copy pathEmotion.py
More file actions
24 lines (21 loc) · 736 Bytes
/
Copy pathEmotion.py
File metadata and controls
24 lines (21 loc) · 736 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
from vaderSentiment.vaderSentiment import SentimentIntensityAnalyzer
import speech_recognition as sr
recognizer=sr.Recognizer()
with sr.Microphone() as source:
print('Clearing background noise...')
recognizer.adjust_for_ambient_noise(source,duration=1)
print('Waiting for your message...')
recordedaudio=recognizer.listen(source)
print('Done recording..')
try:
print('Printing the message..')
text=recognizer.recognize_google(recordedaudio,language='en-US')
print('Your message:{}'.format(text))
except Exception as ex:
print(ex)
#Sentiment analysis
Sentence=[str(text)]
analyser=SentimentIntensityAnalyzer()
for i in Sentence:
v=analyser.polarity_scores(i)
print(v)