Commit f55f532c authored by LiniEisha's avatar LiniEisha

FrontEnd

parent c69a4c9e
...@@ -6,4 +6,5 @@ from LectureSummarizingApp.models import * ...@@ -6,4 +6,5 @@ from LectureSummarizingApp.models import *
admin.site.register(LectureAudio) admin.site.register(LectureAudio)
admin.site.register(LectureAudioNoiseRemoved) admin.site.register(LectureAudioNoiseRemoved)
admin.site.register(LectureSpeechToText) admin.site.register(LectureSpeechToText)
admin.site.register(LectureNotices)
admin.site.register(LectureAudioSummary) admin.site.register(LectureAudioSummary)
...@@ -4,7 +4,7 @@ from rest_framework.response import Response ...@@ -4,7 +4,7 @@ from rest_framework.response import Response
from LectureSummarizingApp.models import LectureAudio, LectureAudioNoiseRemoved, LectureSpeechToText, \ from LectureSummarizingApp.models import LectureAudio, LectureAudioNoiseRemoved, LectureSpeechToText, \
LectureAudioSummary, LectureNotices LectureAudioSummary, LectureNotices
from LectureSummarizingApp.serializer import LectureAudioSerializer, LectureAudioNoiseRemovedSerializer, \ from LectureSummarizingApp.serializer import LectureAudioSerializer, LectureAudioNoiseRemovedSerializer, \
LectureSpeechToTextSerializer, LectureAudioSummarySerializer LectureSpeechToTextSerializer, LectureAudioSummarySerializer, LectureNoticesSerializer
# this API will retrieve lecture audio details # this API will retrieve lecture audio details
...@@ -66,17 +66,20 @@ class lectureSummaryList(APIView): ...@@ -66,17 +66,20 @@ class lectureSummaryList(APIView):
).save() ).save()
return Response({"response": request.data}) return Response({"response": request.data})
class lectureNoticeList(APIView):
class lectureNoticeList(APIView):
def get(self, request): def get(self, request):
lecture_notice_id = LectureNotices.objects.all() lecture_notice_id = LectureNotices.objects.all()
serializer = LectureSpeechToTextSerializer(lecture_notice_id, many=True) serializer = LectureNoticesSerializer(lecture_notice_id, many=True)
return Response(serializer.data) return Response(serializer.data)
def post(self, request): def post(self, request):
LectureSpeechToText( LectureNotices(
lecture_notice_id=request.data["lecture_notice_id"], lecture_notice_id=request.data["lecture_notice_id"],
lecture_audio_id=request.data["lecture_audio_id"], lecture_audio_id=request.data["lecture_audio_id"],
notice_text=request.data["notice_text"] notice_text=request.data["notice_text"]
).save() ).save()
return Response({"response": request.data}) return Response({"response": request.data})
...@@ -19,7 +19,7 @@ class LectureAudio (models.Model): ...@@ -19,7 +19,7 @@ class LectureAudio (models.Model):
class LectureAudioNoiseRemoved (models.Model): class LectureAudioNoiseRemoved (models.Model):
lecture_audio_noise_removed_id = models.CharField(max_length=10) 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() lecturer_date = models.DateField()
lecture_audio_name = models.CharField(max_length=50) lecture_audio_name = models.CharField(max_length=50)
lecture_audio_length = models.DurationField() lecture_audio_length = models.DurationField()
...@@ -46,6 +46,7 @@ class LectureAudioSummary (models.Model): ...@@ -46,6 +46,7 @@ class LectureAudioSummary (models.Model):
def __str__(self): def __str__(self):
return self.lecture_audio_summary_id return self.lecture_audio_summary_id
class LectureNotices (models.Model): class LectureNotices (models.Model):
lecture_notice_id = models.CharField(max_length=10) lecture_notice_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)
......
...@@ -19,16 +19,16 @@ def read_file(file_name): ...@@ -19,16 +19,16 @@ def read_file(file_name):
return y, sr return y, sr
'''CENTROID''' # '''CENTROID'''
#
def reduce_noise_centroid_s(y, sr): # def reduce_noise_centroid_s(y, sr):
#
cent = librosa.feature.spectral_centroid(y=y, sr=sr) # cent = librosa.feature.spectral_centroid(y=y, sr=sr)
threshold_h = np.max(cent) # threshold_h = np.max(cent)
threshold_l = np.min(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) # 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) # y_cleaned = less_noise(y)
return y_cleaned # return y_cleaned
...@@ -111,19 +111,19 @@ for s in lectures: ...@@ -111,19 +111,19 @@ for s in lectures:
y, sr = read_file(filename) 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_lowshelf = mfcc_lowshelf(y, sr)
y_reduced_mfcc_highshelf = mffc_highshelf(y, sr) y_reduced_mfcc_highshelf = mffc_highshelf(y, sr)
# trimming silences # 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_up, time_trimmed = trim_silence(mfcc_lowshelf)
y_reduced_mfcc_down, time_trimmed = trim_silence(mffc_highshelf) 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_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_reduced_mfcc_down, sr, '_mfcc_down')
output_file('lectures_trimmed_noise_reduced/' ,filename, y, sr, '_org') # output_file('lectures_trimmed_noise_reduced/' ,filename, y, sr, '_org')
...@@ -23,7 +23,8 @@ class LectureAudioNoiseRemovedSerializer(serializers.ModelSerializer): ...@@ -23,7 +23,8 @@ class LectureAudioNoiseRemovedSerializer(serializers.ModelSerializer):
class LectureSpeechToTextSerializer(serializers.ModelSerializer): class LectureSpeechToTextSerializer(serializers.ModelSerializer):
lecture_speech_to_text_id = LectureAudioNoiseRemovedSerializer() # lecture_speech_to_text_id = LectureAudioNoiseRemovedSerializer()
lecture_audio_id = LectureAudioSerializer()
class Meta: class Meta:
model = LectureSpeechToText model = LectureSpeechToText
...@@ -31,7 +32,8 @@ class LectureSpeechToTextSerializer(serializers.ModelSerializer): ...@@ -31,7 +32,8 @@ class LectureSpeechToTextSerializer(serializers.ModelSerializer):
class LectureAudioSummarySerializer(serializers.ModelSerializer): class LectureAudioSummarySerializer(serializers.ModelSerializer):
lecture_audio_noise_removed_id = LectureSpeechToTextSerializer() # lecture_audio_noise_removed_id = LectureSpeechToTextSerializer()
lecture_audio_id = LectureAudioSerializer()
class Meta: class Meta:
model = LectureAudioSummary model = LectureAudioSummary
...@@ -39,8 +41,10 @@ class LectureAudioSummarySerializer(serializers.ModelSerializer): ...@@ -39,8 +41,10 @@ class LectureAudioSummarySerializer(serializers.ModelSerializer):
class LectureNoticesSerializer(serializers.ModelSerializer): class LectureNoticesSerializer(serializers.ModelSerializer):
lecture_audio_noise_removed_id = LectureSpeechToTextSerializer() # lecture_audio_noise_removed_id = LectureSpeechToTextSerializer()
lecture_audio_id = LectureAudioSerializer()
class Meta: class Meta:
model = LectureAudioSummary # model = LectureAudioSummary
model = LectureNotices
fields = '__all__' fields = '__all__'
\ No newline at end of file
...@@ -6,13 +6,35 @@ from rest_framework.response import Response ...@@ -6,13 +6,35 @@ from rest_framework.response import Response
from rest_framework import viewsets from rest_framework import viewsets
from .models import LectureAudio, LectureAudioNoiseRemoved, LectureSpeechToText, LectureAudioSummary, LectureNotices from .models import LectureAudio, LectureAudioNoiseRemoved, LectureSpeechToText, LectureAudioSummary, LectureNotices
from .serializer import LectureAudioSerializer, LectureAudioNoiseRemovedSerializer, LectureAudioSummarySerializer, \ from .serializer import LectureAudioSerializer, LectureAudioNoiseRemovedSerializer, LectureAudioSummarySerializer, \
LectureSpeechToTextSerializer LectureSpeechToTextSerializer, LectureNoticesSerializer
# Create your views here. # Create your views here.
def summarization(request): 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): class audioList(APIView):
...@@ -79,11 +101,11 @@ class lectureSummaryList(APIView): ...@@ -79,11 +101,11 @@ class lectureSummaryList(APIView):
def get(self, request): def get(self, request):
lecture_notice_id = LectureNotices.objects.all() lecture_notice_id = LectureNotices.objects.all()
serializer = LectureSpeechToTextSerializer(lecture_notice_id, many=True) serializer = LectureNoticesSerializer(lecture_notice_id, many=True)
return Response(serializer.data) return Response(serializer.data)
def post(self, request): def post(self, request):
LectureSpeechToText( LectureNotices(
lecture_notice_id=request.data["lecture_notice_id"], lecture_notice_id=request.data["lecture_notice_id"],
lecture_audio_id=request.data["lecture_audio_id"], lecture_audio_id=request.data["lecture_audio_id"],
notice_text=request.data["notice_text"] notice_text=request.data["notice_text"]
......
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