Generate Conversation from PDF with PlayNote API
NotebookLM-style Podcast with PlayNote API Guide
This guide will walk you through generating a conversational-style podcast from a PDF using the PlayNote API. We’ll use the PlayNote API
to take a PDF source file, synthesize it into an audio conversation between two voices, and retrieve the generated podcast URL. This tutorial assumes basic knowledge of Python and API requests.
Prerequisites
Before you start, ensure you have the following:
-
API Key and User ID: You need your
PLAYDIALOG_API_KEY
andPLAYDIALOG_USER_ID
from PlayDialog. Set these as environment variables to avoid exposing them directly in your code. -
Python Libraries: Install the
requests
library if you haven’t already.
Setup your API Key
To keep your API key secure and avoid hardcoding it directly into your code, you can store it as an environment variable. This way, your script can access it securely without exposing the key.
Step 1: Set the Environment Variable
For macOS and Linux
-
Open your terminal.
-
Add this line to your ~/.bashrc or ~/.zshrc file to make it persistent across sessions
- Run
~/.bashrc (or source ~/.zshrc for zsh)
to load the variables into your current session.
For Windows
-
Open Command Prompt or PowerShell.
-
Use the
setx
command to create each environment variable individually:
- Restart your terminal to apply the changes.
Step 1: Setup and Initialize
Start by importing necessary libraries and setting up the API endpoint and headers.
Step 2: Send Request to Generate PlayNote
This step initiates the podcast creation process. Define the parameters such as synthesisStyle, sourceFileUrl, and the voices you want to use.
Note: The PlayNote ID will be used to poll for the podcast’s generation status.
At the end of this step, you’d get the following message:
Step 3: Poll for Completion
After requesting a PlayNote, wait a few minutes before checking the status. Use the PlayNote ID to poll for the audio’s readiness.
Final Output
Once the status shows as completed, the audio URL will be printed. You can use this link to access the generated podcast-style conversation.
Example Output
After completion, expect the output to look like this:
Troubleshooting
-
Authentication Errors: Ensure that api_key and user_id are correctly set in your environment.
-
Source File Issues: Ensure your PDFs are publicly accessible
-
Generation Time: If the response indicates the PlayNote is still being generated, allow more time before retrying.
This guide provides a simple yet powerful way to turn text content from a PDF into a rich, conversational podcast format using PlayNote API. Modify the voice parameters to customize the conversation to match your desired style.