-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathspeechrecog.py
More file actions
35 lines (26 loc) · 929 Bytes
/
speechrecog.py
File metadata and controls
35 lines (26 loc) · 929 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
25
26
27
28
29
30
31
32
33
34
35
from nltk.sentiment import SentimentIntensityAnalyzer
import nltk
import moviepy.editor as mp
import speech_recognition as sr
nltk.download('vader_lexicon')
def toMP3(n):
video = mp.VideoFileClip(n+".mp4")
audio = video.audio
audio.write_audiofile("FileSaving\\sound.wav")
def getSentiment(text):
nia = SentimentIntensityAnalyzer()
return nia.polarity_scores(text)
def generate(n):
out = "FileSaving\\sound.wav"
toMP3(n)
# engine = tts.init()
# engine.save_to_file('''We can discuss your product design later. Email me or something. Please do not make any inquiries about your design right now.''', out)
# engine.runAndWait()
return(out)
def getTextValues(n):
engine = sr.Recognizer()
mp3FileName = generate(n)
with sr.AudioFile(mp3FileName) as source:
audio = engine.record(source)
text = engine.recognize_google(audio)
return(getSentiment(text))