-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSUI.py
More file actions
61 lines (55 loc) · 1.97 KB
/
SUI.py
File metadata and controls
61 lines (55 loc) · 1.97 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/bin/python
import streamlit as st
import pandas as pd
import numpy as np
import time, os
import matplotlib.pyplot as plt
import speech_recognition as sr
import sys
import os
import nltk
nltk.download('punkt')
nltk.download('averaged_perceptron_tagger')
from nltk.stem import PorterStemmer
from nltk.tokenize import word_tokenize
from nltk import pos_tag
from textblob import TextBlob
from sklearn.feature_extraction.text import TfidfVectorizer
from sklearn.metrics.pairwise import cosine_similarity
import subprocess
URL = st.text_input("Enter youtube URL", "")
os.system("rm sentData.txt")
if st.button('Start Mining'):
#os.system("chmod +x start-vsm.sh")
os.system(f"youtube-dl '{URL}' -o - | ffmpeg -i - -f wav - | pv | python3 sentiment-vsm.py&")
chart = st.empty()
counter = 0
chart_data = pd.DataFrame(np.array([[0, 0, 0, 0, 0]]), columns=["anger", "disgust", "fear", "joy", "sadness"])
while (1):
try:
f = open("sentData.txt")
break
except:
pass
while (1):
EmocounT = {"anger": 0,
"disgust": 0,
"fear": 0,
"joy": 0,
"sadness": 0}
buff = f.readline()
buff = buff.strip()
if buff != "":
EmocounT[buff] += 1
chart_data.loc[counter] = pd.DataFrame(np.array(
[[EmocounT["anger"], EmocounT["disgust"], EmocounT["fear"], EmocounT["joy"], EmocounT["sadness"]]]), \
columns=["anger", "disgust", "fear", "joy", "sadness"]).loc[0]
plot_data = pd.DataFrame(chart_data.sum())
# chart.bar_chart(chart_data,orientation='vertical')
groups = plot_data.groupby(plot_data.index)
fig, ax = plt.subplots()
for name, group in groups:
ax.bar(name, group[0], label=name, align='center')
chart.pyplot(fig)
time.sleep(0.5)
counter += 1