Wall06 commited on
Commit
6244153
Β·
verified Β·
1 Parent(s): 529e3cc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -10
app.py CHANGED
@@ -79,7 +79,7 @@ def smart_summary(text):
79
  errors.append(f"HF: {err}")
80
  return "⚠ SYSTEM FAILURE. DEBUG LOG:\n" + "\n".join(errors)
81
 
82
- # -------------------- AUDIO FUNCTION (UPDATED FOR V1.0) --------------------
83
  def generate_audio_report(text):
84
  # 1. Check Library
85
  try:
@@ -96,15 +96,14 @@ def generate_audio_report(text):
96
  if not api_key:
97
  raise gr.Error("❌ API Key Missing! Check Settings > Secrets.")
98
 
99
- # 4. Generate with NEW Syntax
100
  try:
101
  client = ElevenLabs(api_key=api_key)
102
 
103
- # Use 'text_to_speech.convert' instead of 'generate'
104
- # Voice ID for "Brian": nPczCjzI2devNBz1zQrb
105
  audio_stream = client.text_to_speech.convert(
106
  text=text[:400],
107
- voice_id="nPczCjzI2devNBz1zQrb",
108
  model_id="eleven_multilingual_v2"
109
  )
110
 
@@ -115,10 +114,11 @@ def generate_audio_report(text):
115
 
116
  except Exception as e:
117
  error_msg = str(e)
 
118
  if "401" in error_msg:
119
- raise gr.Error("❌ 401 Unauthorized: API Key is wrong.")
120
  elif "quota" in error_msg.lower():
121
- raise gr.Error("❌ Quota Exceeded: No credits left.")
122
  else:
123
  raise gr.Error(f"❌ ElevenLabs Error: {error_msg}")
124
 
@@ -240,7 +240,6 @@ custom_css = """
240
 
241
  with gr.Blocks(title="FlumenIntel") as demo:
242
  gr.HTML(f"<style>{custom_css}</style>")
243
-
244
  with gr.Column(elem_id="title-box"):
245
  gr.Markdown("# FlumenIntel 🌊\n### Advanced River Health Analytics")
246
 
@@ -304,5 +303,4 @@ with gr.Blocks(title="FlumenIntel") as demo:
304
  )
305
 
306
  if __name__ == "__main__":
307
- demo.launch()
308
- when i click the eleven report i got the 401 error
 
79
  errors.append(f"HF: {err}")
80
  return "⚠ SYSTEM FAILURE. DEBUG LOG:\n" + "\n".join(errors)
81
 
82
+ # -------------------- AUDIO FUNCTION (CORRECTED) --------------------
83
  def generate_audio_report(text):
84
  # 1. Check Library
85
  try:
 
96
  if not api_key:
97
  raise gr.Error("❌ API Key Missing! Check Settings > Secrets.")
98
 
99
+ # 4. Generate with NEW SYNTAX
100
  try:
101
  client = ElevenLabs(api_key=api_key)
102
 
103
+ # Brian's ID: nPczCjzI2devNBz1zQrb
 
104
  audio_stream = client.text_to_speech.convert(
105
  text=text[:400],
106
+ voice_id="nPczCjzI2devNBz1zQrb",
107
  model_id="eleven_multilingual_v2"
108
  )
109
 
 
114
 
115
  except Exception as e:
116
  error_msg = str(e)
117
+ # THIS IS THE ERROR YOU ARE SEEING
118
  if "401" in error_msg:
119
+ raise gr.Error("❌ 401 Unauthorized: The API KEY in Settings is wrong! Delete and re-add it.")
120
  elif "quota" in error_msg.lower():
121
+ raise gr.Error("❌ Quota Exceeded: You have 0 credits left.")
122
  else:
123
  raise gr.Error(f"❌ ElevenLabs Error: {error_msg}")
124
 
 
240
 
241
  with gr.Blocks(title="FlumenIntel") as demo:
242
  gr.HTML(f"<style>{custom_css}</style>")
 
243
  with gr.Column(elem_id="title-box"):
244
  gr.Markdown("# FlumenIntel 🌊\n### Advanced River Health Analytics")
245
 
 
303
  )
304
 
305
  if __name__ == "__main__":
306
+ demo.launch()