siddhartharya
commited on
Commit
•
6d14527
1
Parent(s):
5f5ebb2
Update app.py
Browse files
app.py
CHANGED
@@ -47,9 +47,6 @@ def generate_podcast(file, url, tone, length):
|
|
47 |
audio_segments.append(audio_segment)
|
48 |
transcript += f"**{item.speaker}**: {item.text}\n\n"
|
49 |
os.remove(audio_file) # Clean up temporary audio file
|
50 |
-
|
51 |
-
# Yield progress updates
|
52 |
-
yield None, f"Generating audio for {item.speaker}..."
|
53 |
except Exception as e:
|
54 |
raise gr.Error(f"Error generating audio: {str(e)}")
|
55 |
|
@@ -61,4 +58,44 @@ def generate_podcast(file, url, tone, length):
|
|
61 |
|
62 |
return temp_audio_path, transcript
|
63 |
|
64 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
audio_segments.append(audio_segment)
|
48 |
transcript += f"**{item.speaker}**: {item.text}\n\n"
|
49 |
os.remove(audio_file) # Clean up temporary audio file
|
|
|
|
|
|
|
50 |
except Exception as e:
|
51 |
raise gr.Error(f"Error generating audio: {str(e)}")
|
52 |
|
|
|
58 |
|
59 |
return temp_audio_path, transcript
|
60 |
|
61 |
+
instructions = """
|
62 |
+
# Podcast Generator
|
63 |
+
|
64 |
+
Welcome to the Podcast Generator project! This tool allows you to create custom podcast episodes using AI-generated content.
|
65 |
+
|
66 |
+
## Features
|
67 |
+
* Generate podcast scripts from PDF content or web pages
|
68 |
+
* Convert text to speech for a natural listening experience
|
69 |
+
* Choose the tone of your podcast
|
70 |
+
* Export episodes as MP3 files
|
71 |
+
|
72 |
+
## How to Use
|
73 |
+
1. Upload a PDF file OR enter a URL (content will be truncated to 2048 tokens if longer)
|
74 |
+
2. Select the desired tone (humorous, casual, formal)
|
75 |
+
3. Choose the podcast length
|
76 |
+
4. Click "Generate" to create your podcast
|
77 |
+
5. Listen to the generated audio and review the transcript
|
78 |
+
|
79 |
+
Note: This tool uses the LLaMa 3.1 70B model for script generation and a lightweight TTS engine for voice synthesis. The input is limited to 2048 tokens to ensure compatibility with the model.
|
80 |
+
"""
|
81 |
+
|
82 |
+
iface = gr.Interface(
|
83 |
+
fn=generate_podcast,
|
84 |
+
inputs=[
|
85 |
+
gr.File(label="Upload PDF file (optional)", file_types=[".pdf"]),
|
86 |
+
gr.Textbox(label="OR Enter URL"),
|
87 |
+
gr.Radio(["humorous", "casual", "formal"], label="Select podcast tone", value="casual"),
|
88 |
+
gr.Radio(["Short (1-2 min)", "Medium (3-5 min)"], label="Podcast length", value="Medium (3-5 min)")
|
89 |
+
],
|
90 |
+
outputs=[
|
91 |
+
gr.Audio(label="Generated Podcast"),
|
92 |
+
gr.Markdown(label="Transcript")
|
93 |
+
],
|
94 |
+
title="Custom NotebookLM-type Podcast Generator (2048 token limit)",
|
95 |
+
description=instructions,
|
96 |
+
allow_flagging="never",
|
97 |
+
theme=gr.themes.Soft()
|
98 |
+
)
|
99 |
+
|
100 |
+
# This line is crucial for Hugging Face Spaces
|
101 |
+
app = gr.mount_gradio_app(iface)
|