app file
Browse files- app.py +4 -2
- summarizer.py +4 -4
- transcript.py +9 -2
app.py
CHANGED
@@ -34,7 +34,8 @@ def image_mod(link):
|
|
34 |
lexrank_switch = True
|
35 |
html = ''
|
36 |
images = []
|
37 |
-
|
|
|
38 |
#images = su.getSummaryImage(link, lexrank_switch, rpunkt_switch)
|
39 |
print(html)
|
40 |
|
@@ -52,8 +53,9 @@ def image_mod(link):
|
|
52 |
|
53 |
print('images',images)
|
54 |
|
55 |
-
return {"html": html, "images":images}
|
56 |
#return HTMLResponse(content=html)
|
|
|
57 |
|
58 |
|
59 |
@app.get("/html")
|
|
|
34 |
lexrank_switch = True
|
35 |
html = ''
|
36 |
images = []
|
37 |
+
json_file = su.getSummary(link, lexrank_switch, rpunkt_switch)
|
38 |
+
#html, images = su.getSummary(link, lexrank_switch, rpunkt_switch)
|
39 |
#images = su.getSummaryImage(link, lexrank_switch, rpunkt_switch)
|
40 |
print(html)
|
41 |
|
|
|
53 |
|
54 |
print('images',images)
|
55 |
|
56 |
+
#return {"html": html, "images":images}
|
57 |
#return HTMLResponse(content=html)
|
58 |
+
return json_file
|
59 |
|
60 |
|
61 |
@app.get("/html")
|
summarizer.py
CHANGED
@@ -128,11 +128,11 @@ def getSummary(link, lexrank_switch, rpunkt_switch):
|
|
128 |
proc_list = fr.extractImagesFromVideo(dict_timestamp_summary.keys())
|
129 |
print('frames: '+str(proc_list))
|
130 |
|
131 |
-
|
132 |
-
images = ts.getImages(dict_timestamp_summary)
|
133 |
-
|
134 |
-
return html_file, images
|
135 |
|
|
|
|
|
136 |
|
137 |
#filename='/Users/hujo/Downloads/Channel_Summaries/wholesaleted.srt.pnct.txt'
|
138 |
#with open(filename, 'w') as the_file:
|
|
|
128 |
proc_list = fr.extractImagesFromVideo(dict_timestamp_summary.keys())
|
129 |
print('frames: '+str(proc_list))
|
130 |
|
131 |
+
json_file = ts.convertToJSON(dict_timestamp_summary)
|
132 |
+
#images = ts.getImages(dict_timestamp_summary)
|
|
|
|
|
133 |
|
134 |
+
#return json_file, images
|
135 |
+
return json_file
|
136 |
|
137 |
#filename='/Users/hujo/Downloads/Channel_Summaries/wholesaleted.srt.pnct.txt'
|
138 |
#with open(filename, 'w') as the_file:
|
transcript.py
CHANGED
@@ -100,15 +100,22 @@ def getSentences(raw_transcript):
|
|
100 |
#return dsl
|
101 |
|
102 |
def convertToJSON(dsl):
|
103 |
-
workdir = '
|
104 |
cnt=1
|
105 |
json_rows = '['
|
106 |
for (key,val) in dsl.items():
|
107 |
image='frame_'+f"{int(cnt):04d}"+'.jpg'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
108 |
sentence = val
|
109 |
row = '{"image_id": "'+str(cnt)+'",'
|
110 |
row = row + '"timestamp": "'+key+'",'
|
111 |
-
row = row + '"image": "'+
|
112 |
row = row + '"caption": "'+sentence+'"},'
|
113 |
json_rows = json_rows + row
|
114 |
cnt = cnt+1
|
|
|
100 |
#return dsl
|
101 |
|
102 |
def convertToJSON(dsl):
|
103 |
+
workdir = './workdir/'
|
104 |
cnt=1
|
105 |
json_rows = '['
|
106 |
for (key,val) in dsl.items():
|
107 |
image='frame_'+f"{int(cnt):04d}"+'.jpg'
|
108 |
+
|
109 |
+
# open image and convert it to base64 image
|
110 |
+
with open(workdir+image, 'rb') as open_file:
|
111 |
+
byte_content = open_file.read()
|
112 |
+
base64_bytes = base64.b64encode(byte_content)
|
113 |
+
base64_string = base64_bytes.decode('utf-8')
|
114 |
+
|
115 |
sentence = val
|
116 |
row = '{"image_id": "'+str(cnt)+'",'
|
117 |
row = row + '"timestamp": "'+key+'",'
|
118 |
+
row = row + '"image": "'+base64_string+'",'
|
119 |
row = row + '"caption": "'+sentence+'"},'
|
120 |
json_rows = json_rows + row
|
121 |
cnt = cnt+1
|