Commit 3d96314a authored by LiniEisha's avatar LiniEisha

audio recorder

parent b3ff7439
......@@ -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"
......
......@@ -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(newFilteredSignal)
mplt.title('Lowpass Filter')
mplt.xlabel('Frequency(Hz)')
mplt.ylabel('Amplitude')
# plotting the signal.
mplt.plot(filteredSignal)
mplt.title('Highpass 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
{% 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 %}-->
<!--&lt;!&ndash; Bootstrap core JavaScript&ndash;&gt;-->
<!--<script src="{% static 'FirstApp/vendor/jquery/jquery.min.js' %}"></script>-->
<!--<script src="{% static 'FirstApp/vendor/bootstrap/js/bootstrap.bundle.min.js' %}"></script>-->
<!--&lt;!&ndash; Page level plugins &ndash;&gt;-->
<!--<script src="{% static 'FirstApp/vendor/datatables/jquery.dataTables.min.js' %}"></script>-->
<!--<script src="{% static 'FirstApp/vendor/datatables/dataTables.bootstrap4.min.js' %}"></script>-->
<!--&lt;!&ndash; Page level custom scripts &ndash;&gt;-->
<!--<script src="{% static 'FirstApp/js/demo/datatables-demo.js' %}"></script>-->
<!--&lt;!&ndash; Core plugin JavaScript&ndash;&gt;-->
<!--<script src="{% static 'FirstApp/vendor/jquery-easing/jquery.easing.min.js' %}"></script>-->
<!--&lt;!&ndash; Load TensorFlow.js &ndash;&gt;-->
<!--<script src="https://unpkg.com/@tensorflow/tfjs"></script>-->
<!--&lt;!&ndash; Load Posenet &ndash;&gt;-->
<!--<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
......@@ -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
......
......@@ -13,7 +13,7 @@ def lectureRecord(request):
print('lecture record data: ', lecture_audio_ser.data)
return render(request, "LectureSummarizationApp/RecordLecture.html")
return render(request, "LectureSummarizingApp/RecordLecture.html")
# Views used in Lecture Summarization
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment