Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
2
2022-066
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
2022-066
2022-066
Commits
b6f14a4a
Commit
b6f14a4a
authored
Oct 09, 2022
by
chaveenagit
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
api
parent
3ee5a299
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
95 additions
and
0 deletions
+95
-0
TopicIndexing/api.py
TopicIndexing/api.py
+95
-0
No files found.
TopicIndexing/api.py
0 → 100644
View file @
b6f14a4a
from
flask
import
Flask
,
request
,
render_template
,
send_file
from
flask_cors
import
CORS
import
werkzeug
import
cv2
import
note_generator.note
as
note_gen
import
topics_find.audio_gen
as
topic_gen
import
note_generator.write_word
as
writer
import
topics_find.bert
as
bert
import
os
os
.
environ
[
'KMP_DUPLICATE_LIB_OK'
]
=
'True'
app
=
Flask
(
__name__
)
CORS
(
app
)
video_file_name
=
''
pptx_file_name
=
''
@
app
.
route
(
'/'
)
def
index
():
return
render_template
(
'index.html'
)
@
app
.
route
(
'/upload_action'
,
methods
=
[
'GET'
,
'POST'
])
def
upload_action
():
lecture_video
=
request
.
files
[
'lecture_video'
]
filename_v
=
werkzeug
.
utils
.
secure_filename
(
lecture_video
.
filename
)
print
(
"
\n
Received image File name : "
+
lecture_video
.
filename
)
lecture_video
.
save
(
'upload/'
+
filename_v
)
lecture_ppt
=
request
.
files
[
'lecture_ppt'
]
filename
=
werkzeug
.
utils
.
secure_filename
(
lecture_ppt
.
filename
)
print
(
"
\n
Received image File name : "
+
lecture_ppt
.
filename
)
lecture_ppt
.
save
(
'upload/'
+
filename
)
global
video_file_name
global
pptx_file_name
video_file_name
=
filename_v
pptx_file_name
=
filename
return
render_template
(
'upload.html'
,
video_file_name
=
video_file_name
,
pptx_file_name
=
pptx_file_name
)
@
app
.
route
(
'/generate_topics'
,
methods
=
[
'GET'
,
'POST'
])
def
generate_topics
():
global
video_file_name
global
pptx_file_name
text_list_from_video
,
all_text
=
topic_gen
.
split_video_file
(
'upload/'
+
video_file_name
)
topic_list
=
[]
for
index
in
text_list_from_video
:
topic_list
.
append
([
index
[
0
],
index
[
1
],
bert
.
get_topics_new
(
index
[
1
])])
return
render_template
(
'topics.html'
,
topic_list
=
topic_list
)
@
app
.
route
(
'/generate_short_note'
,
methods
=
[
'GET'
,
'POST'
])
def
generate_short_note
():
global
video_file_name
global
pptx_file_name
text_from_pptx
=
note_gen
.
generate_note
(
'upload/'
+
pptx_file_name
)
text_list_from_video
,
all_text
=
topic_gen
.
split_video_file
(
'upload/'
+
video_file_name
)
writer
.
create_doc
()
writer
.
write_note
(
'short note from lecture video :- '
)
for
i
in
text_list_from_video
:
writer
.
write_note
(
i
[
1
])
writer
.
write_note
(
'short note from lecture slide (pptx) :- '
)
writer
.
write_note
(
text_from_pptx
)
writer
.
save_note
(
'upload/'
+
pptx_file_name
.
split
(
'.'
)[
0
]
+
'.docx'
)
doc_filename
=
pptx_file_name
.
split
(
'.'
)[
0
]
+
'.docx'
print
(
doc_filename
)
return
render_template
(
'short_notes.html'
,
filename
=
doc_filename
)
@
app
.
route
(
'/short_note/<name>'
)
def
short_note
(
name
):
doc
=
'upload/'
+
name
print
(
'request'
,
doc
)
return
send_file
(
doc
,
as_attachment
=
True
)
if
__name__
==
'__main__'
:
app
.
run
(
host
=
"0.0.0.0"
,
port
=
5200
,
debug
=
True
)
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