Commit dd665bb8 authored by LiniEisha's avatar LiniEisha

Integrate

parent 2e86bf20
...@@ -6,10 +6,11 @@ def LectureNotice(notice_name): ...@@ -6,10 +6,11 @@ def LectureNotice(notice_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, "speechToText\\{}".format(notice_name)) FILE_PATH = os.path.join(BASE_DIR, "speechToText\\{}".format(notice_name))
DESTINATION_DIR = os.path.dirname(os.path.join(BASE_DIR, "LectureSummarizingApp\\Notices\\sample.txt")) DESTINATION_DIR = os.path.join(BASE_DIR, "notices\\Notice_{}".format(notice_name))
print('destination directory: ', DESTINATION_DIR) print('destination directory: ', DESTINATION_DIR)
read_lines = [line.rstrip('\n') for line in open("audioToText01.txt", "r")] text = ''
read_lines = [line.rstrip('\n') for line in open(FILE_PATH, "r")]
sentences_list = [] sentences_list = []
sentence_list = nltk.sent_tokenize(read_lines) sentence_list = nltk.sent_tokenize(read_lines)
word_search = "important" word_search = "important"
...@@ -28,11 +29,17 @@ def LectureNotice(notice_name): ...@@ -28,11 +29,17 @@ def LectureNotice(notice_name):
sentences_with_word.append(sentence) sentences_with_word.append(sentence)
word_sentence_dictionary[word] = sentences_with_word word_sentence_dictionary[word] = sentences_with_word
file = open('Notices01.txt', 'w') file = open('DESTINATION_DIR', 'w')
file.close() file.close()
def SaveNotices(): # def SaveNotices():
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
# PDF_DESTINATION_DIR = os.path.dirname(os.path.join(BASE_DIR, "summaryPDF\\sample.txt"))
PDF_DESTINATION_DIR = os.path.join(BASE_DIR, "noticePDF\\Notice{}.pdf".format(notice_name))
pdf = FPDF() pdf = FPDF()
# Add a page # Add a page
pdf.add_page() pdf.add_page()
...@@ -41,11 +48,13 @@ def SaveNotices(): ...@@ -41,11 +48,13 @@ def SaveNotices():
pdf.set_font("Arial", size=15) pdf.set_font("Arial", size=15)
# open the text file in read mode # open the text file in read mode
f = open("Summary01.txt", "r") f = open("DESTINATION_DIR", "r")
# insert the texts in pdf # insert the texts in pdf
for x in f: for x in f:
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("summary01.pdf") pdf.output("PDF_DESTINATION_DIR")
\ No newline at end of file
return text
\ No newline at end of file
...@@ -148,27 +148,27 @@ class LectureSummaryList(APIView): ...@@ -148,27 +148,27 @@ class LectureSummaryList(APIView):
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 = LectureNoticesSerializer(lecture_notice_id, many=True) # serializer = LectureNoticesSerializer(lecture_notice_id, many=True)
# return Response(serializer.data) # return Response(serializer.data)
lecture_notice_list = LectureNotices.objects.order_by('lecture_notice_list').last() lecture_notice_list = LectureNotices.objects.order_by('lecture_notice_id').last()
lecture_notice_name = request.query_params.get("lecture_notice_name") lecture_notice_name = request.query_params.get("lecture_notice_name")
id = int(request.query_params.get("id")) id = int(request.query_params.get("id"))
# generate new id for notices # generate new id for notice
lecture_notice_id = generate_new_id(lecture_notice_list.lecture_notice_id) notice_id = "LN0001" if lecture_notice_list is None else generate_new_id(lecture_notice_list.lecture_notice_id)
LectureNotices(lecture_notice_name) text = LectureNotices(lecture_notice_name)
LectureNotices( LectureNotices(
lecture_notice_id=id, lecture_notice_id=notice_id,
lecture_audio_id=lecture_notice_id, lecture_audio_id=id,
notice_text=lecture_notice_name notice_text=text
).save() ).save()
return Response({"response": request.data}) return Response({"response": request.data})
......
...@@ -112,7 +112,7 @@ ...@@ -112,7 +112,7 @@
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-summary-name');
lecture_notice_name = lecture_notice_name + ".wav"; 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);
......
...@@ -20,7 +20,7 @@ urlpatterns = [ ...@@ -20,7 +20,7 @@ urlpatterns = [
url(r'^lecture-summary/$', api.LectureSummaryList.as_view()), url(r'^lecture-summary/$', api.LectureSummaryList.as_view()),
url(r'^lecture-notices/$', api.lectureNoticeList.as_view()), url(r'^lecture-notices/$', api.LectureNoticeList.as_view()),
path('api-auth/', include('rest_framework.urls', namespace='rest_framework')) path('api-auth/', include('rest_framework.urls', namespace='rest_framework'))
......
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