Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,22 +1,33 @@
|
|
1 |
-
|
2 |
-
|
|
|
|
|
|
|
|
|
3 |
|
4 |
-
|
|
|
5 |
|
6 |
-
# Load model (download on first run and reference local installation for consequent runs)
|
7 |
-
model = AutoModelForSeq2SeqLM.from_pretrained(model_name)
|
8 |
-
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
9 |
|
10 |
-
|
|
|
|
|
11 |
|
12 |
-
app = Flask(__name__)
|
13 |
|
14 |
-
@app.route('/')
|
15 |
-
def
|
16 |
-
return
|
17 |
-
|
18 |
-
|
19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
|
21 |
-
if __name__ ==
|
22 |
-
app.run(host='0.0.0.0'
|
|
|
1 |
+
import base64
|
2 |
+
import json
|
3 |
+
from flask import Flask, render_template, request
|
4 |
+
from worker import speech_to_text, text_to_speech, openai_process_message
|
5 |
+
from flask_cors import CORS
|
6 |
+
import os
|
7 |
|
8 |
+
app = Flask(__name__)
|
9 |
+
cors = CORS(app, resources={r"/*": {"origins": "*"}})
|
10 |
|
|
|
|
|
|
|
11 |
|
12 |
+
@app.route('/', methods=['GET'])
|
13 |
+
def index():
|
14 |
+
return render_template('index.html')
|
15 |
|
|
|
16 |
|
17 |
+
@app.route('/speech-to-text', methods=['POST'])
|
18 |
+
def speech_to_text_route():
|
19 |
+
return None
|
20 |
+
|
21 |
+
|
22 |
+
@app.route('/process-message', methods=['POST'])
|
23 |
+
def process_prompt_route():
|
24 |
+
response = app.response_class(
|
25 |
+
response=json.dumps({"openaiResponseText": None, "openaiResponseSpeech": None}),
|
26 |
+
status=200,
|
27 |
+
mimetype='application/json'
|
28 |
+
)
|
29 |
+
return response
|
30 |
+
|
31 |
|
32 |
+
if __name__ == "__main__":
|
33 |
+
app.run(port=8000, host='0.0.0.0')
|