-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.py
30 lines (26 loc) · 831 Bytes
/
main.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
from flask import Flask, request, render_template, send_file, jsonify
from gemini import get_gemini_response
from speechToText import conver_to_audio
import json
# from app import AIGirlfriend
app = Flask(__name__)
@app.route("/")
def index():
return render_template('index.html')
@app.route("/tts", methods=["POST"])
def tts():
messages = request.form.get("messages")
messages = json.loads(messages)
messages = get_gemini_response(messages)
return jsonify({"message": messages})
@app.route("/getAudio", methods=["POST"])
def getAudio():
text = request.form.get("message")
text = text.replace('*', '')
id = conver_to_audio(text)
return send_file(id, as_attachment=True)
# return text
if __name__ == "__main__":
from dotenv import load_dotenv
load_dotenv()
app.run(debug=True)