marks commited on
Commit
8757c5b
·
1 Parent(s): 0a42087

Integrated scraper

Browse files
Files changed (1) hide show
  1. app.py +10 -1
app.py CHANGED
@@ -4,6 +4,7 @@ import gradio as gr
4
  from api_clients import OpenRouterClient, ElevenLabsClient
5
  from logger import setup_logger
6
  from config import Config
 
7
 
8
  logger = setup_logger("app")
9
 
@@ -34,7 +35,15 @@ class PodcasterUI:
34
  async def on_submit(self, content: str, model_id: str, voice_id: str, prompt: str = "") -> tuple:
35
  """Handle form submission with async API calls"""
36
  try:
37
- script = await self.router_client.generate_script(content, prompt, model_id)
 
 
 
 
 
 
 
 
38
  audio = await self.elevenlabs_client.generate_audio(script, voice_id)
39
  return script, audio
40
  except Exception as e:
 
4
  from api_clients import OpenRouterClient, ElevenLabsClient
5
  from logger import setup_logger
6
  from config import Config
7
+ from scraper import scrape_url
8
 
9
  logger = setup_logger("app")
10
 
 
35
  async def on_submit(self, content: str, model_id: str, voice_id: str, prompt: str = "") -> tuple:
36
  """Handle form submission with async API calls"""
37
  try:
38
+ # First scrape the webpage content
39
+ webpage_content = scrape_url(content)
40
+ if not webpage_content:
41
+ return "Failed to extract content from URL", None
42
+
43
+ # Generate script using the scraped content
44
+ script = await self.router_client.generate_script(webpage_content, prompt, model_id)
45
+
46
+ # Generate audio from the script
47
  audio = await self.elevenlabs_client.generate_audio(script, voice_id)
48
  return script, audio
49
  except Exception as e: