jibay commited on
Commit ·
d4083cd
1
Parent(s): 5940223
Modif
Browse filesFiles changed (2)
- Dockerfile+3-1
- app.py+18-1
33 unmodified lines3435363733 unmodified lines# Start the FastAPI app on port 7860, the default port expected by Spaces#CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]#CMD ["python", "app.py"]CMD ["python", "-m", "flask", "run", "--host", "0.0.0.0", "--port", "7860"]33 unmodified lines34353637383933 unmodified lines# Start the FastAPI app on port 7860, the default port expected by Spaces#CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]#CMD ["python", "app.py"]CMD ["python", "-m", "flask", "run", "--host", "0.0.0.0", "--port", "7860"]#CMD ["pyton3", ""]
6 unmodified lines7891011123 unmodified lines16171819202127 unmodified lines4950515253545556576 unmodified linesfrom twilio.twiml.voice_response import VoiceResponse, Start, Stopfrom twilio.rest import Clientimport voskapp = Flask(__name__)sock = Sock(app)3 unmodified linesCL = '\x1b[0K'BS = '\x08'@app.route('/call', methods=['POST'])def call():27 unmodified linesr = json.loads(rec.Result())#print(CL + r['text'] + ' ', end='', flush=True)print('FINAL:'+r['text'] + ' ', end='', flush=True)else:r = json.loads(rec.PartialResult())print('PARTIAL:' + r['partial']+'\n', end='', flush=True)#print(CL + r['partial'] + BS * len(r['partial']), end='', flush=True)#print(CL + r['partial'] + BS * len(r['partial']), end='', flush=True)6 unmodified lines789101112133 unmodified lines1718192021222324252627 unmodified lines5455565758596061626364656667686970717273746 unmodified linesfrom twilio.twiml.voice_response import VoiceResponse, Start, Stopfrom twilio.rest import Clientimport voskimport openaiapp = Flask(__name__)sock = Sock(app)3 unmodified linesCL = '\x1b[0K'BS = '\x08'openai.api_key = os.environ.get("OPEN_API_KEY")messages = [ {"role": "system", "content":"You are a intelligent assistant."} ]@app.route('/call', methods=['POST'])def call():27 unmodified linesr = json.loads(rec.Result())#print(CL + r['text'] + ' ', end='', flush=True)print('FINAL:'+r['text'] + ' ', end='', flush=True)messageChatGpt = "peux-tu me dire s'il faut appeler les secours, quelqu'un m'a ecrit ceci: \""+r['text']+"\ ?"messages.append({"role": "user", "content": messageChatGpt})chat = openai.ChatCompletion.create(model="gpt-3.5-turbo", messages=messages)reply = chat.choices[0].message.contentprint(reply)else:r = json.loads(rec.PartialResult())#print('PARTIAL:' + r['partial']+'\n', end='', flush=True)#print(CL + r['partial'] + BS * len(r['partial']), end='', flush=True)#print(CL + r['partial'] + BS * len(r['partial']), end='', flush=True)
Dockerfile+3-1
app.py+18-1