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
3d96314a
Commit
3d96314a
authored
Jan 06, 2021
by
LiniEisha
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
audio recorder
parent
b3ff7439
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
101 additions
and
89 deletions
+101
-89
LectureSummarizingApp/api.py
LectureSummarizingApp/api.py
+4
-1
LectureSummarizingApp/noiseRemove.py
LectureSummarizingApp/noiseRemove.py
+41
-32
LectureSummarizingApp/templates/LectureSummarizingApp/RecordLecture.html
...ingApp/templates/LectureSummarizingApp/RecordLecture.html
+54
-54
LectureSummarizingApp/urls.py
LectureSummarizingApp/urls.py
+1
-1
LectureSummarizingApp/views.py
LectureSummarizingApp/views.py
+1
-1
No files found.
LectureSummarizingApp/api.py
View file @
3d96314a
...
...
@@ -7,6 +7,7 @@ from LectureSummarizingApp.serializer import LectureAudioSerializer, LectureAudi
LectureSpeechToTextSerializer
,
LectureAudioSummarySerializer
,
LectureNoticesSerializer
from
.
import
speech_to_text
as
stt
from
.
import
noiseRemove
as
nr
# APIs used in Lecture Summarizing Component
...
...
@@ -47,7 +48,9 @@ class audioToTextList(APIView):
print
(
'video name: '
,
video_name
)
stt
.
speech_to_text
(
video_name
)
nr
.
noise_removal
(
video_name
)
# stt.speech_to_text(video_name)
return
Response
({
"response"
:
"successful"
...
...
LectureSummarizingApp/noiseRemove.py
View file @
3d96314a
...
...
@@ -4,54 +4,63 @@ from scipy.io.wavfile import read
from
scipy.io.wavfile
import
write
from
scipy
import
signal
import
matplotlib.pyplot
as
mplt
import
os
#get_ipython().magic('matplotlib inline')
(
Frequency
,
array
)
=
read
(
'lectures/Lecture01.wav'
)
len
(
array
)
def
noise_removal
(
video_name
):
mplt
.
plot
(
array
)
mplt
.
title
(
'Original Signal Spectrum'
)
mplt
.
xlabel
(
'Frequency(Hz)'
)
mplt
.
ylabel
(
'Amplitude'
)
BASE_DIR
=
os
.
path
.
dirname
(
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
)))
LECTURE_VIDEO_DIR
=
os
.
path
.
join
(
BASE_DIR
,
"LectureSummarizingApp
\\
lectures
\\
{}"
.
format
(
video_name
))
fourierTransformation
=
sip
.
fft
(
array
)
# (Frequency, array) = read('lectures/Lecture01.wav')
# (Frequency, array) = read('lectures/{}'.format(video_name))
(
Frequency
,
array
)
=
read
(
LECTURE_VIDEO_DIR
)
scale
=
sip
.
linspace
(
0
,
Frequency
,
len
(
array
)
)
len
(
array
)
mplt
.
stem
(
scale
[
0
:
5000
],
nump
.
abs
(
fourierTransformation
[
0
:
5000
]),
'r'
)
mplt
.
title
(
'Signal spectrum after FFT
'
)
mplt
.
xlabel
(
'Frequency(Hz)'
)
mplt
.
ylabel
(
'Amplitude'
)
mplt
.
plot
(
array
)
mplt
.
title
(
'Original Signal Spectrum
'
)
mplt
.
xlabel
(
'Frequency(Hz)'
)
mplt
.
ylabel
(
'Amplitude'
)
fourierTransformation
=
sip
.
fft
(
array
)
guassianNoise
=
nump
.
random
.
rand
(
len
(
fourierTransformation
))
scale
=
sip
.
linspace
(
0
,
Frequency
,
len
(
array
))
mplt
.
stem
(
scale
[
0
:
5000
],
nump
.
abs
(
fourierTransformation
[
0
:
5000
]),
'r'
)
mplt
.
title
(
'Signal spectrum after FFT'
)
mplt
.
xlabel
(
'Frequency(Hz)'
)
mplt
.
ylabel
(
'Amplitude'
)
NewSound
=
guassianNoise
+
array
write
(
"New-Sound-Added-With-Guassian-Noise.wav"
,
Frequency
,
NewSound
)
guassianNoise
=
nump
.
random
.
rand
(
len
(
fourierTransformation
)
)
u
,
v
=
signal
.
butter
(
5
,
1000
/
(
Frequency
/
2
),
btype
=
'highpass'
)
filteredSignal
=
signal
.
lfilter
(
u
,
v
,
NewSound
)
NewSound
=
guassianNoise
+
array
# plotting the signal.
mplt
.
plot
(
filteredSignal
)
mplt
.
title
(
'Highpass Filter'
)
mplt
.
xlabel
(
'Frequency(Hz)'
)
mplt
.
ylabel
(
'Amplitude'
)
write
(
"New-Sound-Added-With-Guassian-Noise.wav"
,
Frequency
,
NewSound
)
# ButterWorth low-filter
x
,
y
=
signal
.
butter
(
5
,
380
/
(
Frequency
/
2
),
btype
=
'lowpass'
)
u
,
v
=
signal
.
butter
(
5
,
1000
/
(
Frequency
/
2
),
btype
=
'highpass'
)
# Applying the filter to the signal
newFilteredSignal
=
signal
.
lfilter
(
x
,
y
,
filteredSignal
)
filteredSignal
=
signal
.
lfilter
(
u
,
v
,
NewSound
)
# plotting the signal.
mplt
.
plot
(
newF
ilteredSignal
)
mplt
.
title
(
'Low
pass Filter'
)
mplt
.
xlabel
(
'Frequency(Hz)'
)
mplt
.
ylabel
(
'Amplitude'
)
# plotting the signal.
mplt
.
plot
(
f
ilteredSignal
)
mplt
.
title
(
'High
pass Filter'
)
mplt
.
xlabel
(
'Frequency(Hz)'
)
mplt
.
ylabel
(
'Amplitude'
)
write
(
"removed.wav"
,
Frequency
,
nump
.
int16
(
newFilteredSignal
/
nump
.
max
(
nump
.
abs
(
newFilteredSignal
))
*
32767
))
\ No newline at end of file
# ButterWorth low-filter
x
,
y
=
signal
.
butter
(
5
,
380
/
(
Frequency
/
2
),
btype
=
'lowpass'
)
# Applying the filter to the signal
newFilteredSignal
=
signal
.
lfilter
(
x
,
y
,
filteredSignal
)
# plotting the signal.
mplt
.
plot
(
newFilteredSignal
)
mplt
.
title
(
'Lowpass Filter'
)
mplt
.
xlabel
(
'Frequency(Hz)'
)
mplt
.
ylabel
(
'Amplitude'
)
write
(
"removed.wav"
,
Frequency
,
nump
.
int16
(
newFilteredSignal
/
nump
.
max
(
nump
.
abs
(
newFilteredSignal
))
*
32767
))
\ No newline at end of file
LectureSummarizingApp/templates/LectureSummarizingApp/RecordLecture.html
View file @
3d96314a
{% 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
<!--{% 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 @
3d96314a
...
...
@@ -8,7 +8,7 @@ router = routers.DefaultRouter()
urlpatterns
=
[
path
(
'lecture'
,
views
.
summarization
),
path
(
'record'
,
views
.
lectureRecord
),
#
path('record', views.lectureRecord),
# API to retrieve lecture summarizing details
...
...
LectureSummarizingApp/views.py
View file @
3d96314a
...
...
@@ -13,7 +13,7 @@ def lectureRecord(request):
print
(
'lecture record data: '
,
lecture_audio_ser
.
data
)
return
render
(
request
,
"LectureSummariz
ation
App/RecordLecture.html"
)
return
render
(
request
,
"LectureSummariz
ing
App/RecordLecture.html"
)
# Views used in Lecture Summarization
...
...
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