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
49dc3c62
Commit
49dc3c62
authored
Nov 14, 2022
by
De Silva K.C.C.C
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Topic API
parent
2ecf839d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
65 additions
and
0 deletions
+65
-0
Indexing/api.py
Indexing/api.py
+65
-0
No files found.
Indexing/api.py
0 → 100644
View file @
49dc3c62
# import libraries
from
flask
import
Flask
,
request
,
send_file
from
flask_cors
import
CORS
import
json
import
werkzeug
import
os
import
audio_gen
as
topic_gen
import
bert
as
bert
from
nltk.corpus
import
stopwords
s
=
set
(
stopwords
.
words
(
'english'
))
app
=
Flask
(
__name__
)
CORS
(
app
)
download_file
=
''
@
app
.
route
(
'/topic'
,
methods
=
[
'GET'
,
'POST'
])
def
topic
():
imagefile
=
request
.
files
[
'video'
]
filename
=
werkzeug
.
utils
.
secure_filename
(
imagefile
.
filename
)
print
(
"
\n
Received image File name : "
+
imagefile
.
filename
)
imagefile
.
save
(
'upload/'
+
filename
)
global
download_file
download_file
=
'upload/'
+
str
(
filename
)
.
replace
(
'.mp4'
,
'.txt'
)
text_list_from_video
,
all_text
=
topic_gen
.
split_video_file
(
'upload/'
+
filename
)
# Writing to a file
file1
=
open
(
download_file
,
'w'
)
file1
.
writelines
(
all_text
)
file1
.
close
()
topic_list
=
[]
for
index
in
text_list_from_video
:
temp_topic
=
bert
.
get_topics_new
(
index
[
1
])
filtered_topics
=
[
elem
for
elem
in
temp_topic
if
elem
not
in
s
]
topic_list
.
append
(
filtered_topics
[
0
])
return_json
=
'[ '
for
i
,
topic
in
enumerate
(
topic_list
):
if
i
==
len
(
topic_list
)
-
1
:
return_json
+=
'{ "index" : "'
+
str
(
i
)
+
'", "topic" : "'
+
str
(
topic
)
+
'", "time_frame" : "'
+
str
(
i
*
240
)
+
' to end" } ]'
else
:
return_json
+=
'{ "index" : "'
+
str
(
i
)
+
'", "topic" : "'
+
str
(
topic
)
+
'", "time_frame" : "'
+
str
(
i
*
240
)
+
' to '
+
str
((
i
+
1
)
*
240
)
+
' seconds"} ,'
print
(
return_json
)
return
json
.
loads
(
return_json
)
@
app
.
route
(
'/transcript'
,
methods
=
[
'GET'
,
'POST'
])
def
transcript
():
global
download_file
doc
=
download_file
return
send_file
(
doc
,
as_attachment
=
True
)
if
__name__
==
"__main__"
:
app
.
run
(
host
=
"0.0.0.0"
,
port
=
1100
,
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