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
58b6c3fd
Commit
58b6c3fd
authored
Jan 06, 2021
by
I.K Seneviratne
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/QA_RELEASE' into monitoring_student_behavior_IT17138000
parents
8551c77e
63ce8fd8
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
202 additions
and
16 deletions
+202
-16
FirstApp/templates/FirstApp/template.html
FirstApp/templates/FirstApp/template.html
+1
-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
MonitorLecturerApp/api.py
MonitorLecturerApp/api.py
+11
-5
MonitorLecturerApp/logic/lecturer_batch_process.py
MonitorLecturerApp/logic/lecturer_batch_process.py
+50
-6
MonitorLecturerApp/serializers.py
MonitorLecturerApp/serializers.py
+46
-3
integrated_slpes/urls.py
integrated_slpes/urls.py
+2
-1
No files found.
FirstApp/templates/FirstApp/template.html
View file @
58b6c3fd
...
...
@@ -118,6 +118,7 @@
<div
id=
"collapseThree"
class=
"collapse"
aria-labelledby=
"headingThree"
data-parent=
"#accordionSidebar"
>
<div
class=
"bg-white py-2 collapse-inner rounded"
>
<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>
</div>
</div>
...
...
LectureSummarizingApp/Voice Recorder.py
0 → 100644
View file @
58b6c3fd
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 @
58b6c3fd
...
...
@@ -54,3 +54,4 @@ class LectureNotices (models.Model):
def
__str__
(
self
):
return
self
.
lecture_notice_id
LectureSummarizingApp/templates/LectureSummarizingApp/RecordLecture.html
0 → 100644
View file @
58b6c3fd
{% 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 @
58b6c3fd
...
...
@@ -8,6 +8,7 @@ router = routers.DefaultRouter()
urlpatterns
=
[
path
(
'lecture'
,
views
.
summarization
),
path
(
'record'
,
views
.
lectureRecord
),
# API to retrieve lecture summarizing details
...
...
LectureSummarizingApp/views.py
View file @
58b6c3fd
...
...
@@ -6,6 +6,14 @@ from .models import LectureAudio, LectureAudioNoiseRemoved, LectureSpeechToText,
from
.serializer
import
LectureAudioSerializer
,
LectureAudioNoiseRemovedSerializer
,
LectureAudioSummarySerializer
,
\
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
...
...
@@ -108,4 +116,5 @@ class lectureSummaryList(APIView):
lecture_audio_id
=
request
.
data
[
"lecture_audio_id"
],
notice_text
=
request
.
data
[
"notice_text"
]
)
.
save
()
return
Response
({
"response"
:
request
.
data
})
\ No newline at end of file
return
Response
({
"response"
:
request
.
data
})
MonitorLecturerApp/api.py
View file @
58b6c3fd
...
...
@@ -28,12 +28,13 @@ class LecturerVideoAPI(APIView):
def
post
(
self
,
request
):
serializer
=
LectureRecordedVideoSerializer
(
data
=
request
.
data
)
data
=
{}
if
serializer
.
is_valid
(
raise_exception
=
ValueError
):
# serializer.create(validated_data=request.data)
serializer
.
create
(
validated_data
=
request
.
data
)
data
=
serializer
.
create
(
validated_data
=
request
.
data
)
return
Response
(
serializer
.
data
,
status
=
status
.
HTTP_201_CREATED
)
return
Response
(
data
,
status
=
status
.
HTTP_201_CREATED
)
##### END OF LECTURER VIDEO SECTION #####
...
...
@@ -59,7 +60,10 @@ class ActivityRecognitionAPI(APIView):
walking_count
=
percentages
[
"walking_perct"
]
)
.
save
()
return
Response
({
"response"
:
percentages
})
return
Response
({
"response"
:
percentages
,
"created"
:
True
})
def
post
(
self
,
request
):
pass
...
...
@@ -103,7 +107,8 @@ class ProcessLecturerFrameRecognitionsAPI(APIView):
return
Response
({
"frame_recognitions"
:
frame_recognitions
,
"fps"
:
fps
"fps"
:
fps
,
"created"
:
True
})
...
...
@@ -247,7 +252,8 @@ class ProcessLectureAudioAnalysis(APIView):
return
Response
({
"response"
:
"success"
"response"
:
"success"
,
"created"
:
True
},
status
=
status
.
HTTP_201_CREATED
)
...
...
MonitorLecturerApp/logic/lecturer_batch_process.py
View file @
58b6c3fd
import
requests
import
json
# this method lists down the main methods that need to be executed when the lecturer performance module is under operation
def
lecturer_batch_process
(
video_name
,
audio_name
):
is_all_processed
=
False
# As the first step, calculate the lectuer activity details
lecturer_activity_resp
=
requests
.
get
(
'http://127.0.0.1:8000/activities/?video_name='
+
video_name
)
# lecturer_activity_resp = requests.get('http://127.0.0.1:8000/activities/?video_name=' + video_name)
lecturer_activity_resp
=
requests
.
get
(
'http://127.0.0.1:8000/activities/'
,
params
=
{
'video_name'
:
video_name
})
# if the lecturer activity is created
if
lecturer_activity_resp
.
json
()[
'created'
]:
# save the lecturer video frame recognitions
# lecturer_video_frame_recognitions_resp = requests.get('http://127.0.0.1:8000/process-lecturer-video-frame-recognitions/?video_name=' + video_name)
lecturer_video_frame_recognitions_resp
=
requests
.
get
(
'http://127.0.0.1:8000/process-lecturer-video-frame-recognitions/'
,
params
=
{
'video_name'
:
video_name
})
# save the lecturer video frame recognitions
lecturer_video_frame_recognitions_resp
=
requests
.
get
(
'http://127.0.0.1:8000/process-lecturer-video-frame-recognitions/?video_name='
+
video_name
)
# if the lecture video frame recognitions are created
if
lecturer_video_frame_recognitions_resp
.
json
()[
'created'
]:
# processing the lecture audio
lecture_audio_text_resp
=
requests
.
get
(
'http://127.0.0.1:8000/lecturer/process-lecture-audio-analysis'
)
# processing the lecture audio
lecture_audio_text_resp
=
requests
.
get
(
'http://127.0.0.1:8000/lecturer/process-lecture-audio-analysis'
)
# if the lecturer audio text is processed
if
lecture_audio_text_resp
.
json
()[
'created'
]:
is_all_processed
=
True
return
is_all_processed
# this method will save the lecturer video details
def
save_lecturer_video_details
(
video
):
lecturer_video_resp
=
requests
.
post
(
'http://127.0.0.1:8000/lecturer-video'
,
video
)
\ No newline at end of file
headers
=
{
"Content-Type"
:
"application/json"
}
# convert the data into JSON string
video_json_str
=
json
.
dumps
(
video
)
lecturer_video_resp
=
requests
.
post
(
url
=
'http://127.0.0.1:8000/lecturer/lecturer-video/'
,
data
=
video_json_str
,
headers
=
headers
)
response
=
lecturer_video_resp
.
json
()
return
response
[
0
]
# if __name__ == '__main__':
#
# video = {
# "lecturer": 1,
# "subject": 16,
# "lecturer_date": "2020-12-09",
# "lecture_video_name": "Video_test_19.mp4",
# "lecture_video_length": "00:45:06"
# }
#
# response = save_lecturer_video_details(video)
#
# print('response: ', response)
\ No newline at end of file
MonitorLecturerApp/serializers.py
View file @
58b6c3fd
...
...
@@ -7,10 +7,9 @@ from .models import RegisterTeacher, LecturerActivityFrameRecognitions
from
.models
import
LecturerAudioText
,
LecturerVideoMetaData
,
LecturerVideo
,
LectureRecordedVideo
from
FirstApp.logic
import
id_generator
as
ig
import
datetime
class
RegisterTeacherSerializer
(
serializers
.
ModelSerializer
):
class
Meta
:
model
=
RegisterTeacher
...
...
@@ -39,6 +38,46 @@ class LectureRecordedVideoSerializer(serializers.ModelSerializer):
model
=
LectureRecordedVideo
fields
=
'__all__'
# this method will validate the input data
def
to_internal_value
(
self
,
data
):
lecturer
=
None
subject
=
None
lecturer_data
=
data
.
get
(
'lecturer'
)
subject_data
=
data
.
get
(
'subject'
)
# serialize the lecturer data
lecturer
=
Lecturer
.
objects
.
filter
(
id
=
lecturer_data
)
subject
=
Subject
.
objects
.
filter
(
id
=
subject_data
)
lecturer_ser_data
=
LecturerSerializer
(
lecturer
,
many
=
True
)
.
data
[
0
]
subject_ser_data
=
SubjectSerializer
(
subject
,
many
=
True
)
.
data
[
0
]
# retrieve the last lecture video details
last_lec_video
=
LectureRecordedVideo
.
objects
.
order_by
(
'lecture_video_id'
)
.
last
()
# create the next lecture video id
new_lecture_video_id
=
ig
.
generate_new_id
(
last_lec_video
.
lecture_video_id
)
# if both subject and lecturer details are available
if
len
(
lecturer
)
==
1
&
len
(
subject
)
==
1
:
str_video_length
=
data
.
get
(
'lecture_video_length'
)
video_length_parts
=
str_video_length
.
split
(
':'
)
video_length
=
datetime
.
timedelta
(
minutes
=
int
(
video_length_parts
[
0
]),
seconds
=
int
(
video_length_parts
[
1
]),
milliseconds
=
int
(
video_length_parts
[
2
]))
# this data will be passed as validated data
validated_data
=
{
'lecture_video_id'
:
new_lecture_video_id
,
'lecturer'
:
lecturer_ser_data
,
'subject'
:
subject_ser_data
,
'lecturer_date'
:
data
.
get
(
'lecturer_date'
),
'lecture_video_name'
:
data
.
get
(
'lecture_video_name'
),
'lecture_video_length'
:
video_length
}
return
super
(
LectureRecordedVideoSerializer
,
self
)
.
to_internal_value
(
validated_data
)
# this method will override the 'create' method
def
create
(
self
,
validated_data
):
lecturer
=
None
...
...
@@ -73,8 +112,12 @@ class LectureRecordedVideoSerializer(serializers.ModelSerializer):
lecture_video_length
=
video_length
)
# retrieve the created object
created_lecture_video
=
LectureRecordedVideo
.
objects
.
filter
(
lecture_video_id
=
lecture_video
)
create_lecture_video_ser
=
LectureRecordedVideoSerializer
(
created_lecture_video
,
many
=
True
)
create_lecture_video_ser_data
=
create_lecture_video_ser
.
data
return
lecture_video
return
create_lecture_video_ser_data
return
None
...
...
integrated_slpes/urls.py
View file @
58b6c3fd
...
...
@@ -24,5 +24,6 @@ urlpatterns = [
path
(
'attendance/'
,
include
(
'AttendanceApp.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