Commit cc7f90b1 authored by NaweenTharuka's avatar NaweenTharuka

updated: prosodic features

parent d84ae894
# -*- coding: utf-8 -*-
"""emotionDetection.ipynb
Automatically generated by Colaboratory.
Original file is located at
https://colab.research.google.com/drive/1o8opa083KfLohUfWs-oGfkdo9kuRN_eS
**Importing dependencies**
* pip install fer
* List item
"""
from fer import Video from fer import Video
from fer import FER from fer import FER
import os import os
...@@ -20,13 +5,9 @@ import sys ...@@ -20,13 +5,9 @@ import sys
import pandas as pd import pandas as pd
import numpy as np import numpy as np
"""Upload the video to the Google colab and get the path of the video and xml file"""
location_videofile = "F:\\CDAP-PRESENTLY\\21_22-j-02\\Presently\\presently\\media\\video\\22\\testvideo.mp4" location_videofile = "F:\\CDAP-PRESENTLY\\21_22-j-02\\Presently\\presently\\media\\video\\22\\testvideo.mp4"
cascPath = "F:\\CDAP-PRESENTLY\\21_22-j-02\\Presently\\presently\\users\\models\\abc.xml" cascPath = "F:\\CDAP-PRESENTLY\\21_22-j-02\\Presently\\presently\\users\\models\\abc.xml"
"""Get labels to each emotion"""
def _get_labels(): def _get_labels():
return { return {
0: "angry", 0: "angry",
...@@ -38,10 +19,7 @@ def _get_labels(): ...@@ -38,10 +19,7 @@ def _get_labels():
6: "neutral", 6: "neutral",
} }
"""Build a square (around the face)"""
def tosquare(bbox): def tosquare(bbox):
"""Convert bounding box to square by elongating shorter side."""
x, y, w, h = bbox x, y, w, h = bbox
if h > w: if h > w:
diff = h - w diff = h - w
...@@ -56,15 +34,11 @@ def tosquare(bbox): ...@@ -56,15 +34,11 @@ def tosquare(bbox):
return (x, y, w, h) return (x, y, w, h)
"""Builded square around the face"""
def __apply_offsets(face_coordinates): def __apply_offsets(face_coordinates):
x, y, width, height = face_coordinates x, y, width, height = face_coordinates
x_off, y_off = (10, 10) x_off, y_off = (10, 10)
return (x - x_off, x + width + x_off, y - y_off, y + height + y_off) return (x - x_off, x + width + x_off, y - y_off, y + height + y_off)
"""To correct numbers"""
def __preprocess_input(x, v2=False): def __preprocess_input(x, v2=False):
x = x.astype("float32") x = x.astype("float32")
x = x / 255.0 x = x / 255.0
...@@ -73,8 +47,6 @@ def __preprocess_input(x, v2=False): ...@@ -73,8 +47,6 @@ def __preprocess_input(x, v2=False):
x = x * 2.0 x = x * 2.0
return x return x
"""Add padding to the image"""
def pad(image): def pad(image):
PADDING = 40 PADDING = 40
row, col = image.shape[:2] row, col = image.shape[:2]
...@@ -106,7 +78,6 @@ def detect_emotions(location_videofile, NumberofFrames): ...@@ -106,7 +78,6 @@ def detect_emotions(location_videofile, NumberofFrames):
success,image = vidcap.read() success,image = vidcap.read()
frame_count = vidcap.get(cv2.CAP_PROP_FRAME_COUNT) frame_count = vidcap.get(cv2.CAP_PROP_FRAME_COUNT)
print("Frame Count: ", frame_count)
count = 0 count = 0
faceCascade = cv2.CascadeClassifier(cascPath) faceCascade = cv2.CascadeClassifier(cascPath)
...@@ -116,7 +87,7 @@ def detect_emotions(location_videofile, NumberofFrames): ...@@ -116,7 +87,7 @@ def detect_emotions(location_videofile, NumberofFrames):
if success: if success:
if frame_count > NumberofFrames+1: if frame_count > NumberofFrames+1:
count += frame_count/(NumberofFrames+1) # i.e. at 30 fps, this advances one second count += frame_count/(NumberofFrames+1)
else: else:
count += 1 count += 1
vidcap.set(cv2.CAP_PROP_POS_FRAMES, count) vidcap.set(cv2.CAP_PROP_POS_FRAMES, count)
...@@ -135,7 +106,6 @@ def detect_emotions(location_videofile, NumberofFrames): ...@@ -135,7 +106,6 @@ def detect_emotions(location_videofile, NumberofFrames):
face_coordinates = tosquare(face_coordinates) face_coordinates = tosquare(face_coordinates)
x1, x2, y1, y2 = __apply_offsets(face_coordinates) x1, x2, y1, y2 = __apply_offsets(face_coordinates)
# adjust for padding
x1 += PADDING x1 += PADDING
x2 += PADDING x2 += PADDING
y1 += PADDING y1 += PADDING
...@@ -154,10 +124,8 @@ def detect_emotions(location_videofile, NumberofFrames): ...@@ -154,10 +124,8 @@ def detect_emotions(location_videofile, NumberofFrames):
try: try:
gray_face = cv2.resize(gray_face, model.input_shape[1:3]) gray_face = cv2.resize(gray_face, model.input_shape[1:3])
except Exception as e: except Exception as e:
#print("Cannot resize")
continue continue
# Local Keras model
gray_face = __preprocess_input(gray_face, True) gray_face = __preprocess_input(gray_face, True)
gray_face = np.expand_dims(np.expand_dims(gray_face, 0), -1) gray_face = np.expand_dims(np.expand_dims(gray_face, 0), -1)
...@@ -170,9 +138,6 @@ def detect_emotions(location_videofile, NumberofFrames): ...@@ -170,9 +138,6 @@ def detect_emotions(location_videofile, NumberofFrames):
emotions.append( emotions.append(
dict(box=face_coordinates, emotions=labelled_emotions) dict(box=face_coordinates, emotions=labelled_emotions)
) )
#print("Prediction : ", emotions[0]["emotions"])
#plt.imshow(gray_img, interpolation='nearest')
#plt.show()
top_emotions = [max(e["emotions"], key=lambda key: e["emotions"][key]) for e in emotions] top_emotions = [max(e["emotions"], key=lambda key: e["emotions"][key]) for e in emotions]
if len(top_emotions): if len(top_emotions):
for top_emotion in emotions[0]["emotions"]: for top_emotion in emotions[0]["emotions"]:
...@@ -190,4 +155,3 @@ def detect_emotions(location_videofile, NumberofFrames): ...@@ -190,4 +155,3 @@ def detect_emotions(location_videofile, NumberofFrames):
return max(arry, key=arry.get), arry return max(arry, key=arry.get), arry
emo, arr1 = detect_emotions(location_videofile, 300) emo, arr1 = detect_emotions(location_videofile, 300)
# print(emo, arr1)
\ No newline at end of file
...@@ -25,8 +25,8 @@ def run_praat_file(m, p): ...@@ -25,8 +25,8 @@ def run_praat_file(m, p):
try: try:
objects= run_file(sourcerun, -20, 2, 0.3, "yes",sound,path, 80, 400, 0.01, capture_output=True) objects= run_file(sourcerun, -20, 2, 0.3, "yes",sound,path, 80, 400, 0.01, capture_output=True)
print (objects[0]) # This will print the info from the sound object, and objects[0] is a parselmouth.Sound object print (objects[0])
z1=str( objects[1]) # This will print the info from the textgrid object, and objects[1] is a parselmouth.Data object with a TextGrid inside z1=str( objects[1])
z2=z1.strip().split() z2=z1.strip().split()
return z2 return z2
except: except:
...@@ -39,10 +39,9 @@ def myspsyl(m,p): ...@@ -39,10 +39,9 @@ def myspsyl(m,p):
Detect and count number of syllables Detect and count number of syllables
""" """
z2 = run_praat_file(m, p) z2 = run_praat_file(m, p)
z3=int(z2[0]) # will be the integer number 10 z3=int(z2[0])
z4=float(z2[3]) # will be the floating point number 8.3 z4=float(z2[3])
print ("number_ of_syllables=",z3) return ("Number of syllables = ",z3)
return z3
def mysppaus(m,p): def mysppaus(m,p):
""" """
...@@ -51,8 +50,7 @@ def mysppaus(m,p): ...@@ -51,8 +50,7 @@ def mysppaus(m,p):
z2 = run_praat_file(m, p) z2 = run_praat_file(m, p)
z3=int(z2[1]) # will be the integer number 10 z3=int(z2[1]) # will be the integer number 10
z4=float(z2[3]) # will be the floating point number 8.3 z4=float(z2[3]) # will be the floating point number 8.3
print ("number_of_pauses=",z3) return ("Number of pauses = ",z3)
return z3
def myspsr(m,p): def myspsr(m,p):
""" """
...@@ -61,8 +59,7 @@ def myspsr(m,p): ...@@ -61,8 +59,7 @@ def myspsr(m,p):
z2 = run_praat_file(m, p) z2 = run_praat_file(m, p)
z3=int(z2[2]) # will be the integer number 10 z3=int(z2[2]) # will be the integer number 10
z4=float(z2[3]) # will be the floating point number 8.3 z4=float(z2[3]) # will be the floating point number 8.3
print ("rate_of_speech=",z3,"# syllables/sec original duration") return ("Rate of speech = ",z3," # syllables/sec original duration")
return z3
def myspatc(m,p): def myspatc(m,p):
""" """
...@@ -71,8 +68,7 @@ def myspatc(m,p): ...@@ -71,8 +68,7 @@ def myspatc(m,p):
z2 = run_praat_file(m, p) z2 = run_praat_file(m, p)
z3=int(z2[3]) # will be the integer number 10 z3=int(z2[3]) # will be the integer number 10
z4=float(z2[3]) # will be the floating point number 8.3 z4=float(z2[3]) # will be the floating point number 8.3
print ("articulation_rate=",z3,"# syllables/sec speaking duration") return ("Articulation Rate =",z3," # syllables/sec speaking duration")
return z3
def myspst(m,p): def myspst(m,p):
""" """
...@@ -81,8 +77,7 @@ def myspst(m,p): ...@@ -81,8 +77,7 @@ def myspst(m,p):
z2 = run_praat_file(m, p) z2 = run_praat_file(m, p)
z3=int(z2[3]) # will be the integer number 10 z3=int(z2[3]) # will be the integer number 10
z4=float(z2[4]) # will be the floating point number 8.3 z4=float(z2[4]) # will be the floating point number 8.3
print ("speaking_duration=",z4,"# sec only speaking duration without pauses") return ("Speaking duration = ",z4," # sec only speaking duration without pauses")
return z4
def myspod(m,p): def myspod(m,p):
""" """
...@@ -91,8 +86,7 @@ def myspod(m,p): ...@@ -91,8 +86,7 @@ def myspod(m,p):
z2 = run_praat_file(m, p) z2 = run_praat_file(m, p)
z3=int(z2[3]) # will be the integer number 10 z3=int(z2[3]) # will be the integer number 10
z4=float(z2[5]) # will be the floating point number 8.3 z4=float(z2[5]) # will be the floating point number 8.3
print ("original_duration=",z4,"# sec total speaking duration with pauses") return ("Original duration = ",z4," # sec total speaking duration with pauses")
return z4
def myspbala(m,p): def myspbala(m,p):
""" """
...@@ -101,8 +95,7 @@ def myspbala(m,p): ...@@ -101,8 +95,7 @@ def myspbala(m,p):
z2 = run_praat_file(m, p) z2 = run_praat_file(m, p)
z3=int(z2[3]) # will be the integer number 10 z3=int(z2[3]) # will be the integer number 10
z4=float(z2[6]) # will be the floating point number 8.3 z4=float(z2[6]) # will be the floating point number 8.3
print ("balance=",z4,"# ratio (speaking duration)/(original duration)") return ("Balance = ",z4," # ratio (speaking duration)/(original duration)")
return z4
def myspf0mean(m,p): def myspf0mean(m,p):
""" """
...@@ -111,8 +104,7 @@ def myspf0mean(m,p): ...@@ -111,8 +104,7 @@ def myspf0mean(m,p):
z2 = run_praat_file(m, p) z2 = run_praat_file(m, p)
z3=int(z2[3]) # will be the integer number 10 z3=int(z2[3]) # will be the integer number 10
z4=float(z2[7]) # will be the floating point number 8.3 z4=float(z2[7]) # will be the floating point number 8.3
print ("f0_mean=",z4,"# Hz global mean of fundamental frequency distribution") return ("f0 mean = ",z4," # Hz global mean of fundamental frequency distribution")
return z4
def myspf0sd(m,p): def myspf0sd(m,p):
""" """
...@@ -121,8 +113,7 @@ def myspf0sd(m,p): ...@@ -121,8 +113,7 @@ def myspf0sd(m,p):
z2 = run_praat_file(m, p) z2 = run_praat_file(m, p)
z3=int(z2[3]) # will be the integer number 10 z3=int(z2[3]) # will be the integer number 10
z4=float(z2[8]) # will be the floating point number 8.3 z4=float(z2[8]) # will be the floating point number 8.3
print ("f0_SD=",z4,"# Hz global standard deviation of fundamental frequency distribution") return ("f0 SD = ",z4," # Hz global standard deviation of fundamental frequency distribution")
return z4
def myspf0med(m,p): def myspf0med(m,p):
""" """
...@@ -131,8 +122,7 @@ def myspf0med(m,p): ...@@ -131,8 +122,7 @@ def myspf0med(m,p):
z2 = run_praat_file(m, p) z2 = run_praat_file(m, p)
z3=int(z2[3]) # will be the integer number 10 z3=int(z2[3]) # will be the integer number 10
z4=float(z2[9]) # will be the floating point number 8.3 z4=float(z2[9]) # will be the floating point number 8.3
print ("f0_MD=",z4,"# Hz global median of fundamental frequency distribution") return ("f0 MD = ",z4," # Hz global median of fundamental frequency distribution")
return z4
def myspf0min(m,p): def myspf0min(m,p):
""" """
...@@ -141,8 +131,7 @@ def myspf0min(m,p): ...@@ -141,8 +131,7 @@ def myspf0min(m,p):
z2 = run_praat_file(m, p) z2 = run_praat_file(m, p)
z3=int(z2[10]) # will be the integer number 10 z3=int(z2[10]) # will be the integer number 10
z4=float(z2[10]) # will be the floating point number 8.3 z4=float(z2[10]) # will be the floating point number 8.3
print ("f0_min=",z3,"# Hz global minimum of fundamental frequency distribution") return ("f0 min = ",z3," # Hz global minimum of fundamental frequency distribution")
return z3
def myspf0max(m,p): def myspf0max(m,p):
""" """
...@@ -151,8 +140,7 @@ def myspf0max(m,p): ...@@ -151,8 +140,7 @@ def myspf0max(m,p):
z2 = run_praat_file(m, p) z2 = run_praat_file(m, p)
z3=int(z2[11]) # will be the integer number 10 z3=int(z2[11]) # will be the integer number 10
z4=float(z2[11]) # will be the floating point number 8.3 z4=float(z2[11]) # will be the floating point number 8.3
print ("f0_max=",z3,"# Hz global maximum of fundamental frequency distribution") return ("f0 max = ",z3," # Hz global maximum of fundamental frequency distribution")
return z3
def myspf0q25(m,p): def myspf0q25(m,p):
""" """
...@@ -161,8 +149,7 @@ def myspf0q25(m,p): ...@@ -161,8 +149,7 @@ def myspf0q25(m,p):
z2 = run_praat_file(m, p) z2 = run_praat_file(m, p)
z3=int(z2[12]) # will be the integer number 10 z3=int(z2[12]) # will be the integer number 10
z4=float(z2[11]) # will be the floating point number 8.3 z4=float(z2[11]) # will be the floating point number 8.3
print ("f0_quan25=",z3,"# Hz global 25th quantile of fundamental frequency distribution") return ("f0 quan25 = ",z3," # Hz global 25th quantile of fundamental frequency distribution")
return z3
def myspf0q75(m,p): def myspf0q75(m,p):
""" """
...@@ -171,22 +158,7 @@ def myspf0q75(m,p): ...@@ -171,22 +158,7 @@ def myspf0q75(m,p):
z2 = run_praat_file(m, p) z2 = run_praat_file(m, p)
z3=int(z2[13]) # will be the integer number 10 z3=int(z2[13]) # will be the integer number 10
z4=float(z2[11]) # will be the floating point number 8.3 z4=float(z2[11]) # will be the floating point number 8.3
print ("f0_quan75=",z3,"# Hz global 75th quantile of fundamental frequency distribution") return ("f0 quan75 = ",z3," # Hz global 75th quantile of fundamental frequency distribution")
return z3
def mysptotal(m,p):
"""
Overview
"""
z2 = run_praat_file(m, p)
z3=np.array(z2)
z4=np.array(z3)[np.newaxis]
z5=z4.T
dataset=pd.DataFrame({"number_ of_syllables":z5[0,:],"number_of_pauses":z5[1,:],"rate_of_speech":z5[2,:],"articulation_rate":z5[3,:],"speaking_duration":z5[4,:],
"original_duration":z5[5,:],"balance":z5[6,:],"f0_mean":z5[7,:],"f0_std":z5[8,:],"f0_median":z5[9,:],"f0_min":z5[10,:],"f0_max":z5[11,:],
"f0_quantile25":z5[12,:],"f0_quan75":z5[13,:]})
print (dataset.T)
return dataset.T
def mysppron(m,p): def mysppron(m,p):
""" """
...@@ -206,9 +178,9 @@ def mysppron(m,p): ...@@ -206,9 +178,9 @@ def mysppron(m,p):
db= binom.rvs(n=10,p=z4,size=10000) db= binom.rvs(n=10,p=z4,size=10000)
a=np.array(db) a=np.array(db)
b=np.mean(a)*100/10 b=np.mean(a)*100/10
print ("Pronunciation_posteriori_probability_score_percentage= :%.2f" % (b)) return ("Pronunciation posteriori probability score percentage = : %.2f" % (b))
except: except:
print ("Try again the sound of the audio was not clear") return ("Try again the sound of the audio was not clear")
return return
def myspgend(m,p): def myspgend(m,p):
...@@ -266,21 +238,21 @@ def myspgend(m,p): ...@@ -266,21 +238,21 @@ def myspgend(m,p):
else: else:
mmm=0.35 mmm=0.35
if z4>97 and z4<=114: if z4>97 and z4<=114:
print("a Male, mood of speech: Showing no emotion, normal, p-value/sample size= :%.2f" % (mmm), (nnn)) return ("A Male, Mood of speech: Showing no emotion | normal, p-value/sample size :%.2f" % (mmm), (nnn))
elif z4>114 and z4<=135: elif z4>114 and z4<=135:
print("a Male, mood of speech: Reading, p-value/sample size= :%.2f" % (mmm), (nnn)) return ("A Male, Mood of speech: Reading, p-value/sample size :%.2f" % (mmm), (nnn))
elif z4>135 and z4<=163: elif z4>135 and z4<=163:
print("a Male, mood of speech: speaking passionately, p-value/sample size= :%.2f" % (mmm), (nnn)) return ("A Male, Mood of speech: speaking passionately, p-value/sample size :%.2f" % (mmm), (nnn))
elif z4>163 and z4<=197: elif z4>163 and z4<=197:
print("a female, mood of speech: Showing no emotion, normal, p-value/sample size= :%.2f" % (mmm), (nnn)) return ("A Female, Mood of speech: Showing no emotion | normal, p-value/sample size :%.2f" % (mmm), (nnn))
elif z4>197 and z4<=226: elif z4>197 and z4<=226:
print("a female, mood of speech: Reading, p-value/sample size= :%.2f" % (mmm), (nnn)) return ("A Female, Mood of speech: Reading, p-value/sample size :%.2f" % (mmm), (nnn))
elif z4>226 and z4<=245: elif z4>226 and z4<=245:
print("a female, mood of speech: speaking passionately, p-value/sample size= :%.2f" % (mmm), (nnn)) return ("A Female, Mood of speech: speaking passionately, p-value/sample size :%.2f" % (mmm), (nnn))
else: else:
print("Voice not recognized") return ("Voice not recognized")
except: except:
print ("Try again the sound of the audio was not clear") return ("Try again the sound of the audio was not clear")
def myprosody(m,p): def myprosody(m,p):
""" """
...@@ -299,11 +271,10 @@ def myprosody(m,p): ...@@ -299,11 +271,10 @@ def myprosody(m,p):
result_array = np.empty((0, 27)) result_array = np.empty((0, 27))
try: try:
objects= run_file(sourcerun, -20, 2, 0.3, "yes",sound,path, 80, 400, 0.01, capture_output=True) objects= run_file(sourcerun, -20, 2, 0.3, "yes",sound,path, 80, 400, 0.01, capture_output=True)
z1=( objects[1]) # This will print the info from the textgrid object, and objects[1] is a parselmouth.Data object with a TextGrid inside z1=( objects[1])
z3=z1.strip().split() z3=z1.strip().split()
z2=np.array([z3]) z2=np.array([z3])
result_array=np.append(result_array,[z3], axis=0) result_array=np.append(result_array,[z3], axis=0)
#print(z3)
np.savetxt(outo,result_array, fmt='%s',delimiter=',') np.savetxt(outo,result_array, fmt='%s',delimiter=',')
#Data and features analysis #Data and features analysis
df = pd.read_csv(outo, df = pd.read_csv(outo,
...@@ -334,15 +305,15 @@ def myprosody(m,p): ...@@ -334,15 +305,15 @@ def myprosody(m,p):
if he==0: if he==0:
he=25 he=25
dfout = "%s:\t %f (%s)" % (nsns[i],he,"% percentile ") dfout = "%s:\t %f (%s)" % (nsns[i],he,"% percentile ")
print(dfout) return(dfout)
elif he>=25 and he<=75: elif he>=25 and he<=75:
dfout = "%s:\t %f (%s)" % (nsns[i],he,"% percentile ") dfout = "%s:\t %f (%s)" % (nsns[i],he,"% percentile ")
print(dfout) return(dfout)
else: else:
dfout = "%s:\t (%s)" % (nsns[i],":Out of Range") dfout = "%s:\t (%s)" % (nsns[i],":Out of Range")
print(dfout) return(dfout)
except: except:
print ("Try again the sound of the audio was not clear") return ("Try again the sound of the audio was not clear")
def mysplev(m,p): def mysplev(m,p):
import sys import sys
......
import myprosody as mysp
import pickle
p="happy"
c="F:\\CDAP-PRESENTLY\\21_22-j-02\\Presently\\presently\\users\\myprosody"
mysp.myspsyl(p,c)
mysp.mysppaus(p,c)
mysp.myspsr(p,c)
mysp.myspatc(p,c)
mysp.myspst(p,c)
mysp.myspod(p,c)
mysp.myspbala(p,c)
mysp.myspf0mean(p,c)
mysp.myspf0sd(p,c)
mysp.myspf0med(p,c)
mysp.myspf0min(p,c)
mysp.myspf0max(p,c)
mysp.myspf0q25(p,c)
mysp.myspf0q75(p,c)
mysp.mysptotal(p,c)
mysp.myspgend(p,c)
mysp.mysppron(p,c)
mysp.myprosody(p,c)
mysp.mysplev(p,c)
...@@ -7,8 +7,7 @@ ...@@ -7,8 +7,7 @@
<link rel="stylesheet" href="{% static 'users/css/main.css' %}" type="text/css"> <link rel="stylesheet" href="{% static 'users/css/main.css' %}" type="text/css">
<link rel="stylesheet" href="{% static 'users/css/plugin.css' %}" type="text/css"> <link rel="stylesheet" href="{% static 'users/css/plugin.css' %}" type="text/css">
<link rel="stylesheet" href="{% static 'users/css/style.css' %}" type="text/css"> <link rel="stylesheet" href="{% static 'users/css/style.css' %}" type="text/css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-eOJMYsd53ii+scO/bJGFsiCZc+5NDVN2yr8+0RDqr0Ql0h+rP48ckxlpbzKgwra6" crossorigin="anonymous"> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-eOJMYsd53ii+scO/bJGFsiCZc+5NDVN2yr8+0RDqr0Ql0h+rP48ckxlpbzKgwra6" crossorigin="anonymous">
<link rel="preconnect" href="https://fonts.gstatic.com"> <link rel="preconnect" href="https://fonts.gstatic.com">
<link href="https://fonts.googleapis.com/css2?family=Montserrat:wght@500&family=Open+Sans:wght@800&display=swap" rel="stylesheet"> <link href="https://fonts.googleapis.com/css2?family=Montserrat:wght@500&family=Open+Sans:wght@800&display=swap" rel="stylesheet">
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
{% block content %} {% block content %}
<h2> {{ var1 }} {{ var2 }}</h2> <h2> {{ var1 }} {{ var2 }}</h2>
<!-- {% for key, value in predictions.items %} <!-- {% for key, value in var2.items %}
<h2>{{ forloop.counter }}. {{ key }} : {{ value }}</h2> <h2>{{ forloop.counter }}. {{ key }} : {{ value }}</h2>
{% endfor %} --> {% endfor %} -->
......
...@@ -10,11 +10,16 @@ from .models import Video ...@@ -10,11 +10,16 @@ from .models import Video
from django.template import Template, Context from django.template import Template, Context
import datetime import datetime
from . import emotiondetectionvideo from . import emotiondetectionvideo
from . import emotiondetectionaudio # from . import emotiondetectionaudio
import myprosody as mysp
import pickle
from . import myprosody
def test(request): def test(request):
var1= emotiondetectionaudio.emo_list p="happy"
var2= emotiondetectionaudio.total_predictions_np c="F:\\CDAP-PRESENTLY\\21_22-j-02\\Presently\\presently\\users\\myprosody"
var2= myprosody.myspgend(p,c)
var1= myprosody.myprosody(p,c)
context= { context= {
'var1': var1, 'var1': var1,
'var2': var2 'var2': var2
...@@ -60,7 +65,46 @@ def emotionvideo(request): ...@@ -60,7 +65,46 @@ def emotionvideo(request):
return render(request, 'users/emotionvideo.html',context) return render(request, 'users/emotionvideo.html',context)
def emotionaudioprosody(request): def emotionaudioprosody(request):
return render(request, 'users/prosody.html') p="happy"
c="F:\\CDAP-PRESENTLY\\21_22-j-02\\Presently\\presently\\users\\myprosody"
myspsyl= myprosody.myspsyl(p,c)
mysppaus= myprosody.mysppaus(p,c)
myspsr= myprosody.myspsr(p,c)
myspatc= myprosody.myspatc(p,c)
myspst= myprosody.myspst(p,c)
myspod= myprosody.myspod(p,c)
myspbala= myprosody.myspbala(p,c)
myspf0mean= myprosody.myspf0mean(p,c)
myspf0sd= myprosody.myspf0sd(p,c)
myspf0med= myprosody.myspf0med(p,c)
myspf0min= myprosody.myspf0min(p,c)
myspf0max= myprosody.myspf0max(p,c)
myspf0q25= myprosody.myspf0q25(p,c)
myspf0q75= myprosody.myspf0q75(p,c)
myspgend= myprosody.myspgend(p,c)
mysppron= myprosody.mysppron(p,c)
prosody= myprosody.myprosody(p,c)
context= {
'myspsyl': myspsyl,
'mysppaus': mysppaus,
'myspsr': myspsr,
'myspatc': myspatc,
'myspst': myspst,
'myspod': myspod,
'myspbala': myspbala,
'myspf0mean': myspf0mean,
'myspf0sd': myspf0sd,
'myspf0med': myspf0med,
'myspf0min': myspf0min,
'myspf0max': myspf0max,
'myspf0q25': myspf0q25,
'myspf0q75': myspf0q75,
'myspgend': myspgend,
'mysppron': mysppron,
'prosody': prosody
}
return render(request, 'users/prosody.html',context)
def overallfeedback(request): def overallfeedback(request):
return render(request, 'users/overallfeedback.html') return render(request, 'users/overallfeedback.html')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment