-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
47 lines (41 loc) · 1.48 KB
/
app.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
from flask import Flask
app = Flask(__name__)
import os
import openai
from dotenv import load_dotenv
basedir = os.path.abspath(os.path.dirname(__file__))
load_dotenv(os.path.join(basedir, ".envrc"))
openai.api_key = os.environ.get("OPEN_API_KEY")
@app.route("/")
def home():
f = open('recording.txt','r')
prompt = f'Suggest multiple things to talk about next based on this conversation: {f}'
response = openai.Completion.create(model="text-davinci-003", prompt=prompt, temperature=0, max_tokens=7)
response = openai.Completion.create(
model="text-davinci-003",
prompt=prompt,
temperature=0,
max_tokens=60,
top_p=1,
frequency_penalty=0,
presence_penalty=0
)
text = response["text"]
file = open('recording_response.txt', 'w')
file.write(transcript["text"])
file.close()
return response
@app.route("/record")
def record():
audio_file= open("recording.wav", "rb")
transcript = openai.Audio.transcribe("whisper-1", audio_file)
file = open('recording.txt', 'w')
file.write(transcript["text"])
file.close()
return transcript
@app.route("/format")
def format():
# TODO: read from open API response
# TODO: do this realtime
response = "\n\n1. What other hobbies do you have?\n2. What do you like to do in your free time?\n3. What do you think about the current state of the world?\n4. What do you think are the biggest challenges facing society today?\n5. What do"
return response