Commit 3d96314a authored by LiniEisha's avatar LiniEisha

audio recorder

parent b3ff7439
...@@ -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"
......
...@@ -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(newFilteredSignal) mplt.plot(filteredSignal)
mplt.title('Lowpass Filter') mplt.title('Highpass 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
{% 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--> <!--&lt;!&ndash; Bootstrap core JavaScript&ndash;&gt;-->
<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 --> <!--&lt;!&ndash; Page level plugins &ndash;&gt;-->
<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 --> <!--&lt;!&ndash; Page level custom scripts &ndash;&gt;-->
<script src="{% static 'FirstApp/js/demo/datatables-demo.js' %}"></script> <!--<script src="{% static 'FirstApp/js/demo/datatables-demo.js' %}"></script>-->
<!-- Core plugin JavaScript--> <!--&lt;!&ndash; Core plugin JavaScript&ndash;&gt;-->
<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 --> <!--&lt;!&ndash; Load TensorFlow.js &ndash;&gt;-->
<script src="https://unpkg.com/@tensorflow/tfjs"></script> <!--<script src="https://unpkg.com/@tensorflow/tfjs"></script>-->
<!-- Load Posenet --> <!--&lt;!&ndash; Load Posenet &ndash;&gt;-->
<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
...@@ -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
......
...@@ -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, "LectureSummarizationApp/RecordLecture.html") return render(request, "LectureSummarizingApp/RecordLecture.html")
# Views used in Lecture Summarization # 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