Rausda6 commited on
Commit
413618e
·
verified ·
1 Parent(s): d25d7b2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -7
app.py CHANGED
@@ -154,13 +154,13 @@ Generate JSON:"""
154
  generation_config=self.generation_config,
155
  pad_token_id=self.tokenizer.pad_token_id,
156
  )
157
-
158
  # Decode only the new tokens
159
  generated_text = self.tokenizer.decode(
160
  output[0][inputs['input_ids'].shape[1]:],
161
  skip_special_tokens=True
162
  )
163
-
164
  print(f"Generated text: {generated_text[:500]}...")
165
 
166
  if progress:
@@ -274,6 +274,9 @@ Generate JSON:"""
274
  if not podcast_json.get('podcast'):
275
  raise Exception("No podcast content generated")
276
 
 
 
 
277
  if progress:
278
  progress(0.5, "Converting text to speech...")
279
 
@@ -334,7 +337,7 @@ async def process_input(input_text: str, input_file, language: str, speaker1: st
334
  # Map speaker names to voice IDs
335
  speaker1_voice = VOICE_MAPPING.get(speaker1, "en-US-AndrewMultilingualNeural")
336
  speaker2_voice = VOICE_MAPPING.get(speaker2, "en-US-AvaMultilingualNeural")
337
-
338
  # Validate input
339
  if not input_text or input_text.strip() == "":
340
  if input_file is None:
@@ -346,6 +349,7 @@ async def process_input(input_text: str, input_file, language: str, speaker1: st
346
  input_text, language, speaker1_voice, speaker2_voice, input_file, progress
347
  )
348
 
 
349
  end_time = time.time()
350
  print(f"Total generation time: {end_time - start_time:.2f} seconds")
351
  return result
@@ -356,7 +360,6 @@ async def process_input(input_text: str, input_file, language: str, speaker1: st
356
  raise Exception(f"Generation failed: {error_msg}")
357
 
358
  def generate_podcast_gradio(input_text, input_file, language, speaker1, speaker2):
359
- """Gradio interface function with proper error handling"""
360
  try:
361
  # Validate inputs
362
  if not input_text and input_file is None:
@@ -364,14 +367,15 @@ def generate_podcast_gradio(input_text, input_file, language, speaker1, speaker2
364
 
365
  if input_text and len(input_text.strip()) == 0:
366
  input_text = None
367
-
368
  # Create a simple progress tracker
369
  progress_history = []
370
-
 
371
  def progress_callback(value, text):
372
  progress_history.append(f"{value:.1%}: {text}")
373
  print(f"Progress: {value:.1%} - {text}")
374
-
375
  # Run the async function
376
  loop = asyncio.new_event_loop()
377
  asyncio.set_event_loop(loop)
@@ -448,6 +452,12 @@ def create_interface():
448
  size="lg"
449
  )
450
 
 
 
 
 
 
 
451
  output_audio = gr.Audio(
452
  label="Generated Podcast",
453
  type="filepath",
 
154
  generation_config=self.generation_config,
155
  pad_token_id=self.tokenizer.pad_token_id,
156
  )
157
+ logs.append("✅ calling llm")
158
  # Decode only the new tokens
159
  generated_text = self.tokenizer.decode(
160
  output[0][inputs['input_ids'].shape[1]:],
161
  skip_special_tokens=True
162
  )
163
+ logs.append("✅ generated text")
164
  print(f"Generated text: {generated_text[:500]}...")
165
 
166
  if progress:
 
274
  if not podcast_json.get('podcast'):
275
  raise Exception("No podcast content generated")
276
 
277
+
278
+ logs.append("✅ process input 1")
279
+
280
  if progress:
281
  progress(0.5, "Converting text to speech...")
282
 
 
337
  # Map speaker names to voice IDs
338
  speaker1_voice = VOICE_MAPPING.get(speaker1, "en-US-AndrewMultilingualNeural")
339
  speaker2_voice = VOICE_MAPPING.get(speaker2, "en-US-AvaMultilingualNeural")
340
+ logs.append("✅ process input 1")
341
  # Validate input
342
  if not input_text or input_text.strip() == "":
343
  if input_file is None:
 
349
  input_text, language, speaker1_voice, speaker2_voice, input_file, progress
350
  )
351
 
352
+ logs.append("✅ process input 2")
353
  end_time = time.time()
354
  print(f"Total generation time: {end_time - start_time:.2f} seconds")
355
  return result
 
360
  raise Exception(f"Generation failed: {error_msg}")
361
 
362
  def generate_podcast_gradio(input_text, input_file, language, speaker1, speaker2):
 
363
  try:
364
  # Validate inputs
365
  if not input_text and input_file is None:
 
367
 
368
  if input_text and len(input_text.strip()) == 0:
369
  input_text = None
370
+ logs.append("✅ File processing 1")
371
  # Create a simple progress tracker
372
  progress_history = []
373
+
374
+
375
  def progress_callback(value, text):
376
  progress_history.append(f"{value:.1%}: {text}")
377
  print(f"Progress: {value:.1%} - {text}")
378
+ logs.append("✅ File processing 2")
379
  # Run the async function
380
  loop = asyncio.new_event_loop()
381
  asyncio.set_event_loop(loop)
 
452
  size="lg"
453
  )
454
 
455
+ log_output = gr.Textbox(
456
+ label="🪵 Debug & Transcript Log",
457
+ lines=15,
458
+ interactive=False
459
+ )
460
+
461
  output_audio = gr.Audio(
462
  label="Generated Podcast",
463
  type="filepath",