-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
executable file
·44 lines (27 loc) · 932 Bytes
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
from flask import Flask, render_template, url_for, request, redirect
from gtts import gTTS
from caption import *
import warnings
warnings.filterwarnings("ignore")
app = Flask(__name__)
@app.route('/')
def hello():
return render_template('index.html')
@app.route('/', methods = ['POST'])
def upload_file():
if request.method == 'POST':
img = request.files['image']
# print(img)
# print(img.filename)
img.save("static/"+img.filename)
caption = caption_this_image("static/"+img.filename)
result_dic = {
'image' : "static/" + img.filename,
'description' : caption
}
song=gTTS(caption)
song.save("static/"+img.filename+".mp3")
return render_template('index.html', results = result_dic,songs=img.filename+".mp3")
if __name__ == '__main__':
app.config['TEMPLATES_AUTO_RELOAD']=True
app.run(debug = False)