-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.py
40 lines (34 loc) · 1.25 KB
/
run.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
# Importing the necessary Libraries
from flask_cors import cross_origin
from flask import Flask, render_template, request
#from main import text_to_speech
#from inference import synthesize
from flask_ngrok import run_with_ngrok
#import IPython.display as ipd
#import soundfile as sf
from saveText import save_text
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
app = Flask(__name__,template_folder='') #html 폴더 경로 설정
app.config.from_pyfile('config.py')
database = create_engine(app.config['DB_URL'], encoding = 'utf-8', max_overflow = 0)
Session = sessionmaker(database)
session = Session()
#run_with_ngrok(app)
@app.route('/', methods=['POST', 'GET'])
@cross_origin()
def homepage():
if request.method == 'POST':
text = request.form['speech']
voice = request.form['voices']
#text_to_speech(text,voice)
#wavs=synthesize(text)
#ipd.display(ipd.Audio(wavs,rate=22050,autoplay=True))
save_text(text,database,session)
#sf.write('/content/audio.wav',wavs, 22050, 'PCM_24')
return render_template('frontend.html')
else:
return render_template('frontend.html')
if __name__ == "__main__":
#app.run('0.0.0.0',port = 8000)
app.run(port=8000, debug=True)