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
26eedac2
Commit
26eedac2
authored
Jan 10, 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
74e79b26
6af26c62
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
94 additions
and
17 deletions
+94
-17
LectureSummarizingApp/api.py
LectureSummarizingApp/api.py
+81
-5
LectureSummarizingApp/lecture_audio_batch_process.py
LectureSummarizingApp/lecture_audio_batch_process.py
+2
-2
LectureSummarizingApp/noise.py
LectureSummarizingApp/noise.py
+0
-2
LectureSummarizingApp/speech_to_text.py
LectureSummarizingApp/speech_to_text.py
+1
-2
LectureSummarizingApp/templates/LectureSummarizingApp/summarization.html
...ingApp/templates/LectureSummarizingApp/summarization.html
+4
-4
LectureSummarizingApp/urls.py
LectureSummarizingApp/urls.py
+6
-2
No files found.
LectureSummarizingApp/api.py
View file @
26eedac2
...
@@ -23,6 +23,11 @@ from .voice_recorder import AudioRecorder
...
@@ -23,6 +23,11 @@ from .voice_recorder import AudioRecorder
class
LectureAudioAPI
(
APIView
):
class
LectureAudioAPI
(
APIView
):
def
get
(
self
,
request
):
return
Response
({
"response"
:
Response
.
status_code
})
def
post
(
self
,
request
):
def
post
(
self
,
request
):
lecture_audio
=
LectureAudio
.
objects
.
all
()
.
order_by
(
'lecturer_date'
)
lecture_audio
=
LectureAudio
.
objects
.
all
()
.
order_by
(
'lecturer_date'
)
lecture_audio_serializer
=
LectureAudioSerializer
(
lecture_audio
,
many
=
True
)
lecture_audio_serializer
=
LectureAudioSerializer
(
lecture_audio
,
many
=
True
)
...
@@ -42,12 +47,16 @@ class LectureAudioAPI(APIView):
...
@@ -42,12 +47,16 @@ class LectureAudioAPI(APIView):
lecturer
=
request
.
data
[
"lecturer"
],
lecturer
=
request
.
data
[
"lecturer"
],
subject
=
request
.
data
[
"subject"
]
subject
=
request
.
data
[
"subject"
]
)
.
save
()
)
.
save
()
# get the created lecture audio instance
created_lecture_audio
=
LectureAudio
.
objects
.
filter
(
lecture_audio_id
=
new_audio_id
)
return
Response
({
return
Response
({
"response"
:
Response
.
status_code
"response"
:
Response
.
status_code
,
"audio_id"
:
int
(
created_lecture_audio
[
0
]
.
id
)
})
})
class
AudioNoiseRemovedList
(
APIView
):
class
AudioNoiseRemovedList
(
APIView
):
def
get
(
self
,
request
):
def
get
(
self
,
request
):
...
@@ -66,9 +75,9 @@ class AudioNoiseRemovedList(APIView):
...
@@ -66,9 +75,9 @@ class AudioNoiseRemovedList(APIView):
# generate new id for audio noise removed
# generate new id for audio noise removed
new_audio_noise_removed_id
=
generate_new_id
(
audio_noise_removed_list
.
lecture_audio_noise_removed_id
)
new_audio_noise_removed_id
=
generate_new_id
(
audio_noise_removed_list
.
lecture_audio_noise_removed_id
)
print
(
'inside the noise removal api'
)
# nr.noise_removalll(video_name)
noise_removal
(
audio_name
)
a
,
sr
=
noise_removal
(
audio_name
)
LectureAudioNoiseRemoved
(
LectureAudioNoiseRemoved
(
lecture_audio_noise_removed_id
=
new_audio_noise_removed_id
,
lecture_audio_noise_removed_id
=
new_audio_noise_removed_id
,
...
@@ -78,6 +87,8 @@ class AudioNoiseRemovedList(APIView):
...
@@ -78,6 +87,8 @@ class AudioNoiseRemovedList(APIView):
lecture_audio_length
=
fake_duration
lecture_audio_length
=
fake_duration
)
.
save
()
)
.
save
()
print
(
'ending the noise removal api'
)
return
Response
({
return
Response
({
"response"
:
Response
.
status_code
"response"
:
Response
.
status_code
})
})
...
@@ -90,6 +101,7 @@ class AudioNoiseRemovedList(APIView):
...
@@ -90,6 +101,7 @@ class AudioNoiseRemovedList(APIView):
lecture_audio_name
=
request
.
data
[
"lecture_audio_name"
],
lecture_audio_name
=
request
.
data
[
"lecture_audio_name"
],
lecture_audio_length
=
request
.
data
[
"lecture_audio_length"
]
lecture_audio_length
=
request
.
data
[
"lecture_audio_length"
]
)
.
save
()
)
.
save
()
return
Response
({
"response"
:
request
.
data
})
return
Response
({
"response"
:
request
.
data
})
...
@@ -111,7 +123,7 @@ class AudioToTextList(APIView):
...
@@ -111,7 +123,7 @@ class AudioToTextList(APIView):
# generate new id for speech to text file
# generate new id for speech to text file
new_speech_to_text_id
=
"LST0001"
if
audio_to_text_list
is
None
else
generate_new_id
(
audio_to_text_list
.
lecture_speech_to_text_id
)
new_speech_to_text_id
=
"LST0001"
if
audio_to_text_list
is
None
else
generate_new_id
(
audio_to_text_list
.
lecture_speech_to_text_id
)
is_finished
=
speech_to_text
(
speech_to_text_name
)
speech_to_text
(
speech_to_text_name
)
LectureSpeechToText
(
LectureSpeechToText
(
lecture_speech_to_text_id
=
new_speech_to_text_id
,
lecture_speech_to_text_id
=
new_speech_to_text_id
,
...
@@ -202,3 +214,67 @@ class LectureNoticeList(APIView):
...
@@ -202,3 +214,67 @@ class LectureNoticeList(APIView):
)
.
save
()
)
.
save
()
return
Response
({
"response"
:
request
.
data
})
return
Response
({
"response"
:
request
.
data
})
class
TestMethod
(
APIView
):
def
get
(
self
,
request
):
# lecture_audio_noise_removed = LectureAudioNoiseRemoved.objects.all()
# serializer = LectureAudioNoiseRemovedSerializer(lecture_audio_noise_removed, many=True)
audio_noise_removed_list
=
LectureAudioNoiseRemoved
.
objects
.
order_by
(
'lecture_audio_noise_removed_id'
)
.
last
()
audio_name
=
request
.
query_params
.
get
(
"audio_name"
)
id
=
int
(
request
.
query_params
.
get
(
"id"
))
current_date
=
datetime
.
datetime
.
now
()
.
date
()
fake_duration
=
datetime
.
timedelta
(
minutes
=
2
,
seconds
=
10
,
milliseconds
=
00
)
# generate new id for audio noise removed
new_audio_noise_removed_id
=
generate_new_id
(
audio_noise_removed_list
.
lecture_audio_noise_removed_id
)
print
(
'inside the noise removal api'
)
noise_removal
(
audio_name
)
LectureAudioNoiseRemoved
(
lecture_audio_noise_removed_id
=
new_audio_noise_removed_id
,
lecture_audio_id_id
=
id
,
lecturer_date
=
current_date
,
lecture_audio_name
=
audio_name
,
lecture_audio_length
=
fake_duration
)
.
save
()
print
(
'ending the noise removal api'
)
return
Response
({
"response"
:
Response
.
status_code
})
class
TestMethod02
(
APIView
):
def
get
(
self
,
request
):
# lecture_speech_to_text_id = LectureSpeechToText.objects.all()
# serializer = LectureSpeechToTextSerializer(lecture_speech_to_text_id, many=True)
audio_to_text_list
=
LectureSpeechToText
.
objects
.
order_by
(
'lecture_speech_to_text_id'
)
.
last
()
# return Response(serializer.data)
speech_to_text_name
=
request
.
query_params
.
get
(
"speech_to_text_name"
)
print
(
'file name: '
,
speech_to_text_name
)
id
=
int
(
request
.
query_params
.
get
(
"id"
))
# id = request.query_params.get("id")
# generate new id for speech to text file
new_speech_to_text_id
=
"LST0001"
if
audio_to_text_list
is
None
else
generate_new_id
(
audio_to_text_list
.
lecture_speech_to_text_id
)
speech_to_text
(
speech_to_text_name
)
LectureSpeechToText
(
lecture_speech_to_text_id
=
new_speech_to_text_id
,
lecture_audio_id_id
=
id
,
audio_original_text
=
speech_to_text_name
)
.
save
()
return
Response
({
"response"
:
Response
.
status_code
})
\ No newline at end of file
LectureSummarizingApp/lecture_audio_batch_process.py
View file @
26eedac2
...
@@ -10,7 +10,7 @@ def summarization_batch_process(audio_id, audio_name):
...
@@ -10,7 +10,7 @@ def summarization_batch_process(audio_id, audio_name):
noise_removed_resp
=
requests
.
get
(
'http://127.0.0.1:8000/summary/lecture-
audio-noise-removed
/'
,
params
=
{
'id'
:
audio_id
,
'audio_name'
:
audio_name
})
noise_removed_resp
=
requests
.
get
(
'http://127.0.0.1:8000/summary/lecture-
noise
/'
,
params
=
{
'id'
:
audio_id
,
'audio_name'
:
audio_name
})
print
(
'response: '
,
noise_removed_resp
.
json
())
print
(
'response: '
,
noise_removed_resp
.
json
())
...
@@ -21,7 +21,7 @@ def summarization_batch_process(audio_id, audio_name):
...
@@ -21,7 +21,7 @@ def summarization_batch_process(audio_id, audio_name):
audio_root_name
=
audio_name
.
split
(
'.'
)[
0
]
audio_root_name
=
audio_name
.
split
(
'.'
)[
0
]
speech_to_text_name
=
audio_root_name
+
'.txt'
speech_to_text_name
=
audio_root_name
+
'.txt'
audio_text_resp
=
requests
.
get
(
'http://127.0.0.1:8000/summary/lecture-
audio-to-
text/'
,
params
=
{
'id'
:
audio_id
,
'speech_to_text_name'
:
speech_to_text_name
})
audio_text_resp
=
requests
.
get
(
'http://127.0.0.1:8000/summary/lecture-text/'
,
params
=
{
'id'
:
audio_id
,
'speech_to_text_name'
:
speech_to_text_name
})
if
audio_text_resp
.
json
()[
'response'
]
==
200
:
if
audio_text_resp
.
json
()[
'response'
]
==
200
:
...
...
LectureSummarizingApp/noise.py
View file @
26eedac2
...
@@ -31,8 +31,6 @@ def noise_removal(video_name):
...
@@ -31,8 +31,6 @@ def noise_removal(video_name):
print
(
'ending the noise removal process'
)
print
(
'ending the noise removal process'
)
return
a
,
sr
'''MFCC'''
'''MFCC'''
...
...
LectureSummarizingApp/speech_to_text.py
View file @
26eedac2
...
@@ -10,7 +10,7 @@ def speech_to_text(speech_to_text_name):
...
@@ -10,7 +10,7 @@ def speech_to_text(speech_to_text_name):
BASE_DIR
=
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
))
BASE_DIR
=
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
))
# FILE_PATH = os.path.join(BASE_DIR, "noise_removed_lectures\\noise_removed_lectures_{}".format(speech_to_text_name))
# FILE_PATH = os.path.join(BASE_DIR, "noise_removed_lectures\\noise_removed_lectures_{}".format(speech_to_text_name))
FILE_PATH
=
os
.
path
.
join
(
BASE_DIR
,
"
noise_removed_
lectures
\\
{}"
.
format
(
speech_to_text_name
))
FILE_PATH
=
os
.
path
.
join
(
BASE_DIR
,
"lectures
\\
{}"
.
format
(
speech_to_text_name
))
print
(
'file path: '
,
FILE_PATH
)
print
(
'file path: '
,
FILE_PATH
)
# DESTINATION_DIR = os.path.dirname(os.path.join(BASE_DIR, "LectureSummarizingApp\\speechToText\\{}.txt".format(speech_to_text_name)))
# DESTINATION_DIR = os.path.dirname(os.path.join(BASE_DIR, "LectureSummarizingApp\\speechToText\\{}.txt".format(speech_to_text_name)))
DESTINATION_DIR
=
os
.
path
.
join
(
BASE_DIR
,
"speechToText
\\
{}.txt"
.
format
(
speech_to_text_name
))
DESTINATION_DIR
=
os
.
path
.
join
(
BASE_DIR
,
"speechToText
\\
{}.txt"
.
format
(
speech_to_text_name
))
...
@@ -30,4 +30,3 @@ def speech_to_text(speech_to_text_name):
...
@@ -30,4 +30,3 @@ def speech_to_text(speech_to_text_name):
print
(
'ending the speech_to_text process'
)
print
(
'ending the speech_to_text process'
)
return
True
LectureSummarizingApp/templates/LectureSummarizingApp/summarization.html
View file @
26eedac2
...
@@ -45,7 +45,7 @@
...
@@ -45,7 +45,7 @@
alert
(
'
speech to text file name:
'
+
speech_to_text_name
);
alert
(
'
speech to text file name:
'
+
speech_to_text_name
);
//call the fetch API
//call the fetch API
fetch
(
'
http://127.0.0.1:8000/summary/lecture-
audio-to-
text/?speech_to_text_name=
'
+
speech_to_text_name
+
'
&id=
'
+
id
)
fetch
(
'
http://127.0.0.1:8000/summary/lecture-text/?speech_to_text_name=
'
+
speech_to_text_name
+
'
&id=
'
+
id
)
.
then
((
res
)
=>
res
.
json
())
.
then
((
res
)
=>
res
.
json
())
.
then
((
out
)
=>
handleSpeechToText
(
out
.
response
))
.
then
((
out
)
=>
handleSpeechToText
(
out
.
response
))
.
catch
((
err
)
=>
alert
(
'
error:
'
+
err
))
.
catch
((
err
)
=>
alert
(
'
error:
'
+
err
))
...
@@ -68,12 +68,14 @@
...
@@ -68,12 +68,14 @@
alert
(
'
audio name:
'
+
audio_name
);
alert
(
'
audio name:
'
+
audio_name
);
//call the fetch API
//call the fetch API
fetch
(
'
http://127.0.0.1:8000/summary/lecture-
audio-noise-removed
/?audio_name=
'
+
audio_name
+
'
&id=
'
+
id
)
fetch
(
'
http://127.0.0.1:8000/summary/lecture-
noise
/?audio_name=
'
+
audio_name
+
'
&id=
'
+
id
)
.
then
((
res
)
=>
res
.
json
())
.
then
((
res
)
=>
res
.
json
())
.
then
((
out
)
=>
handleNoiseRemoved
(
out
.
response
))
.
then
((
out
)
=>
handleNoiseRemoved
(
out
.
response
))
.
catch
((
err
)
=>
alert
(
'
error:
'
+
err
))
.
catch
((
err
)
=>
alert
(
'
error:
'
+
err
))
});
});
//this function will handle the success respopnse for noise removed
//this function will handle the success respopnse for noise removed
function
handleNoiseRemoved
(
response
)
{
function
handleNoiseRemoved
(
response
)
{
...
@@ -167,7 +169,6 @@
...
@@ -167,7 +169,6 @@
<span
class=
"font-italic"
>
No Recordings
</span>
<span
class=
"font-italic"
>
No Recordings
</span>
</div>
</div>
{% else %}
{% else %}
#lecture list
<div
class=
"table-responsive"
>
<div
class=
"table-responsive"
>
<table
class=
"table table-bordered"
id=
"datatable"
>
<table
class=
"table table-bordered"
id=
"datatable"
>
<thead>
<thead>
...
@@ -228,7 +229,6 @@
...
@@ -228,7 +229,6 @@
<span
class=
"font-italic"
>
No Recordings
</span>
<span
class=
"font-italic"
>
No Recordings
</span>
</div>
</div>
{% else %}
{% else %}
#noise removes list
<div
class=
"table-responsive"
>
<div
class=
"table-responsive"
>
<table
class=
"table table-bordered"
id=
"datatable"
>
<table
class=
"table table-bordered"
id=
"datatable"
>
<thead>
<thead>
...
...
LectureSummarizingApp/urls.py
View file @
26eedac2
...
@@ -14,9 +14,13 @@ urlpatterns = [
...
@@ -14,9 +14,13 @@ urlpatterns = [
# API to retrieve lecture summarizing details
# API to retrieve lecture summarizing details
url
(
r'^lecture-audio'
,
api
.
LectureAudioAPI
.
as_view
()),
url
(
r'^lecture-audio'
,
api
.
LectureAudioAPI
.
as_view
()),
url
(
r'^lecture-audio-noise-removed/$'
,
api
.
AudioNoiseRemovedList
.
as_view
()),
#
url(r'^lecture-audio-noise-removed/$', api.AudioNoiseRemovedList.as_view()),
url
(
r'^lecture-audio-to-text/$'
,
api
.
AudioToTextList
.
as_view
()),
url
(
r'^lecture-noise/$'
,
api
.
TestMethod
.
as_view
()),
url
(
r'^lecture-text/$'
,
api
.
TestMethod02
.
as_view
()),
# url(r'^lecture-audio-to-text/$', api.AudioToTextList.as_view()),
url
(
r'^lecture-summary/$'
,
api
.
LectureSummaryList
.
as_view
()),
url
(
r'^lecture-summary/$'
,
api
.
LectureSummaryList
.
as_view
()),
...
...
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