Update app.py
Browse files
app.py
CHANGED
@@ -45,6 +45,29 @@ def transcribe(audio, text):
|
|
45 |
audio_file = open(audio, "rb")
|
46 |
transcript = openai.Audio.transcribe("whisper-1", audio_file, language="en")
|
47 |
messages.append({"role": "user", "content": transcript["text"]})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
48 |
|
49 |
# Split the input text into sentences
|
50 |
sentences = sent_tokenize(text)
|
|
|
45 |
audio_file = open(audio, "rb")
|
46 |
transcript = openai.Audio.transcribe("whisper-1", audio_file, language="en")
|
47 |
messages.append({"role": "user", "content": transcript["text"]})
|
48 |
+
system_message = openai.ChatCompletion.create(
|
49 |
+
model="gpt-3.5-turbo",
|
50 |
+
messages=messages,
|
51 |
+
max_tokens=2000
|
52 |
+
)["choices"][0]["message"]
|
53 |
+
|
54 |
+
messages.append({"role": "system", "content": str(system_message['content'])})
|
55 |
+
messages_rev.append({"role": "system", "content": str(system_message['content'])})
|
56 |
+
|
57 |
+
# Concatenate the chat history
|
58 |
+
chat_transcript = "\n\n".join([f"[ANSWER {answer_count}]{message['role']}: {message['content']}" for message in messages_rev if message['role'] != 'user'])
|
59 |
+
# if not isinstance(messages[-1]['content'], str):
|
60 |
+
# continue
|
61 |
+
|
62 |
+
# Append the number of tokens used to the end of the chat transcript
|
63 |
+
chat_transcript += f"\n\nNumber of tokens used: {num_tokens}\n\n"
|
64 |
+
df = pd.DataFrame([chat_transcript])
|
65 |
+
# Get the current time in Eastern Time (ET)
|
66 |
+
now_et = datetime.now(timezone(timedelta(hours=-4)))
|
67 |
+
# Format the time as string (YY-MM-DD HH:MM)
|
68 |
+
published_date = now_et.strftime('%m-%d-%y %H:%M')
|
69 |
+
notion_df.upload(df, 'https://www.notion.so/US-62e861a0b35f43da8ef9a7789512b8c2?pvs=4', title=str(published_date), api_key=API_KEY)
|
70 |
+
|
71 |
|
72 |
# Split the input text into sentences
|
73 |
sentences = sent_tokenize(text)
|