Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -349,29 +349,28 @@ async def process_input(input_text: str, input_file, language: str, speaker1: st
|
|
| 349 |
# Gradio UI
|
| 350 |
def generate_podcast_gradio(input_text, input_file, language, speaker1, speaker2, api_key, progress=gr.Progress()):
|
| 351 |
# Handle the file if uploaded
|
| 352 |
-
file_obj = None
|
| 353 |
-
|
| 354 |
-
file_obj = input_file
|
| 355 |
-
|
| 356 |
-
# Use the progress function from Gradio
|
| 357 |
def progress_callback(value, text):
|
| 358 |
progress(value, text)
|
| 359 |
|
| 360 |
-
|
| 361 |
-
|
| 362 |
-
|
| 363 |
-
|
| 364 |
-
|
| 365 |
-
|
| 366 |
-
|
| 367 |
-
|
| 368 |
-
|
| 369 |
-
|
|
|
|
| 370 |
return result # Should be a string (audio file path)
|
| 371 |
except Exception as e:
|
| 372 |
# Don't return error string, RAISE for Gradio error popup
|
| 373 |
raise gr.Error(str(e))
|
| 374 |
|
|
|
|
| 375 |
def main():
|
| 376 |
with gr.Blocks(title="PodcastGen 🎙️") as demo:
|
| 377 |
gr.Markdown(
|
|
|
|
| 349 |
# Gradio UI
|
| 350 |
def generate_podcast_gradio(input_text, input_file, language, speaker1, speaker2, api_key, progress=gr.Progress()):
|
| 351 |
# Handle the file if uploaded
|
| 352 |
+
file_obj = input_file if input_file is not None else None
|
| 353 |
+
|
|
|
|
|
|
|
|
|
|
| 354 |
def progress_callback(value, text):
|
| 355 |
progress(value, text)
|
| 356 |
|
| 357 |
+
try:
|
| 358 |
+
# Run the async function in the event loop
|
| 359 |
+
result = asyncio.run(process_input(
|
| 360 |
+
input_text,
|
| 361 |
+
file_obj,
|
| 362 |
+
language,
|
| 363 |
+
speaker1,
|
| 364 |
+
speaker2,
|
| 365 |
+
api_key,
|
| 366 |
+
progress_callback
|
| 367 |
+
))
|
| 368 |
return result # Should be a string (audio file path)
|
| 369 |
except Exception as e:
|
| 370 |
# Don't return error string, RAISE for Gradio error popup
|
| 371 |
raise gr.Error(str(e))
|
| 372 |
|
| 373 |
+
|
| 374 |
def main():
|
| 375 |
with gr.Blocks(title="PodcastGen 🎙️") as demo:
|
| 376 |
gr.Markdown(
|