Update app.py
Browse files
app.py
CHANGED
@@ -33,8 +33,7 @@ def transcribe(audio, text):
|
|
33 |
if audio is not None:
|
34 |
audio_file = open(audio, "rb")
|
35 |
transcript = openai.Audio.transcribe("whisper-1", audio_file, language="en")
|
36 |
-
|
37 |
-
|
38 |
# Tokenize the text input
|
39 |
if text is not None:
|
40 |
# Split the input text into sentences
|
@@ -59,9 +58,8 @@ def transcribe(audio, text):
|
|
59 |
# Decode the input tokens into text
|
60 |
input_text = tokenizer.decode(input_tokens)
|
61 |
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
|
66 |
# Check if the accumulated tokens have exceeded 2096
|
67 |
num_tokens = sum(len(tokenizer.encode(message["content"])) for message in messages)
|
|
|
33 |
if audio is not None:
|
34 |
audio_file = open(audio, "rb")
|
35 |
transcript = openai.Audio.transcribe("whisper-1", audio_file, language="en")
|
36 |
+
|
|
|
37 |
# Tokenize the text input
|
38 |
if text is not None:
|
39 |
# Split the input text into sentences
|
|
|
58 |
# Decode the input tokens into text
|
59 |
input_text = tokenizer.decode(input_tokens)
|
60 |
|
61 |
+
# Add the input text to the messages list
|
62 |
+
messages.append({"role": "user", "content": transcript["text"]+input_text})
|
|
|
63 |
|
64 |
# Check if the accumulated tokens have exceeded 2096
|
65 |
num_tokens = sum(len(tokenizer.encode(message["content"])) for message in messages)
|