son9john commited on
Commit
a490765
·
1 Parent(s): 528e1e5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -3
app.py CHANGED
@@ -43,7 +43,8 @@ See https://github.com/openai/openai-python/blob/main/chatml.md for information
43
  def transcribe(audio, text):
44
  global messages
45
  global answer_count
46
-
 
47
  if audio is not None:
48
  audio_file = open(audio, "rb")
49
  transcript = openai.Audio.transcribe("whisper-1", audio_file, language="en")
@@ -66,12 +67,13 @@ def transcribe(audio, text):
66
  messages = [initial_message]
67
  answer_count = 0
68
  input_text = 'Can you click the Submit button one more time? (say Yes)'
69
- messages.append({"role": "user", "content": input_text})
70
  else:
71
  # Add the input tokens to the messages list
72
  input_text = tokenizer.decode(input_tokens)
73
- messages.append({"role": "user", "content": input_text})
74
 
 
 
75
  # Check if the accumulated tokens have exceeded the limit
76
  num_tokens = num_tokens_from_messages(messages)
77
  if num_tokens > 2096:
 
43
  def transcribe(audio, text):
44
  global messages
45
  global answer_count
46
+ transcript = {'text': ''}
47
+ input_text = []
48
  if audio is not None:
49
  audio_file = open(audio, "rb")
50
  transcript = openai.Audio.transcribe("whisper-1", audio_file, language="en")
 
67
  messages = [initial_message]
68
  answer_count = 0
69
  input_text = 'Can you click the Submit button one more time? (say Yes)'
70
+
71
  else:
72
  # Add the input tokens to the messages list
73
  input_text = tokenizer.decode(input_tokens)
 
74
 
75
+ messages.append({"role": "user", "content": transcript["text"]+input_text})
76
+
77
  # Check if the accumulated tokens have exceeded the limit
78
  num_tokens = num_tokens_from_messages(messages)
79
  if num_tokens > 2096: