Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
2
2020-101
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Sachith Fernando
2020-101
Commits
2e86bf20
Commit
2e86bf20
authored
Jan 08, 2021
by
I.K Seneviratne
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'IT17100908' into 'QA_RELEASE'
Integrate See merge request
!47
parents
e2c05f52
010d9235
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
61 additions
and
32 deletions
+61
-32
LectureSummarizingApp/ExtractKeySentences.py
LectureSummarizingApp/ExtractKeySentences.py
+3
-0
LectureSummarizingApp/Summary.py
LectureSummarizingApp/Summary.py
+26
-9
LectureSummarizingApp/api.py
LectureSummarizingApp/api.py
+13
-10
LectureSummarizingApp/speech_to_text.py
LectureSummarizingApp/speech_to_text.py
+6
-2
LectureSummarizingApp/templates/LectureSummarizingApp/summarization.html
...ingApp/templates/LectureSummarizingApp/summarization.html
+12
-10
LectureSummarizingApp/urls.py
LectureSummarizingApp/urls.py
+1
-1
No files found.
LectureSummarizingApp/ExtractKeySentences.py
View file @
2e86bf20
...
...
@@ -28,6 +28,9 @@ def LectureNotice(notice_name):
sentences_with_word
.
append
(
sentence
)
word_sentence_dictionary
[
word
]
=
sentences_with_word
file
=
open
(
'Notices01.txt'
,
'w'
)
file
.
close
()
def
SaveNotices
():
pdf
=
FPDF
()
...
...
LectureSummarizingApp/Summary.py
View file @
2e86bf20
...
...
@@ -6,14 +6,16 @@ from fpdf import FPDF
def
LectureSummary
(
summary_name
):
#
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
#
FILE_PATH = os.path.join(BASE_DIR, "speechToText\\{}".format(summary_name))
# DESTINATION_DIR = os.path.dirname(os.path.join(BASE_DIR, "LectureSummarizingApp\\summary\\sample.txt"
))
#
print('destination directory: ', DESTINATION_DIR)
BASE_DIR
=
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
))
FILE_PATH
=
os
.
path
.
join
(
BASE_DIR
,
"speechToText
\\
{}"
.
format
(
summary_name
))
DESTINATION_DIR
=
os
.
path
.
join
(
BASE_DIR
,
"summary
\\
Summary_{}"
.
format
(
summary_name
))
print
(
'destination directory: '
,
DESTINATION_DIR
)
# Reading the file
nlp
=
pt_core_news_sm
.
load
()
with
open
(
"audioToText.txt"
,
"r"
,
encoding
=
"utf-8"
)
as
f
:
# file = open(DESTINATION_DIR, 'w')
text
=
''
with
open
(
FILE_PATH
,
"r"
,
encoding
=
"utf-8"
)
as
f
:
text
=
" "
.
join
(
f
.
readlines
())
doc
=
nlp
(
text
)
...
...
@@ -53,13 +55,23 @@ def LectureSummary(summary_name):
summary
.
append
(
sent
)
else
:
continue
file
=
None
for
i
in
summary
:
file
=
open
(
'Summary01.txt'
,
'w'
)
file
=
open
(
DESTINATION_DIR
,
'w'
)
# file = open('Summary01.txt', 'w')
file
.
write
(
str
(
i
))
file
.
close
()
def
SaveSummary
():
# def SaveSummary():
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
,
"summaryPDF
\\
Summary_PDF_{}.pdf"
.
format
(
summary_name
))
pdf
=
FPDF
()
# Add a page
pdf
.
add_page
()
...
...
@@ -68,11 +80,16 @@ def SaveSummary():
pdf
.
set_font
(
"Arial"
,
size
=
15
)
# open the text file in read mode
f
=
open
(
"Summary01.txt"
,
"r"
)
f
=
open
(
DESTINATION_DIR
,
"r"
)
# insert the texts in pdf
for
x
in
f
:
pdf
.
cell
(
200
,
10
,
txt
=
x
,
ln
=
1
,
align
=
'C'
)
# save the pdf with name .pdf
pdf
.
output
(
"summary01.pdf"
)
\ No newline at end of file
pdf
.
output
(
PDF_DESTINATION_DIR
)
# convert the summary list to a text
listToStr
=
' '
.
join
([
str
(
elem
)
for
elem
in
summary
])
return
text
,
listToStr
\ No newline at end of file
LectureSummarizingApp/api.py
View file @
2e86bf20
...
...
@@ -14,6 +14,7 @@ import datetime
# APIs used in Lecture Summarizing Component
from
.Summary
import
LectureSummary
from
.noise
import
noise_removal
from
.speech_to_text
import
speech_to_text
...
...
@@ -83,15 +84,17 @@ class audioToTextList(APIView):
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
=
generate_new_id
(
audio_to_text_list
.
new
_speech_to_text_id
)
new_speech_to_text_id
=
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
,
lecture_audio_id
_id
=
id
,
audio_original_text
=
speech_to_text_name
)
.
save
()
...
...
@@ -108,29 +111,29 @@ class audioToTextList(APIView):
return
Response
({
"response"
:
request
.
data
})
class
l
ectureSummaryList
(
APIView
):
class
L
ectureSummaryList
(
APIView
):
def
get
(
self
,
request
):
lecture_audio_summary_id
=
LectureAudioSummary
.
objects
.
all
()
# serializer = LectureAudioSummarySerializer(lecture_audio_summary_id, many=True)
# return Response(serializer.data)
lecture_summary_list
=
LectureAudioSummary
.
objects
.
order_by
(
'lecture_
summary_list
'
)
.
last
()
lecture_summary_list
=
LectureAudioSummary
.
objects
.
order_by
(
'lecture_
audio_summary_id
'
)
.
last
()
lecture_summary_name
=
request
.
query_params
.
get
(
"lecture_summary_name"
)
id
=
int
(
request
.
query_params
.
get
(
"id"
))
current_date
=
datetime
.
datetime
.
now
()
.
date
()
# generate new id for summary
lecture_summary_id
=
generate_new_id
(
lecture_summary_list
.
lecture
_summary_id
)
lecture_summary_id
=
"LSUM0001"
if
lecture_summary_list
is
None
else
generate_new_id
(
lecture_summary_list
.
lecture_audio
_summary_id
)
LectureAudio
Summary
(
lecture_summary_name
)
text
,
summary
=
Lecture
Summary
(
lecture_summary_name
)
LectureAudioSummary
(
lecture_
speech_to_text_id
=
id
,
lecture_audio_id
=
lecture_summary_
id
,
audio_original_text
=
current_date
,
audio_summary
=
lecture_summary_name
lecture_
audio_summary_id
=
lecture_summary_
id
,
lecture_audio_id
_id
=
id
,
audio_original_text
=
text
,
audio_summary
=
summary
)
.
save
()
return
Response
({
"response"
:
request
.
data
})
...
...
LectureSummarizingApp/speech_to_text.py
View file @
2e86bf20
...
...
@@ -8,13 +8,17 @@ def speech_to_text(speech_to_text_name):
r
=
sr
.
Recognizer
()
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
\\
{}"
.
format
(
speech_to_text_name
))
DESTINATION_DIR
=
os
.
path
.
dirname
(
os
.
path
.
join
(
BASE_DIR
,
"LectureSummarizingApp
\\
speechToText
\\
sample.txt"
))
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
.
join
(
BASE_DIR
,
"speechToText
\\
{}.txt"
.
format
(
speech_to_text_name
))
print
(
'destination directory: '
,
DESTINATION_DIR
)
with
sr
.
AudioFile
(
FILE_PATH
)
as
source
:
audio
=
r
.
listen
(
source
)
file
=
open
(
'audioToText01.txt'
,
'w'
)
#open file
# file = open('audioToText01.txt', 'w') #open file
file
=
open
(
DESTINATION_DIR
,
'w'
)
#open file
try
:
text
=
r
.
recognize_google
(
audio
)
#Convert using google recognizer
file
.
write
(
text
)
...
...
LectureSummarizingApp/templates/LectureSummarizingApp/summarization.html
View file @
2e86bf20
...
...
@@ -35,11 +35,12 @@
$
(
document
).
ready
(
function
()
{
<!--
speech
to
text
-->
$
(
'
.audio_to_text_process
'
).
click
(
function
()
{
alert
(
'
Process
ing
'
);
$
(
'
.audio_to_text_process
'
).
click
(
function
(
e
)
{
alert
(
'
Convert
ing
'
);
let
id
=
e
.
target
.
parentNode
.
parentNode
.
getAttribute
(
'
id
'
);
let
speech_to_text_name
=
e
.
target
.
parentNode
.
parentNode
.
getAttribute
(
'
data-noiseless-audio-name
'
);
speech_to_text_name
=
speech_to_text_name
+
"
.txt
"
;
<!--
speech_to_text_name
=
speech_to_text_name
+
"
.txt
"
;
-->
alert
(
'
id:
'
+
id
);
alert
(
'
speech to text file name:
'
+
speech_to_text_name
);
...
...
@@ -82,17 +83,18 @@
}
<!--
To
summary
-->
$
(
'
.to_summary
'
).
click
(
function
()
{
$
(
'
.to_summary
'
).
click
(
function
(
e
)
{
alert
(
'
Processing
'
);
let
id
=
e
.
target
.
parentNode
.
parentNode
.
getAttribute
(
'
id
'
);
let
lecture_summary_name
=
e
.
target
.
parentNode
.
parentNode
.
getAttribute
(
'
data-summary-name
'
);
lecture_summary_name
=
lecture_summary_name
+
"
.wav
"
;
<!--
lecture_summary_name
=
lecture_summary_name
+
"
.txt
"
;
-->
lecture_summary_name
=
lecture_summary_name
+
"
.wav.txt
"
;
alert
(
'
id:
'
+
id
);
alert
(
'
lecture_summary_name:
'
+
lecture_summary_name
);
//call the fetch API
etch
(
'
http://127.0.0.1:8000/summary/lecture-summary/?lecture_summary_name=
'
+
lecture_summary_name
+
'
&id=
'
+
id
)
f
etch
(
'
http://127.0.0.1:8000/summary/lecture-summary/?lecture_summary_name=
'
+
lecture_summary_name
+
'
&id=
'
+
id
)
.
then
((
res
)
=>
res
.
json
())
.
then
((
out
)
=>
handleLectureRemoved
(
out
.
response
))
.
catch
((
err
)
=>
alert
(
'
error:
'
+
err
))
...
...
@@ -106,7 +108,7 @@
}
<!--
To
Notice
-->
$
(
'
.get_notices
'
).
click
(
function
()
{
$
(
'
.get_notices
'
).
click
(
function
(
e
)
{
alert
(
'
Processing
'
);
let
id
=
e
.
target
.
parentNode
.
parentNode
.
getAttribute
(
'
id
'
);
let
lecture_notice_name
=
e
.
target
.
parentNode
.
parentNode
.
getAttribute
(
'
data-summary-name
'
);
...
...
@@ -116,7 +118,7 @@
//call the fetch API
etch
(
'
http://127.0.0.1:8000/summary/lecture-notices/?lecture_notice_name=
'
+
lecture_notice_name
+
'
&id=
'
+
id
)
f
etch
(
'
http://127.0.0.1:8000/summary/lecture-notices/?lecture_notice_name=
'
+
lecture_notice_name
+
'
&id=
'
+
id
)
.
then
((
res
)
=>
res
.
json
())
.
then
((
out
)
=>
handleNoticeRemoved
(
out
.
response
))
.
catch
((
err
)
=>
alert
(
'
error:
'
+
err
))
...
...
@@ -240,7 +242,7 @@
<tbody>
{% for noiseless_audio in noiseless_data %}
<tr
class=
"recordings not_clicked"
id=
"{{ noiseless_audio.lecture_audio_id }}"
data-noiseless-audio-name=
"{{ noiseless_audio.lecture_audio_name }}"
>
<tr
class=
"recordings not_clicked"
id=
"{{ noiseless_audio.lecture_audio_id
.id
}}"
data-noiseless-audio-name=
"{{ noiseless_audio.lecture_audio_name }}"
>
<!-- <td>-->
<!-- <div class="radio">-->
<!-- <label><input type="radio"-->
...
...
@@ -308,7 +310,7 @@
<tbody>
{% for lec_text in lecture_text_data %}
<tr
class=
"recordings not_clicked"
id=
"{{ lec_text.lecture_audio_id
}}"
data-summary-name=
"{{lec_text.lecture_audio_id.subject.
name}}"
>
<tr
class=
"recordings not_clicked"
id=
"{{ lec_text.lecture_audio_id
.id }}"
data-summary-name=
"{{lec_text.lecture_audio_id.lecture_audio_
name}}"
>
<!-- <td>-->
<!-- <div class="radio">-->
<!-- <label><input type="radio"-->
...
...
LectureSummarizingApp/urls.py
View file @
2e86bf20
...
...
@@ -18,7 +18,7 @@ urlpatterns = [
url
(
r'^lecture-audio-to-text/'
,
api
.
audioToTextList
.
as_view
()),
url
(
r'^lecture-summary/$'
,
api
.
l
ectureSummaryList
.
as_view
()),
url
(
r'^lecture-summary/$'
,
api
.
L
ectureSummaryList
.
as_view
()),
url
(
r'^lecture-notices/$'
,
api
.
lectureNoticeList
.
as_view
()),
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment