Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -58,13 +58,18 @@ def process_pdf_to_podcast(pdf_file):
|
|
| 58 |
f"Steps 1-3 completed. Preview and adjust the rewritten transcript if needed.",
|
| 59 |
text_preview,
|
| 60 |
transcript_preview,
|
| 61 |
-
tts_ready_preview
|
|
|
|
| 62 |
)
|
| 63 |
|
| 64 |
|
| 65 |
# Final Step: Generate Audio after optional adjustments
|
| 66 |
@spaces.GPU
|
| 67 |
-
def generate_audio_from_modified_text(tts_ready_text):
|
|
|
|
|
|
|
|
|
|
|
|
|
| 68 |
# Save any modified TTS-ready transcript
|
| 69 |
with open(tts_ready_path, 'wb') as f:
|
| 70 |
pickle.dump(tts_ready_text, f)
|
|
@@ -98,18 +103,20 @@ with gr.Blocks() as app:
|
|
| 98 |
# Button for generating audio with editable transcript
|
| 99 |
generate_audio_button = gr.Button("Generate Audio from Edited Transcript")
|
| 100 |
final_audio_output = gr.Audio(label="Generated Podcast Audio")
|
|
|
|
|
|
|
| 101 |
|
| 102 |
# Step 1-3 execution
|
| 103 |
run_all_button.click(
|
| 104 |
process_pdf_to_podcast,
|
| 105 |
inputs=pdf_input,
|
| 106 |
-
outputs=[output_status, extracted_text_preview, transcript_preview, tts_ready_preview]
|
| 107 |
)
|
| 108 |
|
| 109 |
# Final step: Generate Audio from modified TTS-ready transcript
|
| 110 |
generate_audio_button.click(
|
| 111 |
generate_audio_from_modified_text,
|
| 112 |
-
inputs=tts_ready_preview,
|
| 113 |
outputs=[output_status, final_audio_output]
|
| 114 |
)
|
| 115 |
|
|
|
|
| 58 |
f"Steps 1-3 completed. Preview and adjust the rewritten transcript if needed.",
|
| 59 |
text_preview,
|
| 60 |
transcript_preview,
|
| 61 |
+
tts_ready_preview,
|
| 62 |
+
session_dir
|
| 63 |
)
|
| 64 |
|
| 65 |
|
| 66 |
# Final Step: Generate Audio after optional adjustments
|
| 67 |
@spaces.GPU
|
| 68 |
+
def generate_audio_from_modified_text(tts_ready_text,session_dir):
|
| 69 |
+
|
| 70 |
+
tts_ready_path = os.path.join(session_dir, "podcast_ready_data.pkl")
|
| 71 |
+
audio_output_path = os.path.join(session_dir, "final_podcast_audio.mp3")
|
| 72 |
+
|
| 73 |
# Save any modified TTS-ready transcript
|
| 74 |
with open(tts_ready_path, 'wb') as f:
|
| 75 |
pickle.dump(tts_ready_text, f)
|
|
|
|
| 103 |
# Button for generating audio with editable transcript
|
| 104 |
generate_audio_button = gr.Button("Generate Audio from Edited Transcript")
|
| 105 |
final_audio_output = gr.Audio(label="Generated Podcast Audio")
|
| 106 |
+
|
| 107 |
+
session_dir = gr.State()
|
| 108 |
|
| 109 |
# Step 1-3 execution
|
| 110 |
run_all_button.click(
|
| 111 |
process_pdf_to_podcast,
|
| 112 |
inputs=pdf_input,
|
| 113 |
+
outputs=[output_status, extracted_text_preview, transcript_preview, tts_ready_preview,session_dir]
|
| 114 |
)
|
| 115 |
|
| 116 |
# Final step: Generate Audio from modified TTS-ready transcript
|
| 117 |
generate_audio_button.click(
|
| 118 |
generate_audio_from_modified_text,
|
| 119 |
+
inputs=[tts_ready_preview, session_dir]
|
| 120 |
outputs=[output_status, final_audio_output]
|
| 121 |
)
|
| 122 |
|