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
f55f532c
Commit
f55f532c
authored
Sep 23, 2020
by
LiniEisha
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
FrontEnd
parent
c69a4c9e
Changes
7
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
399 additions
and
74 deletions
+399
-74
LectureSummarizingApp/admin.py
LectureSummarizingApp/admin.py
+1
-0
LectureSummarizingApp/api.py
LectureSummarizingApp/api.py
+16
-13
LectureSummarizingApp/models.py
LectureSummarizingApp/models.py
+2
-1
LectureSummarizingApp/noise.py
LectureSummarizingApp/noise.py
+15
-15
LectureSummarizingApp/serializer.py
LectureSummarizingApp/serializer.py
+8
-4
LectureSummarizingApp/templates/LectureSummarizingApp/summarization.html
...ingApp/templates/LectureSummarizingApp/summarization.html
+331
-37
LectureSummarizingApp/views.py
LectureSummarizingApp/views.py
+26
-4
No files found.
LectureSummarizingApp/admin.py
View file @
f55f532c
...
...
@@ -6,4 +6,5 @@ from LectureSummarizingApp.models import *
admin
.
site
.
register
(
LectureAudio
)
admin
.
site
.
register
(
LectureAudioNoiseRemoved
)
admin
.
site
.
register
(
LectureSpeechToText
)
admin
.
site
.
register
(
LectureNotices
)
admin
.
site
.
register
(
LectureAudioSummary
)
LectureSummarizingApp/api.py
View file @
f55f532c
...
...
@@ -4,7 +4,7 @@ from rest_framework.response import Response
from
LectureSummarizingApp.models
import
LectureAudio
,
LectureAudioNoiseRemoved
,
LectureSpeechToText
,
\
LectureAudioSummary
,
LectureNotices
from
LectureSummarizingApp.serializer
import
LectureAudioSerializer
,
LectureAudioNoiseRemovedSerializer
,
\
LectureSpeechToTextSerializer
,
LectureAudioSummarySerializer
LectureSpeechToTextSerializer
,
LectureAudioSummarySerializer
,
LectureNoticesSerializer
# this API will retrieve lecture audio details
...
...
@@ -66,17 +66,20 @@ class lectureSummaryList(APIView):
)
.
save
()
return
Response
({
"response"
:
request
.
data
})
class
lectureNoticeList
(
APIView
):
class
lectureNoticeList
(
APIView
):
def
get
(
self
,
request
):
lecture_notice_id
=
LectureNotices
.
objects
.
all
()
serializer
=
LectureSpeechToText
Serializer
(
lecture_notice_id
,
many
=
True
)
serializer
=
LectureNotices
Serializer
(
lecture_notice_id
,
many
=
True
)
return
Response
(
serializer
.
data
)
def
post
(
self
,
request
):
LectureSpeechToText
(
LectureNotices
(
lecture_notice_id
=
request
.
data
[
"lecture_notice_id"
],
lecture_audio_id
=
request
.
data
[
"lecture_audio_id"
],
notice_text
=
request
.
data
[
"notice_text"
]
)
.
save
()
return
Response
({
"response"
:
request
.
data
})
LectureSummarizingApp/models.py
View file @
f55f532c
...
...
@@ -19,7 +19,7 @@ class LectureAudio (models.Model):
class
LectureAudioNoiseRemoved
(
models
.
Model
):
lecture_audio_noise_removed_id
=
models
.
CharField
(
max_length
=
10
)
lecture_audio_id
=
models
.
ForeignKey
(
LectureAudio
,
on_delete
=
models
.
CASCADE
)
lecture_audio_id
=
models
.
ForeignKey
(
LectureAudio
,
on_delete
=
models
.
CASCADE
,
default
=
0
)
lecturer_date
=
models
.
DateField
()
lecture_audio_name
=
models
.
CharField
(
max_length
=
50
)
lecture_audio_length
=
models
.
DurationField
()
...
...
@@ -46,6 +46,7 @@ class LectureAudioSummary (models.Model):
def
__str__
(
self
):
return
self
.
lecture_audio_summary_id
class
LectureNotices
(
models
.
Model
):
lecture_notice_id
=
models
.
CharField
(
max_length
=
10
)
lecture_audio_id
=
models
.
ForeignKey
(
LectureAudio
,
on_delete
=
models
.
CASCADE
)
...
...
LectureSummarizingApp/noise.py
View file @
f55f532c
...
...
@@ -19,16 +19,16 @@ def read_file(file_name):
return
y
,
sr
'''CENTROID'''
def
reduce_noise_centroid_s
(
y
,
sr
):
cent
=
librosa
.
feature
.
spectral_centroid
(
y
=
y
,
sr
=
sr
)
threshold_h
=
np
.
max
(
cent
)
threshold_l
=
np
.
min
(
cent
)
less_noise
=
AudioEffectsChain
()
.
lowshelf
(
gain
=-
12.0
,
frequency
=
threshold_l
,
slope
=
0.5
)
.
highshelf
(
gain
=-
12.0
,
frequency
=
threshold_h
,
slope
=
0.5
)
.
limiter
(
gain
=
6.0
)
y_cleaned
=
less_noise
(
y
)
return
y_cleaned
#
'''CENTROID'''
#
#
def reduce_noise_centroid_s(y, sr):
#
#
cent = librosa.feature.spectral_centroid(y=y, sr=sr)
#
threshold_h = np.max(cent)
#
threshold_l = np.min(cent)
#
less_noise = AudioEffectsChain().lowshelf(gain=-12.0, frequency=threshold_l, slope=0.5).highshelf(gain=-12.0, frequency=threshold_h, slope=0.5).limiter(gain=6.0)
#
y_cleaned = less_noise(y)
#
return y_cleaned
...
...
@@ -111,19 +111,19 @@ for s in lectures:
y
,
sr
=
read_file
(
filename
)
y_reduced_centroid_s
=
reduce_noise_centroid_s
(
y
,
sr
)
#
y_reduced_centroid_s = reduce_noise_centroid_s(y, sr)
y_reduced_mfcc_lowshelf
=
mfcc_lowshelf
(
y
,
sr
)
y_reduced_mfcc_highshelf
=
mffc_highshelf
(
y
,
sr
)
# trimming silences
y_reduced_centroid_s
,
time_trimmed
=
trim_silence
(
y_reduced_centroid_s
)
#
y_reduced_centroid_s, time_trimmed = trim_silence(y_reduced_centroid_s)
y_reduced_mfcc_up
,
time_trimmed
=
trim_silence
(
mfcc_lowshelf
)
y_reduced_mfcc_down
,
time_trimmed
=
trim_silence
(
mffc_highshelf
)
output_file
(
'lectures_trimmed_noise_reduced/'
,
filename
,
y_reduced_centroid_s
,
sr
,
'_ctr_s'
)
#
output_file('lectures_trimmed_noise_reduced/' ,filename, y_reduced_centroid_s, sr, '_ctr_s')
output_file
(
'lectures_trimmed_noise_reduced/'
,
filename
,
y_reduced_mfcc_up
,
sr
,
'_mfcc_up'
)
output_file
(
'lectures_trimmed_noise_reduced/'
,
filename
,
y_reduced_mfcc_down
,
sr
,
'_mfcc_down'
)
output_file
(
'lectures_trimmed_noise_reduced/'
,
filename
,
y
,
sr
,
'_org'
)
#
output_file('lectures_trimmed_noise_reduced/' ,filename, y_reduced_mfcc_down, sr, '_mfcc_down')
#
output_file('lectures_trimmed_noise_reduced/' ,filename, y, sr, '_org')
LectureSummarizingApp/serializer.py
View file @
f55f532c
...
...
@@ -23,7 +23,8 @@ class LectureAudioNoiseRemovedSerializer(serializers.ModelSerializer):
class
LectureSpeechToTextSerializer
(
serializers
.
ModelSerializer
):
lecture_speech_to_text_id
=
LectureAudioNoiseRemovedSerializer
()
# lecture_speech_to_text_id = LectureAudioNoiseRemovedSerializer()
lecture_audio_id
=
LectureAudioSerializer
()
class
Meta
:
model
=
LectureSpeechToText
...
...
@@ -31,7 +32,8 @@ class LectureSpeechToTextSerializer(serializers.ModelSerializer):
class
LectureAudioSummarySerializer
(
serializers
.
ModelSerializer
):
lecture_audio_noise_removed_id
=
LectureSpeechToTextSerializer
()
# lecture_audio_noise_removed_id = LectureSpeechToTextSerializer()
lecture_audio_id
=
LectureAudioSerializer
()
class
Meta
:
model
=
LectureAudioSummary
...
...
@@ -39,8 +41,10 @@ class LectureAudioSummarySerializer(serializers.ModelSerializer):
class
LectureNoticesSerializer
(
serializers
.
ModelSerializer
):
lecture_audio_noise_removed_id
=
LectureSpeechToTextSerializer
()
# lecture_audio_noise_removed_id = LectureSpeechToTextSerializer()
lecture_audio_id
=
LectureAudioSerializer
()
class
Meta
:
model
=
LectureAudioSummary
# model = LectureAudioSummary
model
=
LectureNotices
fields
=
'__all__'
\ No newline at end of file
LectureSummarizingApp/templates/LectureSummarizingApp/summarization.html
View file @
f55f532c
This diff is collapsed.
Click to expand it.
LectureSummarizingApp/views.py
View file @
f55f532c
...
...
@@ -6,13 +6,35 @@ from rest_framework.response import Response
from
rest_framework
import
viewsets
from
.models
import
LectureAudio
,
LectureAudioNoiseRemoved
,
LectureSpeechToText
,
LectureAudioSummary
,
LectureNotices
from
.serializer
import
LectureAudioSerializer
,
LectureAudioNoiseRemovedSerializer
,
LectureAudioSummarySerializer
,
\
LectureSpeechToTextSerializer
LectureSpeechToTextSerializer
,
LectureNoticesSerializer
# Create your views here.
def
summarization
(
request
):
return
render
(
request
,
"LectureSummarizingApp/summarization.html"
)
lec_audio
=
LectureAudio
.
objects
.
all
()
lec_audio_serializer
=
LectureAudioSerializer
(
lec_audio
,
many
=
True
)
data
=
lec_audio_serializer
.
data
lec_noiseless_audio
=
LectureAudioNoiseRemoved
.
objects
.
all
()
lec_noiseless_audio_ser
=
LectureAudioNoiseRemovedSerializer
(
lec_noiseless_audio
,
many
=
True
)
noiseless_data
=
lec_noiseless_audio_ser
.
data
lec_text
=
LectureSpeechToText
.
objects
.
all
()
lec_text_ser
=
LectureSpeechToTextSerializer
(
lec_text
,
many
=
True
)
lecture_text_data
=
lec_text_ser
.
data
lec_summary
=
LectureAudioSummary
.
objects
.
all
()
lec_summary_ser
=
LectureAudioSummarySerializer
(
lec_summary
,
many
=
True
)
lec_summary_data
=
lec_summary_ser
.
data
lec_notice
=
LectureNotices
.
objects
.
all
()
lec_notice_ser
=
LectureNoticesSerializer
(
lec_notice
,
many
=
True
)
lec_notice_data
=
lec_notice_ser
.
data
return
render
(
request
,
"LectureSummarizingApp/summarization.html"
,
{
"lec_audio_data"
:
data
,
"noiseless_data"
:
noiseless_data
,
"lecture_text_data"
:
lecture_text_data
,
"lec_summary_data"
:
lec_summary_data
,
"lec_notice_data"
:
lec_notice_data
})
class
audioList
(
APIView
):
...
...
@@ -79,11 +101,11 @@ class lectureSummaryList(APIView):
def
get
(
self
,
request
):
lecture_notice_id
=
LectureNotices
.
objects
.
all
()
serializer
=
Lecture
SpeechToText
Serializer
(
lecture_notice_id
,
many
=
True
)
serializer
=
Lecture
Notices
Serializer
(
lecture_notice_id
,
many
=
True
)
return
Response
(
serializer
.
data
)
def
post
(
self
,
request
):
Lecture
SpeechToText
(
Lecture
Notices
(
lecture_notice_id
=
request
.
data
[
"lecture_notice_id"
],
lecture_audio_id
=
request
.
data
[
"lecture_audio_id"
],
notice_text
=
request
.
data
[
"notice_text"
]
...
...
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