Spaces:
son9john
/
Runtime error

son9john commited on
Commit
00212f4
1 Parent(s): ad390da

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -5
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
- messages.append({"role": "user", "content": transcript["text"]})
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
- # Add the input text to the messages list
63
- messages.append({"role": "user", "content": input_text})
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)