Commit 21895570 authored by LiniEisha's avatar LiniEisha

Integration

parent 325d7379
...@@ -9,6 +9,9 @@ def GetLectureNotice(notice_name): ...@@ -9,6 +9,9 @@ def GetLectureNotice(notice_name):
DESTINATION_DIR = os.path.join(BASE_DIR, "notices\\Notice_{}".format(notice_name)) DESTINATION_DIR = os.path.join(BASE_DIR, "notices\\Notice_{}".format(notice_name))
print('destination directory: ', DESTINATION_DIR) print('destination directory: ', DESTINATION_DIR)
print('starting the notice process')
text = '' text = ''
# read_lines = [line.rstrip('\n') for line in open(FILE_PATH, "r")] # read_lines = [line.rstrip('\n') for line in open(FILE_PATH, "r")]
# read_lines = [line.rstrip('\n') for line in open(FILE_PATH, "r")] # read_lines = [line.rstrip('\n') for line in open(FILE_PATH, "r")]
...@@ -65,4 +68,7 @@ def GetLectureNotice(notice_name): ...@@ -65,4 +68,7 @@ def GetLectureNotice(notice_name):
listToStr = ' '.join([str(elem) for elem in sentences_with_word]) listToStr = ' '.join([str(elem) for elem in sentences_with_word])
print('ending the notice process')
return text, listToStr return text, listToStr
\ No newline at end of file
...@@ -12,6 +12,9 @@ def LectureSummary(summary_name): ...@@ -12,6 +12,9 @@ def LectureSummary(summary_name):
DESTINATION_DIR = os.path.join(BASE_DIR, "summary\\Summary_{}".format(summary_name)) DESTINATION_DIR = os.path.join(BASE_DIR, "summary\\Summary_{}".format(summary_name))
print('destination directory: ', DESTINATION_DIR) print('destination directory: ', DESTINATION_DIR)
print('starting the summary process')
# Reading the file # Reading the file
nlp = pt_core_news_sm.load() nlp = pt_core_news_sm.load()
# file = open(DESTINATION_DIR, 'w') # file = open(DESTINATION_DIR, 'w')
...@@ -93,4 +96,6 @@ def LectureSummary(summary_name): ...@@ -93,4 +96,6 @@ def LectureSummary(summary_name):
# convert the summary list to a text # convert the summary list to a text
listToStr = ' '.join([str(elem) for elem in summary]) listToStr = ' '.join([str(elem) for elem in summary])
print('ending the summary process')
return text, listToStr return text, listToStr
\ No newline at end of file
...@@ -48,7 +48,7 @@ class LectureAudioAPI(APIView): ...@@ -48,7 +48,7 @@ class LectureAudioAPI(APIView):
class audioNoiseRemovedList(APIView): class AudioNoiseRemovedList(APIView):
def get(self, request): def get(self, request):
# lecture_audio_noise_removed = LectureAudioNoiseRemoved.objects.all() # lecture_audio_noise_removed = LectureAudioNoiseRemoved.objects.all()
...@@ -68,7 +68,7 @@ class audioNoiseRemovedList(APIView): ...@@ -68,7 +68,7 @@ class audioNoiseRemovedList(APIView):
# nr.noise_removalll(video_name) # 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,
...@@ -93,7 +93,7 @@ class audioNoiseRemovedList(APIView): ...@@ -93,7 +93,7 @@ class audioNoiseRemovedList(APIView):
return Response({"response": request.data}) return Response({"response": request.data})
class audioToTextList(APIView): class AudioToTextList(APIView):
def get(self, request): def get(self, request):
#lecture_speech_to_text_id = LectureSpeechToText.objects.all() #lecture_speech_to_text_id = LectureSpeechToText.objects.all()
...@@ -111,7 +111,7 @@ class audioToTextList(APIView): ...@@ -111,7 +111,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)
speech_to_text(speech_to_text_name) is_finished = 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,
......
...@@ -8,26 +8,37 @@ def summarization_batch_process(audio_id, audio_name): ...@@ -8,26 +8,37 @@ def summarization_batch_process(audio_id, audio_name):
is_all_processed = False is_all_processed = False
noise_removed_resp = requests.get('http://127.0.0.1:800/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-audio-noise-removed/', params={'id': audio_id, 'audio_name': audio_name})
print('response: ', noise_removed_resp.json())
if noise_removed_resp.json()['response'] == 200: if noise_removed_resp.json()['response'] == 200:
print('successful noise removed response')
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:800/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-audio-to-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:
print('successful audio to text response')
summary_name = audio_name + '.txt' summary_name = audio_name + '.txt'
summary_resp = requests.get('http://127.0.0.1:800/summary/lecture-summary', params={'id': audio_id, 'lecture_summary_name': summary_name}) summary_resp = requests.get('http://127.0.0.1:8000/summary/lecture-summary/', params={'id': audio_id, 'lecture_summary_name': summary_name})
if summary_resp.json()['response'] == 200: if summary_resp.json()['response'] == 200:
notice_resp = requests.get('http://127.0.0.1:800/summary/lecture-notices', params={'id': audio_id, 'lecture_notice_name': summary_name}) print('successful summary response')
notice_resp = requests.get('http://127.0.0.1:8000/summary/lecture-notices/', params={'id': audio_id, 'lecture_notice_name': summary_name})
if notice_resp.json()['response'] == 200: if notice_resp.json()['response'] == 200:
print('successful notice response')
is_all_processed = True is_all_processed = True
...@@ -54,9 +65,9 @@ def save_lecturer_audio(lecturer_audio): ...@@ -54,9 +65,9 @@ def save_lecturer_audio(lecturer_audio):
return response return response
# this is a test method (delete later) # # this is a test method (delete later)
if __name__ == '__main__': # if __name__ == '__main__':
audio_id = 1 # audio_id = 1
audio_name = 'Lecture01.wav' # audio_name = 'Lecture01.wav'
#
summarization_batch_process(audio_id=audio_id, audio_name=audio_name) # summarization_batch_process(audio_id=audio_id, audio_name=audio_name)
\ No newline at end of file \ No newline at end of file
...@@ -10,6 +10,8 @@ def noise_removal(video_name): ...@@ -10,6 +10,8 @@ def noise_removal(video_name):
# sample_directory = 'lectures/' # sample_directory = 'lectures/'
# sample_path = sample_directory + sample_file # sample_path = sample_directory + sample_file
print('starting the noise removal process')
BASE_DIR = os.path.dirname(os.path.abspath(__file__)) BASE_DIR = os.path.dirname(os.path.abspath(__file__))
LECTURE_VIDEO_DIR = os.path.join(BASE_DIR, "lectures\\{}".format(video_name)) LECTURE_VIDEO_DIR = os.path.join(BASE_DIR, "lectures\\{}".format(video_name))
...@@ -27,6 +29,8 @@ def noise_removal(video_name): ...@@ -27,6 +29,8 @@ def noise_removal(video_name):
output_file(destination=DESTINATION_DIR, filename=video_name, a=a, sr=sr) output_file(destination=DESTINATION_DIR, filename=video_name, a=a, sr=sr)
print('ending the noise removal process')
return a, sr return a, sr
......
...@@ -4,6 +4,7 @@ import os ...@@ -4,6 +4,7 @@ import os
def speech_to_text(speech_to_text_name): def speech_to_text(speech_to_text_name):
print('starting the speech_to_text process')
#calling the Recognizer() #calling the Recognizer()
r = sr.Recognizer() r = sr.Recognizer()
...@@ -25,4 +26,8 @@ def speech_to_text(speech_to_text_name): ...@@ -25,4 +26,8 @@ def speech_to_text(speech_to_text_name):
except: except:
file.write('error') file.write('error')
file.close() file.close()
\ No newline at end of file
print('ending the speech_to_text process')
return True
...@@ -14,9 +14,9 @@ urlpatterns = [ ...@@ -14,9 +14,9 @@ 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-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