-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.py
More file actions
34 lines (30 loc) · 938 Bytes
/
Copy pathmain.py
File metadata and controls
34 lines (30 loc) · 938 Bytes
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
from flask import Flask, request, render_template, send_file, jsonify
import requests
import uuid
from speechToText import convert_to_audio
import json
from app import AIGirlfriend
app = Flask(__name__)
@app.route("/")
@app.route("/home")
def index():
return render_template('index.html')
@app.route("/voice_page")
def voice_page():
return render_template('voice_page.html')
@app.route("/tts", methods=["POST"])
def tts():
messages = request.form.get("messages")
messages = json.loads(messages)
gf = AIGirlfriend()
messages = gf.get_response_from_all_messages(messages)
return jsonify({"messages": messages})
@app.route("/getAudio", methods=["POST"])
def getAudio():
text = request.form.get("message")
id = convert_to_audio(text)
# id = "1e17748c-bee1-4db2-822c-15a37b199f0f.mp3";
return send_file(id, as_attachment=True)
# return text
if __name__ == "__main__":
app.run(debug=True)