Commit 26eedac2 authored by I.K Seneviratne's avatar I.K Seneviratne

Merge remote-tracking branch 'origin/QA_RELEASE' into monitoring_student_behavior_IT17138000

parents 74e79b26 6af26c62
...@@ -23,6 +23,11 @@ from .voice_recorder import AudioRecorder ...@@ -23,6 +23,11 @@ from .voice_recorder import AudioRecorder
class LectureAudioAPI(APIView): class LectureAudioAPI(APIView):
def get(self,request):
return Response({
"response": Response.status_code
})
def post(self, request): def post(self, request):
lecture_audio = LectureAudio.objects.all().order_by('lecturer_date') lecture_audio = LectureAudio.objects.all().order_by('lecturer_date')
lecture_audio_serializer = LectureAudioSerializer(lecture_audio, many=True) lecture_audio_serializer = LectureAudioSerializer(lecture_audio, many=True)
...@@ -42,12 +47,16 @@ class LectureAudioAPI(APIView): ...@@ -42,12 +47,16 @@ class LectureAudioAPI(APIView):
lecturer =request.data["lecturer"], lecturer =request.data["lecturer"],
subject = request.data["subject"] subject = request.data["subject"]
).save() ).save()
# get the created lecture audio instance
created_lecture_audio = LectureAudio.objects.filter(lecture_audio_id=new_audio_id)
return Response({ return Response({
"response": Response.status_code "response": Response.status_code,
"audio_id": int(created_lecture_audio[0].id)
}) })
class AudioNoiseRemovedList(APIView): class AudioNoiseRemovedList(APIView):
def get(self, request): def get(self, request):
...@@ -66,9 +75,9 @@ class AudioNoiseRemovedList(APIView): ...@@ -66,9 +75,9 @@ class AudioNoiseRemovedList(APIView):
# generate new id for audio noise removed # generate new id for audio noise removed
new_audio_noise_removed_id = generate_new_id(audio_noise_removed_list.lecture_audio_noise_removed_id) new_audio_noise_removed_id = generate_new_id(audio_noise_removed_list.lecture_audio_noise_removed_id)
print('inside the noise removal api')
# nr.noise_removalll(video_name) noise_removal(audio_name)
a, sr = noise_removal(audio_name)
LectureAudioNoiseRemoved( LectureAudioNoiseRemoved(
lecture_audio_noise_removed_id=new_audio_noise_removed_id, lecture_audio_noise_removed_id=new_audio_noise_removed_id,
...@@ -78,6 +87,8 @@ class AudioNoiseRemovedList(APIView): ...@@ -78,6 +87,8 @@ class AudioNoiseRemovedList(APIView):
lecture_audio_length=fake_duration lecture_audio_length=fake_duration
).save() ).save()
print('ending the noise removal api')
return Response({ return Response({
"response": Response.status_code "response": Response.status_code
}) })
...@@ -90,6 +101,7 @@ class AudioNoiseRemovedList(APIView): ...@@ -90,6 +101,7 @@ class AudioNoiseRemovedList(APIView):
lecture_audio_name=request.data["lecture_audio_name"], lecture_audio_name=request.data["lecture_audio_name"],
lecture_audio_length=request.data["lecture_audio_length"] lecture_audio_length=request.data["lecture_audio_length"]
).save() ).save()
return Response({"response": request.data}) return Response({"response": request.data})
...@@ -111,7 +123,7 @@ class AudioToTextList(APIView): ...@@ -111,7 +123,7 @@ class AudioToTextList(APIView):
# generate new id for speech to text file # generate new id for speech to text file
new_speech_to_text_id = "LST0001" if audio_to_text_list is None else generate_new_id(audio_to_text_list.lecture_speech_to_text_id) new_speech_to_text_id = "LST0001" if audio_to_text_list is None else generate_new_id(audio_to_text_list.lecture_speech_to_text_id)
is_finished = speech_to_text(speech_to_text_name) speech_to_text(speech_to_text_name)
LectureSpeechToText( LectureSpeechToText(
lecture_speech_to_text_id=new_speech_to_text_id, lecture_speech_to_text_id=new_speech_to_text_id,
...@@ -202,3 +214,67 @@ class LectureNoticeList(APIView): ...@@ -202,3 +214,67 @@ class LectureNoticeList(APIView):
).save() ).save()
return Response({"response": request.data}) return Response({"response": request.data})
class TestMethod(APIView):
def get(self, request):
# lecture_audio_noise_removed = LectureAudioNoiseRemoved.objects.all()
# serializer = LectureAudioNoiseRemovedSerializer(lecture_audio_noise_removed, many=True)
audio_noise_removed_list = LectureAudioNoiseRemoved.objects.order_by('lecture_audio_noise_removed_id').last()
audio_name = request.query_params.get("audio_name")
id = int(request.query_params.get("id"))
current_date = datetime.datetime.now().date()
fake_duration = datetime.timedelta(minutes=2, seconds=10, milliseconds=00)
# generate new id for audio noise removed
new_audio_noise_removed_id = generate_new_id(audio_noise_removed_list.lecture_audio_noise_removed_id)
print('inside the noise removal api')
noise_removal(audio_name)
LectureAudioNoiseRemoved(
lecture_audio_noise_removed_id=new_audio_noise_removed_id,
lecture_audio_id_id=id,
lecturer_date=current_date,
lecture_audio_name=audio_name,
lecture_audio_length=fake_duration
).save()
print('ending the noise removal api')
return Response({
"response": Response.status_code
})
class TestMethod02(APIView):
def get(self, request):
# lecture_speech_to_text_id = LectureSpeechToText.objects.all()
# serializer = LectureSpeechToTextSerializer(lecture_speech_to_text_id, many=True)
audio_to_text_list = LectureSpeechToText.objects.order_by('lecture_speech_to_text_id').last()
# return Response(serializer.data)
speech_to_text_name = request.query_params.get("speech_to_text_name")
print('file name: ', speech_to_text_name)
id = int(request.query_params.get("id"))
# id = request.query_params.get("id")
# generate new id for speech to text file
new_speech_to_text_id = "LST0001" if audio_to_text_list is None else generate_new_id(
audio_to_text_list.lecture_speech_to_text_id)
speech_to_text(speech_to_text_name)
LectureSpeechToText(
lecture_speech_to_text_id=new_speech_to_text_id,
lecture_audio_id_id=id,
audio_original_text=speech_to_text_name
).save()
return Response({
"response": Response.status_code
})
\ No newline at end of file
...@@ -10,7 +10,7 @@ def summarization_batch_process(audio_id, audio_name): ...@@ -10,7 +10,7 @@ def summarization_batch_process(audio_id, audio_name):
noise_removed_resp = requests.get('http://127.0.0.1:8000/summary/lecture-audio-noise-removed/', params={'id': audio_id, 'audio_name': audio_name}) noise_removed_resp = requests.get('http://127.0.0.1:8000/summary/lecture-noise/', params={'id': audio_id, 'audio_name': audio_name})
print('response: ', noise_removed_resp.json()) print('response: ', noise_removed_resp.json())
...@@ -21,7 +21,7 @@ def summarization_batch_process(audio_id, audio_name): ...@@ -21,7 +21,7 @@ def summarization_batch_process(audio_id, audio_name):
audio_root_name = audio_name.split('.')[0] audio_root_name = audio_name.split('.')[0]
speech_to_text_name = audio_root_name + '.txt' speech_to_text_name = audio_root_name + '.txt'
audio_text_resp = requests.get('http://127.0.0.1:8000/summary/lecture-audio-to-text/', params={'id': audio_id, 'speech_to_text_name': speech_to_text_name}) audio_text_resp = requests.get('http://127.0.0.1:8000/summary/lecture-text/', params={'id': audio_id, 'speech_to_text_name': speech_to_text_name})
if audio_text_resp.json()['response'] == 200: if audio_text_resp.json()['response'] == 200:
......
...@@ -31,8 +31,6 @@ def noise_removal(video_name): ...@@ -31,8 +31,6 @@ def noise_removal(video_name):
print('ending the noise removal process') print('ending the noise removal process')
return a, sr
'''MFCC''' '''MFCC'''
......
...@@ -10,7 +10,7 @@ def speech_to_text(speech_to_text_name): ...@@ -10,7 +10,7 @@ def speech_to_text(speech_to_text_name):
BASE_DIR = os.path.dirname(os.path.abspath(__file__)) BASE_DIR = os.path.dirname(os.path.abspath(__file__))
# FILE_PATH = os.path.join(BASE_DIR, "noise_removed_lectures\\noise_removed_lectures_{}".format(speech_to_text_name)) # FILE_PATH = os.path.join(BASE_DIR, "noise_removed_lectures\\noise_removed_lectures_{}".format(speech_to_text_name))
FILE_PATH = os.path.join(BASE_DIR, "noise_removed_lectures\\{}".format(speech_to_text_name)) FILE_PATH = os.path.join(BASE_DIR, "lectures\\{}".format(speech_to_text_name))
print('file path: ', FILE_PATH) print('file path: ', FILE_PATH)
# DESTINATION_DIR = os.path.dirname(os.path.join(BASE_DIR, "LectureSummarizingApp\\speechToText\\{}.txt".format(speech_to_text_name))) # DESTINATION_DIR = os.path.dirname(os.path.join(BASE_DIR, "LectureSummarizingApp\\speechToText\\{}.txt".format(speech_to_text_name)))
DESTINATION_DIR = os.path.join(BASE_DIR, "speechToText\\{}.txt".format(speech_to_text_name)) DESTINATION_DIR = os.path.join(BASE_DIR, "speechToText\\{}.txt".format(speech_to_text_name))
...@@ -30,4 +30,3 @@ def speech_to_text(speech_to_text_name): ...@@ -30,4 +30,3 @@ def speech_to_text(speech_to_text_name):
print('ending the speech_to_text process') print('ending the speech_to_text process')
return True
...@@ -45,7 +45,7 @@ ...@@ -45,7 +45,7 @@
alert('speech to text file name: ' + speech_to_text_name); alert('speech to text file name: ' + speech_to_text_name);
//call the fetch API //call the fetch API
fetch('http://127.0.0.1:8000/summary/lecture-audio-to-text/?speech_to_text_name=' + speech_to_text_name + '&id=' + id) fetch('http://127.0.0.1:8000/summary/lecture-text/?speech_to_text_name=' + speech_to_text_name + '&id=' + id)
.then((res) => res.json()) .then((res) => res.json())
.then((out) => handleSpeechToText(out.response)) .then((out) => handleSpeechToText(out.response))
.catch((err) => alert('error: ' + err)) .catch((err) => alert('error: ' + err))
...@@ -68,12 +68,14 @@ ...@@ -68,12 +68,14 @@
alert('audio name: ' + audio_name); alert('audio name: ' + audio_name);
//call the fetch API //call the fetch API
fetch('http://127.0.0.1:8000/summary/lecture-audio-noise-removed/?audio_name=' + audio_name + '&id=' + id) fetch('http://127.0.0.1:8000/summary/lecture-noise/?audio_name=' + audio_name + '&id=' + id)
.then((res) => res.json()) .then((res) => res.json())
.then((out) => handleNoiseRemoved(out.response)) .then((out) => handleNoiseRemoved(out.response))
.catch((err) => alert('error: ' + err)) .catch((err) => alert('error: ' + err))
}); });
//this function will handle the success respopnse for noise removed //this function will handle the success respopnse for noise removed
function handleNoiseRemoved(response) { function handleNoiseRemoved(response) {
...@@ -167,7 +169,6 @@ ...@@ -167,7 +169,6 @@
<span class="font-italic">No Recordings</span> <span class="font-italic">No Recordings</span>
</div> </div>
{% else %} {% else %}
#lecture list
<div class="table-responsive"> <div class="table-responsive">
<table class="table table-bordered" id="datatable"> <table class="table table-bordered" id="datatable">
<thead> <thead>
...@@ -228,7 +229,6 @@ ...@@ -228,7 +229,6 @@
<span class="font-italic">No Recordings</span> <span class="font-italic">No Recordings</span>
</div> </div>
{% else %} {% else %}
#noise removes list
<div class="table-responsive"> <div class="table-responsive">
<table class="table table-bordered" id="datatable"> <table class="table table-bordered" id="datatable">
<thead> <thead>
......
...@@ -14,9 +14,13 @@ urlpatterns = [ ...@@ -14,9 +14,13 @@ urlpatterns = [
# API to retrieve lecture summarizing details # API to retrieve lecture summarizing details
url(r'^lecture-audio', api.LectureAudioAPI.as_view()), url(r'^lecture-audio', api.LectureAudioAPI.as_view()),
url(r'^lecture-audio-noise-removed/$', api.AudioNoiseRemovedList.as_view()), # url(r'^lecture-audio-noise-removed/$', api.AudioNoiseRemovedList.as_view()),
url(r'^lecture-audio-to-text/$', api.AudioToTextList.as_view()), url(r'^lecture-noise/$', api.TestMethod.as_view()),
url(r'^lecture-text/$', api.TestMethod02.as_view()),
# url(r'^lecture-audio-to-text/$', api.AudioToTextList.as_view()),
url(r'^lecture-summary/$', api.LectureSummaryList.as_view()), url(r'^lecture-summary/$', api.LectureSummaryList.as_view()),
......
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