Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
2
2020-101
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Sachith Fernando
2020-101
Commits
bcb44959
Commit
bcb44959
authored
Jan 06, 2021
by
SohanDanushka
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/QA_RELEASE' into db_and_monitoring_IT17097284
parents
a22f93b0
28bdfdce
Changes
15
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
959 additions
and
249 deletions
+959
-249
FirstApp/api.py
FirstApp/api.py
+85
-3
FirstApp/logic/batch_process.py
FirstApp/logic/batch_process.py
+51
-8
FirstApp/serializers.py
FirstApp/serializers.py
+6
-1
FirstApp/templates/FirstApp/Home.html
FirstApp/templates/FirstApp/Home.html
+1
-1
FirstApp/templates/FirstApp/activity.html
FirstApp/templates/FirstApp/activity.html
+265
-62
FirstApp/templates/FirstApp/emotion.html
FirstApp/templates/FirstApp/emotion.html
+281
-124
FirstApp/templates/FirstApp/gaze.html
FirstApp/templates/FirstApp/gaze.html
+172
-48
FirstApp/templates/FirstApp/template.html
FirstApp/templates/FirstApp/template.html
+1
-0
FirstApp/urls.py
FirstApp/urls.py
+3
-0
LectureSummarizingApp/Voice Recorder.py
LectureSummarizingApp/Voice Recorder.py
+26
-0
LectureSummarizingApp/models.py
LectureSummarizingApp/models.py
+1
-0
LectureSummarizingApp/templates/LectureSummarizingApp/RecordLecture.html
...ingApp/templates/LectureSummarizingApp/RecordLecture.html
+54
-0
LectureSummarizingApp/urls.py
LectureSummarizingApp/urls.py
+1
-0
LectureSummarizingApp/views.py
LectureSummarizingApp/views.py
+10
-1
integrated_slpes/urls.py
integrated_slpes/urls.py
+2
-1
No files found.
FirstApp/api.py
View file @
bcb44959
...
@@ -168,13 +168,17 @@ class LectureVideoViewSet(APIView):
...
@@ -168,13 +168,17 @@ class LectureVideoViewSet(APIView):
# serializer = LectureVideoSerializer(data=request.data, many=True)
# serializer = LectureVideoSerializer(data=request.data, many=True)
serializer
=
LectureVideoSerializer
(
data
=
request
.
data
)
serializer
=
LectureVideoSerializer
(
data
=
request
.
data
)
# serializer.create(validated_data=request.data)
# serializer.create(validated_data=request.data)
data
=
{}
data_ser
=
{}
if
serializer
.
is_valid
(
raise_exception
=
ValueError
):
if
serializer
.
is_valid
(
raise_exception
=
ValueError
):
print
(
'valid'
)
data
=
serializer
.
create
(
validated_data
=
request
.
data
)
serializer
.
create
(
validated_data
=
request
.
data
)
print
(
'data: '
,
data
)
# data_ser = LectureVideoSerializer(data, many=True)
return
Response
(
serializer
.
data
,
status
=
status
.
HTTP_201_CREATED
)
# return Response(serializer.data, status=status.HTTP_201_CREATED)
return
Response
(
data
,
status
=
status
.
HTTP_201_CREATED
)
# return Response(serializer.error_messages,
# return Response(serializer.error_messages,
...
@@ -462,6 +466,7 @@ class GetLectureEmotionReportViewSet(APIView):
...
@@ -462,6 +466,7 @@ class GetLectureEmotionReportViewSet(APIView):
lecture_emotions
=
LectureEmotionReport
.
objects
.
filter
(
lecture_video_id__lecture_video_id
=
lecture_video_id
)
lecture_emotions
=
LectureEmotionReport
.
objects
.
filter
(
lecture_video_id__lecture_video_id
=
lecture_video_id
)
serializer
=
LectureEmotionSerializer
(
lecture_emotions
,
many
=
True
)
serializer
=
LectureEmotionSerializer
(
lecture_emotions
,
many
=
True
)
print
(
'data: '
,
serializer
.
data
)
return
Response
({
return
Response
({
"response"
:
serializer
.
data
,
"response"
:
serializer
.
data
,
...
@@ -1565,3 +1570,80 @@ class TestRandom(APIView):
...
@@ -1565,3 +1570,80 @@ class TestRandom(APIView):
"response"
:
random
"response"
:
random
})
})
# this API will display the upcoming lectures for the lecturer (temporary API)
class
DisplayUpcomingLecturesAPI
(
APIView
):
def
get
(
self
,
request
):
lecturer
=
request
.
query_params
.
get
(
'lecturer'
)
lecturer
=
int
(
lecturer
)
cur_date
=
datetime
.
datetime
.
now
()
.
date
()
cur_time
=
datetime
.
datetime
.
now
()
.
time
()
eligible_start_time
=
''
eligible_end_time
=
''
subject_id
=
0
subject_name
=
''
subject_code
=
''
# retrieve the faculty timetable
faculty_timetable
=
FacultyTimetable
.
objects
.
all
()
# serialize the timetable
faculty_timetable_serialized
=
FacultyTimetableSerializer
(
faculty_timetable
,
many
=
True
)
# get the serialized timetable data
faculty_timetable_serialized_data
=
faculty_timetable_serialized
.
data
# iterate through the serialized timetable data
for
timetable
in
faculty_timetable_serialized_data
:
# get the 'timetable' field
daily_timetable
=
timetable
[
'timetable'
]
# iterate through the 'timetable' field
for
day_timetable
in
daily_timetable
:
# get the 'time_slots' field for a given day
time_slots
=
day_timetable
[
'time_slots'
]
# iterate through the time slots
for
time_slot
in
time_slots
:
# if the lecturer is the currently logged in lecturer
if
lecturer
==
time_slot
[
'lecturer'
][
'id'
]:
# find the upcoming lecture for the logged-in lecturer
if
cur_date
==
day_timetable
[
'date'
]:
# get the start and end times
start_time
=
time_slot
[
'start_time'
]
end_time
=
time_slot
[
'end_time'
]
start_time_list
=
str
(
start_time
)
.
split
(
":"
)
start_time_date
=
datetime
.
datetime
.
now
()
.
replace
(
hour
=
int
(
start_time_list
[
0
]),
minute
=
int
(
start_time_list
[
1
]),
second
=
int
(
start_time_list
[
2
]))
end_time_list
=
str
(
end_time
)
.
split
(
":"
)
end_time_date
=
datetime
.
datetime
.
now
()
.
replace
(
hour
=
int
(
end_time_list
[
0
]),
minute
=
int
(
end_time_list
[
1
]),
second
=
int
(
end_time_list
[
2
]))
# check for the upcoming time slot
if
(
start_time_date
.
time
()
>
cur_time
):
eligible_start_time
=
start_time_date
.
time
()
eligible_end_time
=
end_time_date
.
time
()
subject_id
=
time_slot
[
'subject'
][
'id'
]
subject_name
=
time_slot
[
'subject'
][
'name'
]
subject_code
=
time_slot
[
'subject'
][
'subject_code'
]
return
Response
({
"start_time"
:
eligible_start_time
,
"end_time"
:
eligible_end_time
,
"subject_id"
:
subject_id
,
"subject_name"
:
subject_name
,
"subject_code"
:
subject_code
,
})
FirstApp/logic/batch_process.py
View file @
bcb44959
import
requests
import
requests
import
json
def
batch_process
(
video_id
,
video_name
):
def
student_behavior_
batch_process
(
video_id
,
video_name
):
is_all_processed
=
False
# call the activity process
# call the activity process
activity_resp
=
requests
.
get
(
'http://127.0.0.1:8000/process-lecture-activity/?lecture_video_name='
+
video_name
+
'&lecture_video_id='
+
video_id
)
activity_resp
=
requests
.
get
(
'http://127.0.0.1:8000/process-lecture-activity/'
,
params
=
{
'lecture_video_name'
:
video_name
,
'lecture_video_id'
:
video_id
})
# if the activity process is success
if
activity_resp
.
json
()[
'response'
]:
# call the emotion process
# call the emotion process
emotion_resp
=
requests
.
get
(
'http://127.0.0.1:8000/process-lecture-emotion/?lecture_video_name='
+
video_name
+
'&lecture_video_id='
+
video_id
)
emotion_resp
=
requests
.
get
(
'http://127.0.0.1:8000/process-lecture-emotion/?lecture_video_name='
,
params
=
{
'lecture_video_name'
:
video_name
,
'lecture_video_id'
:
video_id
})
# if the emotion process is success
if
emotion_resp
.
json
()[
'response'
]:
# call the gaze process
# call the gaze process
gaze_resp
=
requests
.
get
(
'http://127.0.0.1:8000/process-lecture-gaze-estimation/?lecture_video_name='
+
video_name
+
'&lecture_video_id='
+
video_id
)
gaze_resp
=
requests
.
get
(
'http://127.0.0.1:8000/process-lecture-gaze-estimation/?lecture_video_name='
,
params
=
{
'lecture_video_name'
:
video_name
,
'lecture_video_id'
:
video_id
}
)
# if the gaze estimation process is successful
if
gaze_resp
.
json
()[
'response'
]:
is_all_processed
=
True
pass
return
is_all_processed
# this method will save the lecture video
# this method will save the lecture video
def
save_student_lecture_video
(
student_video
):
def
save_student_lecture_video
(
student_video
):
data_dumps
=
json
.
dumps
(
student_video
)
headers
=
{
'Content-Type'
:
'application/json'
}
# call the API
# call the API
student_video_save_resp
=
requests
.
post
(
'http://127.0.0.1:8000/lecture-video'
,
student_video
)
# student_video_save_resp = requests.post('http://127.0.0.1:8000/lecture-video', student_video)
\ No newline at end of file
student_video_save_resp
=
requests
.
post
(
url
=
'http://127.0.0.1:8000/lecture-video'
,
data
=
data_dumps
,
headers
=
headers
)
data
=
student_video_save_resp
.
json
()
return
data
[
0
]
if
__name__
==
'__main__'
:
# content = {
# "lecturer": 1,
# "subject": 16,
# "date": "2020-12-09",
# "video_name": "Video_test_19.mp4",
# "video_length": "00:45:06"
# }
#
#
# data_dumps = json.dumps(content)
# data_json = json.loads(data_dumps)
#
#
# save_student_lecture_video(content)
student_behavior_batch_process
(
8
,
"Video_test_8.mp4"
)
FirstApp/serializers.py
View file @
bcb44959
...
@@ -275,6 +275,11 @@ class LectureVideoSerializer(serializers.ModelSerializer):
...
@@ -275,6 +275,11 @@ class LectureVideoSerializer(serializers.ModelSerializer):
video_length
=
video_length
video_length
=
video_length
)
)
# retrieve the created object
created_lecture_video
=
LectureVideo
.
objects
.
filter
(
lecture_video_id
=
lecture_video
)
create_lecture_video_ser
=
LectureVideoSerializer
(
created_lecture_video
,
many
=
True
)
create_lecture_video_ser_data
=
create_lecture_video_ser
.
data
# faculty_data = validated_data.pop('faculty')
# faculty_data = validated_data.pop('faculty')
# serialized_faculty = FacultySerializer(data=faculty_data)
# serialized_faculty = FacultySerializer(data=faculty_data)
#
#
...
@@ -294,7 +299,7 @@ class LectureVideoSerializer(serializers.ModelSerializer):
...
@@ -294,7 +299,7 @@ class LectureVideoSerializer(serializers.ModelSerializer):
#
#
# return lecturer
# return lecturer
#
#
return
lecture_video
return
create_lecture_video_ser_data
return
None
return
None
...
...
FirstApp/templates/FirstApp/Home.html
View file @
bcb44959
...
@@ -2687,7 +2687,7 @@
...
@@ -2687,7 +2687,7 @@
</button>
</button>
</div>
</div>
<div
class=
"modal-body text-center"
>
<div
class=
"modal-body text-center"
>
<h3
class=
"font-weight-bold"
>
Student Activity vs. Student
Emotions
</h3>
<h3
class=
"font-weight-bold"
>
Student Activity vs. Student
Gaze
</h3>
<!-- ajax loader -->
<!-- ajax loader -->
<div
class=
"text-center"
id=
"student_activity_gaze_corr_loader"
hidden
>
<div
class=
"text-center"
id=
"student_activity_gaze_corr_loader"
hidden
>
...
...
FirstApp/templates/FirstApp/activity.html
View file @
bcb44959
This diff is collapsed.
Click to expand it.
FirstApp/templates/FirstApp/emotion.html
View file @
bcb44959
This diff is collapsed.
Click to expand it.
FirstApp/templates/FirstApp/gaze.html
View file @
bcb44959
This diff is collapsed.
Click to expand it.
FirstApp/templates/FirstApp/template.html
View file @
bcb44959
...
@@ -118,6 +118,7 @@
...
@@ -118,6 +118,7 @@
<div
id=
"collapseThree"
class=
"collapse"
aria-labelledby=
"headingThree"
data-parent=
"#accordionSidebar"
>
<div
id=
"collapseThree"
class=
"collapse"
aria-labelledby=
"headingThree"
data-parent=
"#accordionSidebar"
>
<div
class=
"bg-white py-2 collapse-inner rounded"
>
<div
class=
"bg-white py-2 collapse-inner rounded"
>
<h6
class=
"collapse-header"
>
Components:
</h6>
<h6
class=
"collapse-header"
>
Components:
</h6>
<a
class=
"collapse-item"
href=
"/summary/record"
>
Record Lecture
</a>
<a
class=
"collapse-item"
href=
"/summary/lecture"
>
Summarization
</a>
<a
class=
"collapse-item"
href=
"/summary/lecture"
>
Summarization
</a>
</div>
</div>
</div>
</div>
...
...
FirstApp/urls.py
View file @
bcb44959
...
@@ -192,6 +192,9 @@ urlpatterns = [
...
@@ -192,6 +192,9 @@ urlpatterns = [
# perform random task (delete later)
# perform random task (delete later)
url
(
r'^get-random-number/$'
,
api
.
TestRandom
.
as_view
()),
url
(
r'^get-random-number/$'
,
api
.
TestRandom
.
as_view
()),
# perform random task (delete later)
url
(
r'^display-upcoming-lectures/$'
,
api
.
DisplayUpcomingLecturesAPI
.
as_view
()),
...
...
LectureSummarizingApp/Voice Recorder.py
0 → 100644
View file @
bcb44959
import
sounddevice
as
sd
from
scipy.io.wavfile
import
write
import
wavio
as
wv
# Sampling frequency
freq
=
44100
# Recording duration
duration
=
10
# Start recorder with the given values of
# duration and sample frequency
recording
=
sd
.
rec
(
int
(
duration
*
freq
),
samplerate
=
freq
,
channels
=
2
)
# Record audio for the given number of seconds
sd
.
wait
()
# This will convert the NumPy array to an audio
# file with the given sampling frequency
write
(
"recording0.wav"
,
freq
,
recording
)
#Convert the NumPy array to audio file
wv
.
write
(
"recording1.wav"
,
recording
,
freq
,
sampwidth
=
2
)
\ No newline at end of file
LectureSummarizingApp/models.py
View file @
bcb44959
...
@@ -54,3 +54,4 @@ class LectureNotices (models.Model):
...
@@ -54,3 +54,4 @@ class LectureNotices (models.Model):
def
__str__
(
self
):
def
__str__
(
self
):
return
self
.
lecture_notice_id
return
self
.
lecture_notice_id
LectureSummarizingApp/templates/LectureSummarizingApp/RecordLecture.html
0 → 100644
View file @
bcb44959
{% extends 'FirstApp/template.html' %}
<!DOCTYPE html>
<html
lang=
"en"
>
<head>
<meta
charset=
"UTF-8"
>
<title>
Lecture Recording
</title>
</head>
<body>
% block javascript %}
{% load static %}
<!-- Bootstrap core JavaScript-->
<script
src=
"{% static 'FirstApp/vendor/jquery/jquery.min.js' %}"
></script>
<script
src=
"{% static 'FirstApp/vendor/bootstrap/js/bootstrap.bundle.min.js' %}"
></script>
<!-- Page level plugins -->
<script
src=
"{% static 'FirstApp/vendor/datatables/jquery.dataTables.min.js' %}"
></script>
<script
src=
"{% static 'FirstApp/vendor/datatables/dataTables.bootstrap4.min.js' %}"
></script>
<!-- Page level custom scripts -->
<script
src=
"{% static 'FirstApp/js/demo/datatables-demo.js' %}"
></script>
<!-- Core plugin JavaScript-->
<script
src=
"{% static 'FirstApp/vendor/jquery-easing/jquery.easing.min.js' %}"
></script>
<!-- Load TensorFlow.js -->
<script
src=
"https://unpkg.com/@tensorflow/tfjs"
></script>
<!-- Load Posenet -->
<script
src=
"https://unpkg.com/@tensorflow-models/posenet"
>
</script>
{% endblock %}
<div
id=
"wrapper"
>
<div
id=
"content-wrapper"
class=
"d-flex flex-column"
>
<div
id=
"content"
>
{% block 'container-fluid' %}
<div
class=
"container-fluid"
>
{% load static %}
<div
class=
"d-sm-flex align-items-center justify-content-between mb-4"
>
<h1
class=
"h3 mb-0 text-gray-800"
>
Lecture Record
</h1>
</div>
<div>
<button
TYPE=
"button"
class=
"btn btn-success audio_process"
>
Start Recording
</button>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
\ No newline at end of file
LectureSummarizingApp/urls.py
View file @
bcb44959
...
@@ -8,6 +8,7 @@ router = routers.DefaultRouter()
...
@@ -8,6 +8,7 @@ router = routers.DefaultRouter()
urlpatterns
=
[
urlpatterns
=
[
path
(
'lecture'
,
views
.
summarization
),
path
(
'lecture'
,
views
.
summarization
),
path
(
'record'
,
views
.
lectureRecord
),
# API to retrieve lecture summarizing details
# API to retrieve lecture summarizing details
...
...
LectureSummarizingApp/views.py
View file @
bcb44959
...
@@ -6,6 +6,14 @@ from .models import LectureAudio, LectureAudioNoiseRemoved, LectureSpeechToText,
...
@@ -6,6 +6,14 @@ from .models import LectureAudio, LectureAudioNoiseRemoved, LectureSpeechToText,
from
.serializer
import
LectureAudioSerializer
,
LectureAudioNoiseRemovedSerializer
,
LectureAudioSummarySerializer
,
\
from
.serializer
import
LectureAudioSerializer
,
LectureAudioNoiseRemovedSerializer
,
LectureAudioSummarySerializer
,
\
LectureSpeechToTextSerializer
,
LectureNoticesSerializer
LectureSpeechToTextSerializer
,
LectureNoticesSerializer
def
lectureRecord
(
request
):
lecture_audio
=
LectureAudio
.
objects
.
all
()
lecture_audio_ser
=
LectureAudioSerializer
(
lecture_audio
,
many
=
True
)
print
(
'lecture record data: '
,
lecture_audio_ser
.
data
)
return
render
(
request
,
"LectureSummarizationApp/RecordLecture.html"
)
# Views used in Lecture Summarization
# Views used in Lecture Summarization
...
@@ -109,3 +117,4 @@ class lectureSummaryList(APIView):
...
@@ -109,3 +117,4 @@ class lectureSummaryList(APIView):
notice_text
=
request
.
data
[
"notice_text"
]
notice_text
=
request
.
data
[
"notice_text"
]
)
.
save
()
)
.
save
()
return
Response
({
"response"
:
request
.
data
})
return
Response
({
"response"
:
request
.
data
})
integrated_slpes/urls.py
View file @
bcb44959
...
@@ -24,5 +24,6 @@ urlpatterns = [
...
@@ -24,5 +24,6 @@ urlpatterns = [
path
(
'attendance/'
,
include
(
'AttendanceApp.urls'
)),
path
(
'attendance/'
,
include
(
'AttendanceApp.urls'
)),
path
(
'lecturer/'
,
include
(
'MonitorLecturerApp.urls'
)),
path
(
'lecturer/'
,
include
(
'MonitorLecturerApp.urls'
)),
# path('lecturer/', include('MonitorLecturerApp.urls')),
# path('lecturer/', include('MonitorLecturerApp.urls')),
path
(
'summary/'
,
include
(
'LectureSummarizingApp.urls'
))
path
(
'summary/'
,
include
(
'LectureSummarizingApp.urls'
)),
path
(
'record/'
,
include
(
'LectureSummarizingApp.urls'
))
]
]
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment