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
...
@@ -7,6 +7,7 @@ from LectureSummarizingApp.serializer import LectureAudioSerializer, LectureAudi
LectureSpeechToTextSerializer
,
LectureAudioSummarySerializer
,
LectureNoticesSerializer
LectureSpeechToTextSerializer
,
LectureAudioSummarySerializer
,
LectureNoticesSerializer
from
.
import
speech_to_text
as
stt
from
.
import
speech_to_text
as
stt
from
.
import
noiseRemove
as
nr
# APIs used in Lecture Summarizing Component
# APIs used in Lecture Summarizing Component
...
@@ -47,7 +48,9 @@ class audioToTextList(APIView):
...
@@ -47,7 +48,9 @@ class audioToTextList(APIView):
print
(
'video name: '
,
video_name
)
print
(
'video name: '
,
video_name
)
stt
.
speech_to_text
(
video_name
)
nr
.
noise_removal
(
video_name
)
# stt.speech_to_text(video_name)
return
Response
({
return
Response
({
"response"
:
"successful"
"response"
:
"successful"
...
...
LectureSummarizingApp/noiseRemove.py
View file @
3d96314a
...
@@ -4,54 +4,63 @@ from scipy.io.wavfile import read
...
@@ -4,54 +4,63 @@ from scipy.io.wavfile import read
from
scipy.io.wavfile
import
write
from
scipy.io.wavfile
import
write
from
scipy
import
signal
from
scipy
import
signal
import
matplotlib.pyplot
as
mplt
import
matplotlib.pyplot
as
mplt
import
os
#get_ipython().magic('matplotlib inline')
#get_ipython().magic('matplotlib inline')
(
Frequency
,
array
)
=
read
(
'lectures/Lecture01.wav'
)
len
(
array
)
def
noise_removal
(
video_name
):
mplt
.
plot
(
array
)
BASE_DIR
=
os
.
path
.
dirname
(
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
)))
mplt
.
title
(
'Original Signal Spectrum'
)
LECTURE_VIDEO_DIR
=
os
.
path
.
join
(
BASE_DIR
,
"LectureSummarizingApp
\\
lectures
\\
{}"
.
format
(
video_name
))
mplt
.
xlabel
(
'Frequency(Hz)'
)
mplt
.
ylabel
(
'Amplitude'
)
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
.
plot
(
array
)
mplt
.
title
(
'Signal spectrum after FFT
'
)
mplt
.
title
(
'Original Signal Spectrum
'
)
mplt
.
xlabel
(
'Frequency(Hz)'
)
mplt
.
xlabel
(
'Frequency(Hz)'
)
mplt
.
ylabel
(
'Amplitude'
)
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.
write
(
"New-Sound-Added-With-Guassian-Noise.wav"
,
Frequency
,
NewSound
)
mplt
.
plot
(
filteredSignal
)
mplt
.
title
(
'Highpass Filter'
)
mplt
.
xlabel
(
'Frequency(Hz)'
)
mplt
.
ylabel
(
'Amplitude'
)
# ButterWorth low-filter
u
,
v
=
signal
.
butter
(
5
,
1000
/
(
Frequency
/
2
),
btype
=
'highpass'
)
x
,
y
=
signal
.
butter
(
5
,
380
/
(
Frequency
/
2
),
btype
=
'lowpass'
)
# Applying the filter to the signal
filteredSignal
=
signal
.
lfilter
(
u
,
v
,
NewSound
)
newFilteredSignal
=
signal
.
lfilter
(
x
,
y
,
filteredSignal
)
# plotting the signal.
# plotting the signal.
mplt
.
plot
(
newF
ilteredSignal
)
mplt
.
plot
(
f
ilteredSignal
)
mplt
.
title
(
'Low
pass Filter'
)
mplt
.
title
(
'High
pass Filter'
)
mplt
.
xlabel
(
'Frequency(Hz)'
)
mplt
.
xlabel
(
'Frequency(Hz)'
)
mplt
.
ylabel
(
'Amplitude'
)
mplt
.
ylabel
(
'Amplitude'
)
write
(
"removed.wav"
,
Frequency
,
nump
.
int16
(
newFilteredSignal
/
nump
.
max
(
nump
.
abs
(
newFilteredSignal
))
*
32767
))
# ButterWorth low-filter
\ No newline at end of file
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' %}
<!--{% extends 'FirstApp/template.html' %}-->
<!DOCTYPE html>
<!--<!DOCTYPE html>-->
<html
lang=
"en"
>
<!--<html lang="en">-->
<head>
<!--<head>-->
<meta
charset=
"UTF-8"
>
<!-- <meta charset="UTF-8">-->
<title>
Lecture Recording
</title>
<!-- <title>Lecture Recording</title>-->
</head>
<!--</head>-->
<body>
<!--<body>-->
% block javascript %}
<!--% block javascript %}-->
{% load static %}
<!--{% load static %}-->
<!-- Bootstrap core JavaScript-->
<!--<!– Bootstrap core JavaScript–>-->
<script
src=
"{% static 'FirstApp/vendor/jquery/jquery.min.js' %}"
></script>
<!--<script src="{% static 'FirstApp/vendor/jquery/jquery.min.js' %}"></script>-->
<script
src=
"{% static 'FirstApp/vendor/bootstrap/js/bootstrap.bundle.min.js' %}"
></script>
<!--<script src="{% static 'FirstApp/vendor/bootstrap/js/bootstrap.bundle.min.js' %}"></script>-->
<!-- Page level plugins -->
<!--<!– Page level plugins –>-->
<script
src=
"{% static 'FirstApp/vendor/datatables/jquery.dataTables.min.js' %}"
></script>
<!--<script src="{% static 'FirstApp/vendor/datatables/jquery.dataTables.min.js' %}"></script>-->
<script
src=
"{% static 'FirstApp/vendor/datatables/dataTables.bootstrap4.min.js' %}"
></script>
<!--<script src="{% static 'FirstApp/vendor/datatables/dataTables.bootstrap4.min.js' %}"></script>-->
<!-- Page level custom scripts -->
<!--<!– Page level custom scripts –>-->
<script
src=
"{% static 'FirstApp/js/demo/datatables-demo.js' %}"
></script>
<!--<script src="{% static 'FirstApp/js/demo/datatables-demo.js' %}"></script>-->
<!-- Core plugin JavaScript-->
<!--<!– Core plugin JavaScript–>-->
<script
src=
"{% static 'FirstApp/vendor/jquery-easing/jquery.easing.min.js' %}"
></script>
<!--<script src="{% static 'FirstApp/vendor/jquery-easing/jquery.easing.min.js' %}"></script>-->
<!-- Load TensorFlow.js -->
<!--<!– Load TensorFlow.js –>-->
<script
src=
"https://unpkg.com/@tensorflow/tfjs"
></script>
<!--<script src="https://unpkg.com/@tensorflow/tfjs"></script>-->
<!-- Load Posenet -->
<!--<!– Load Posenet –>-->
<script
src=
"https://unpkg.com/@tensorflow-models/posenet"
>
<!--<script src="https://unpkg.com/@tensorflow-models/posenet">-->
</script>
<!--</script>-->
{% endblock %}
<!--{% endblock %}-->
<div
id=
"wrapper"
>
<!--<div id="wrapper">-->
<div
id=
"content-wrapper"
class=
"d-flex flex-column"
>
<!-- <div id="content-wrapper" class="d-flex flex-column">-->
<div
id=
"content"
>
<!-- <div id="content">-->
{% block 'container-fluid' %}
<!-- {% block 'container-fluid' %}-->
<div
class=
"container-fluid"
>
<!-- <div class="container-fluid">-->
{% load static %}
<!-- {% load static %}-->
<div
class=
"d-sm-flex align-items-center justify-content-between mb-4"
>
<!-- <div class="d-sm-flex align-items-center justify-content-between mb-4">-->
<h1
class=
"h3 mb-0 text-gray-800"
>
Lecture Record
</h1>
<!-- <h1 class="h3 mb-0 text-gray-800">Lecture Record</h1>-->
</div>
<!-- </div>-->
<div>
<!-- <div>-->
<button
TYPE=
"button"
class=
"btn btn-success audio_process"
>
Start Recording
</button>
<!-- <button TYPE="button" class="btn btn-success audio_process">Start Recording</button>-->
</div>
<!-- </div>-->
</div>
<!-- </div>-->
</div>
<!-- </div>-->
</div>
<!-- </div>-->
</div>
<!--</div>-->
</body>
<!--</body>-->
</html>
<!--</html>-->
\ No newline at end of file
\ No newline at end of file
LectureSummarizingApp/urls.py
View file @
3d96314a
...
@@ -8,7 +8,7 @@ router = routers.DefaultRouter()
...
@@ -8,7 +8,7 @@ router = routers.DefaultRouter()
urlpatterns
=
[
urlpatterns
=
[
path
(
'lecture'
,
views
.
summarization
),
path
(
'lecture'
,
views
.
summarization
),
path
(
'record'
,
views
.
lectureRecord
),
#
path('record', views.lectureRecord),
# API to retrieve lecture summarizing details
# API to retrieve lecture summarizing details
...
...
LectureSummarizingApp/views.py
View file @
3d96314a
...
@@ -13,7 +13,7 @@ def lectureRecord(request):
...
@@ -13,7 +13,7 @@ def lectureRecord(request):
print
(
'lecture record data: '
,
lecture_audio_ser
.
data
)
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
# 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