shaikrabbani-dev commited on
Commit
6c74211
·
verified ·
1 Parent(s): d4ede98

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -6
app.py CHANGED
@@ -68,7 +68,7 @@ def get_ai_answer(question):
68
  max_tokens=40,
69
  timeout=15
70
  )
71
- # FIXED: Added missing [0] index to resolve choices object extraction crash
72
  return chat_completion.choices[0].message.content.strip()
73
  except Exception as e:
74
  print(f"⚠️ Groq API issue detected: {e}")
@@ -91,11 +91,9 @@ def clone_and_speak(text):
91
  gen_text=text
92
  )
93
 
94
- # FIXED: Corrected tuple indexing format structure
95
  if isinstance(result, tuple):
96
- if len(result) == 2:
97
- audio_data, sample_rate = result
98
- elif len(result) >= 3:
99
  audio_data, sample_rate = result[0], result[1]
100
  else:
101
  audio_data, sample_rate = result[0], 24000
@@ -121,7 +119,6 @@ def clone_and_speak(text):
121
  # ========================================== #
122
  # 4. Request Router Pipeline #
123
  # ========================================== #
124
- # SINGLE DECORATOR: Reserves the GPU session cleanly for all execution sub-calls
125
  @spaces.GPU
126
  def chatbot_engine(text_input, audio_input):
127
  if audio_input is not None:
 
68
  max_tokens=40,
69
  timeout=15
70
  )
71
+ # FULLY FIXED: Added the mandatory list index [0] to read the response object properly
72
  return chat_completion.choices[0].message.content.strip()
73
  except Exception as e:
74
  print(f"⚠️ Groq API issue detected: {e}")
 
91
  gen_text=text
92
  )
93
 
94
+ # FULLY FIXED: Replaced structural breakdown syntax with solid array index indicators
95
  if isinstance(result, tuple):
96
+ if len(result) >= 2:
 
 
97
  audio_data, sample_rate = result[0], result[1]
98
  else:
99
  audio_data, sample_rate = result[0], 24000
 
119
  # ========================================== #
120
  # 4. Request Router Pipeline #
121
  # ========================================== #
 
122
  @spaces.GPU
123
  def chatbot_engine(text_input, audio_input):
124
  if audio_input is not None: