Alexander Nikolaev
Update webApp.py
7b1ddd7 unverified
raw
history blame
1.3 kB
from flask import Flask, render_template, request
import webbrowser
import os
from flask_cors import CORS
import json
import lambdaTTS
import lambdaSpeechToScore
import lambdaGetSample
app = Flask(__name__)
cors = CORS(app)
app.config['CORS_HEADERS'] = '*'
rootPath = ''
@app.route(rootPath+'/')
def main():
return render_template('main.html')
@app.route(rootPath+'/getAudioFromText', methods=['POST'])
def getAudioFromText():
event = {'body': json.dumps(request.get_json(force=True))}
return lambdaTTS.lambda_handler(event, [])
@app.route(rootPath+'/getSample', methods=['POST'])
def getNext():
event = {'body': json.dumps(request.get_json(force=True))}
return lambdaGetSample.lambda_handler(event, [])
@app.route(rootPath+'/GetAccuracyFromRecordedAudio', methods=['POST'])
def GetAccuracyFromRecordedAudio():
try:
event = {'body': json.dumps(request.get_json(force=True))}
lambda_correct_output = lambdaSpeechToScore.lambda_handler(event, [])
except Exception as e:
import traceback
print(e)
print(traceback.format_exc())
return lambda_correct_output
if __name__ == "__main__":
language = 'de'
print(os.system('pwd'))
webbrowser.open_new('http://127.0.0.1:3000/')
app.run(host="0.0.0.0", port=3000)