Commit 51a8aad4 authored by LiniEisha's avatar LiniEisha

Integrate

parent b96dbe0f
...@@ -10,9 +10,15 @@ def GetLectureNotice(notice_name): ...@@ -10,9 +10,15 @@ def GetLectureNotice(notice_name):
print('destination directory: ', DESTINATION_DIR) print('destination directory: ', DESTINATION_DIR)
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")]
for line in open(FILE_PATH, "r"):
text += line.rstrip('\n')
sentences_list = [] sentences_list = []
sentence_list = nltk.sent_tokenize(read_lines) sentence_list = nltk.sent_tokenize(text)
word_search = "important" word_search = "important"
sentences_with_word = [] sentences_with_word = []
for sentence in sentence_list: for sentence in sentence_list:
...@@ -55,7 +61,7 @@ def GetLectureNotice(notice_name): ...@@ -55,7 +61,7 @@ def GetLectureNotice(notice_name):
pdf.cell(200, 10, txt=x, ln=1, align='C') pdf.cell(200, 10, txt=x, ln=1, align='C')
# save the pdf with name .pdf # save the pdf with name .pdf
pdf.output("PDF_DESTINATION_DIR") # pdf.output("PDF_DESTINATION_DIR")
listToStr = ' '.join([str(elem) for elem in sentences_with_word]) listToStr = ' '.join([str(elem) for elem in sentences_with_word])
......
...@@ -88,7 +88,7 @@ def LectureSummary(summary_name): ...@@ -88,7 +88,7 @@ def LectureSummary(summary_name):
pdf.cell(200, 10, txt=x, ln=1, align='C') pdf.cell(200, 10, txt=x, ln=1, align='C')
# save the pdf with name .pdf # save the pdf with name .pdf
pdf.output(PDF_DESTINATION_DIR) # pdf.output(PDF_DESTINATION_DIR)
# 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])
......
...@@ -153,7 +153,7 @@ class LectureSummaryList(APIView): ...@@ -153,7 +153,7 @@ class LectureSummaryList(APIView):
audio_original_text=text, audio_original_text=text,
audio_summary=summary audio_summary=summary
).save() ).save()
return Response({"response": request.data}) return Response({"response": Response.status_code})
def post(self, request): def post(self, request):
LectureAudioSummary( LectureAudioSummary(
...@@ -188,7 +188,7 @@ class LectureNoticeList(APIView): ...@@ -188,7 +188,7 @@ class LectureNoticeList(APIView):
lecture_audio_id_id=id, lecture_audio_id_id=id,
notice_text=text notice_text=text
).save() ).save()
return Response({"response": request.data}) return Response({"response": Response.status_code})
......
...@@ -11,11 +11,11 @@ def noise_removal(video_name): ...@@ -11,11 +11,11 @@ def noise_removal(video_name):
# sample_path = sample_directory + sample_file # sample_path = sample_directory + sample_file
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) BASE_DIR = os.path.dirname(os.path.abspath(__file__))
LECTURE_VIDEO_DIR = os.path.join(BASE_DIR, "LectureSummarizingApp\\lectures\\{}".format(video_name)) LECTURE_VIDEO_DIR = os.path.join(BASE_DIR, "lectures\\{}".format(video_name))
print('lecture audio directory: ', LECTURE_VIDEO_DIR) print('lecture audio directory: ', LECTURE_VIDEO_DIR)
# DESTINATION_DIR = os.path.join(BASE_DIR, "LectureSummarizingApp\\noise_removed_lectures") # DESTINATION_DIR = os.path.join(BASE_DIR, "LectureSummarizingApp\\noise_removed_lectures")
DESTINATION_DIR = os.path.dirname(os.path.join(BASE_DIR, "LectureSummarizingApp\\noise_removed_lectures\\sample.txt")) DESTINATION_DIR = os.path.dirname(os.path.join(BASE_DIR, "noise_removed_lectures\\sample.txt"))
print('destination directory: ', DESTINATION_DIR) print('destination directory: ', DESTINATION_DIR)
# generating audio time series and a sampling rate (int) # generating audio time series and a sampling rate (int)
a, sr = librosa.load(path=LECTURE_VIDEO_DIR) a, sr = librosa.load(path=LECTURE_VIDEO_DIR)
...@@ -75,6 +75,7 @@ def mffc_highshelf(a, sr): ...@@ -75,6 +75,7 @@ def mffc_highshelf(a, sr):
# return a_enhanced # return a_enhanced
def output_file(destination ,filename, a, sr, ext=""): def output_file(destination ,filename, a, sr, ext=""):
destination = destination + filename[:-4] + ext + '.wav' destination = destination + "\\" + filename[:-4] + ext + '.wav'
print('output destination: ', destination)
librosa.output.write_wav(destination, a, sr) librosa.output.write_wav(destination, a, sr)
...@@ -86,8 +86,8 @@ ...@@ -86,8 +86,8 @@
$('.to_summary').click(function(e) { $('.to_summary').click(function(e) {
alert('Processing'); alert('Processing');
let id = e.target.parentNode.parentNode.getAttribute('id'); let id = e.target.parentNode.parentNode.getAttribute('id');
<!-- let lecture_summary_name = e.target.parentNode.parentNode.getAttribute('data-summary-name');--> let lecture_summary_name = e.target.parentNode.parentNode.getAttribute('data-summary-name');
let lecture_summary_name = e.target.parentNode.parentNode.getAttribute('data-notice-name'); <!-- let lecture_summary_name = e.target.parentNode.parentNode.getAttribute('data-notice-name');-->
<!-- lecture_summary_name = lecture_summary_name + ".txt";--> <!-- lecture_summary_name = lecture_summary_name + ".txt";-->
lecture_summary_name = lecture_summary_name + ".wav.txt"; lecture_summary_name = lecture_summary_name + ".wav.txt";
alert('id: ' + id); alert('id: ' + id);
...@@ -112,7 +112,7 @@ ...@@ -112,7 +112,7 @@
$('.get_notices').click(function(e) { $('.get_notices').click(function(e) {
alert('Processing'); alert('Processing');
let id = e.target.parentNode.parentNode.getAttribute('id'); let id = e.target.parentNode.parentNode.getAttribute('id');
let lecture_notice_name = e.target.parentNode.parentNode.getAttribute('data-summary-name'); let lecture_notice_name = e.target.parentNode.parentNode.getAttribute('data-notice-name');
lecture_notice_name = lecture_notice_name + ".wav.txt"; lecture_notice_name = lecture_notice_name + ".wav.txt";
alert('id: ' + id); alert('id: ' + id);
alert('lecture_notice_name: ' + lecture_notice_name); alert('lecture_notice_name: ' + lecture_notice_name);
...@@ -311,7 +311,7 @@ ...@@ -311,7 +311,7 @@
<tbody> <tbody>
{% for lec_text in lecture_text_data %} {% for lec_text in lecture_text_data %}
<tr class="recordings not_clicked" id="{{ lec_text.lecture_audio_id.id }}" data-summary-name="{{lec_text.lecture_audio_id.lecture_audio_name}}" data-notice-name="{{lec_text.lecture_audio_id}}" > <tr class="recordings not_clicked" id="{{ lec_text.lecture_audio_id.id }}" data-summary-name="{{lec_text.lecture_audio_id.lecture_audio_name}}" data-notice-name="{{lec_text.lecture_audio_id.lecture_audio_name}}" >
<!-- <td>--> <!-- <td>-->
<!-- <div class="radio">--> <!-- <div class="radio">-->
<!-- <label><input type="radio"--> <!-- <label><input type="radio"-->
......
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