saq1b commited on
Commit
7c3f277
1 Parent(s): 4e239ef

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -3
app.py CHANGED
@@ -253,7 +253,13 @@ Follow this example structure:
253
  system_instruction=system_prompt
254
  )
255
 
256
- response = await model.generate_content_async(messages)
 
 
 
 
 
 
257
 
258
  print(f"Generated podcast script:\n{response.text}")
259
 
@@ -319,8 +325,7 @@ class TextExtractor:
319
  elif file_extension.lower() == '.txt':
320
  return await cls.extract_from_txt(file_path)
321
  else:
322
- gr.Error(f"Unsupported file type: {file_extension}")
323
- raise ValueError(f"Unsupported file type: {file_extension}")
324
 
325
  async def process_input(input_text: str, input_file, language: str, speaker1: str, speaker2: str, api_key: str = "") -> str:
326
  gr.Info("Starting podcast generation...")
 
253
  system_instruction=system_prompt
254
  )
255
 
256
+ try:
257
+ response = await model.generate_content_async(messages)
258
+ except Exception as e:
259
+ if "API key not valid" in str(e):
260
+ raise gr.Error("Invalid API key. Please provide a valid Gemini API key.")
261
+ else:
262
+ raise gr.Error(f"Failed to generate podcast script: {e}")
263
 
264
  print(f"Generated podcast script:\n{response.text}")
265
 
 
325
  elif file_extension.lower() == '.txt':
326
  return await cls.extract_from_txt(file_path)
327
  else:
328
+ raise gr.Error(f"Unsupported file type: {file_extension}")
 
329
 
330
  async def process_input(input_text: str, input_file, language: str, speaker1: str, speaker2: str, api_key: str = "") -> str:
331
  gr.Info("Starting podcast generation...")