import gradio as gr from utils import generate_script, generate_audio from prompts import SYSTEM_PROMPT from pydub import AudioSegment import os def generate_podcast(file, tone, length): # Extract text from PDF # Generate script using generate_script function # Generate audio for each dialogue item # Combine audio segments # Return audio file and transcript # Gradio interface instructions = """ # Podcast Generator Welcome to the Podcast Generator project! This tool allows you to create custom podcast episodes using AI-generated content. ## Features * Generate podcast scripts on any topic * Convert text to speech for a natural listening experience * Choose the tone of your podcast * Export episodes as MP3 files ## How to Use 1. Upload a PDF file (max 2048 tokens) 2. Select the desired tone (humorous, casual, formal) 3. Choose the podcast length 4. Click "Generate" to create your podcast 5. Listen to the generated audio and review the transcript """ iface = gr.Interface( fn=generate_podcast, inputs=[ gr.File(label="Upload PDF file"), gr.Radio(["humorous", "casual", "formal"], label="Select podcast tone", value="casual"), gr.Radio(["Short (1-2 min)", "Medium (3-5 min)"], label="Podcast length", value="Medium (3-5 min)") ], outputs=[ gr.Audio(label="Generated Podcast"), gr.Markdown(label="Transcript") ], title="Custom NotebookLM-type Podcast Generator", description=instructions ) iface.launch()