iTranslated by AI
NotebookLM-style Podcast Generation with Gemini and VOICEVOX API
Summary
- Convert HTML/PDF to Markdown using MarkItDown
- Create commentary articles and dialogue scripts, and structure them using Gemini Flash 2.5 Preview
- Text-to-speech using VOICEVOX API (Aivis Speech)
- Create a WebUI with Gradio
Deliverables
Code (should be able to generate in about 5 minutes locally):
Web demo (takes about 20 minutes to generate):
Sample audio:
Paper used in the sample:
Purpose
A while ago, NotebookLM started supporting Japanese podcast generation, and I've been using it occasionally, thinking how interesting it is.
Then I realized that with recent technology, MarkItDown can handle converting PDF or HTML to Markdown, Gemini Flash 2.5's Japanese performance has become quite good, and there's natural-sounding text-to-speech like Aivis Speech, so I might be able to create a podcast generator like NotebookLM myself. I thought it would be fun to generate podcasts with high-quality voices for free. Yeah, definitely!
Architecture
The main models and libraries used are as follows:
-
gemini-2.5-flash-preview-05-20(https://aistudio.google.com) - MarkItDown
- litellm
I wanted to try using agent-related libraries, but they all felt like overkill for the task, so I ended up not using them. I also liked being able to work at a relatively low level, as I wasn't entirely sure how things were being processed under the hood.
However, for LLM API calls, I used litellm as a wrapper to make it easier to swap models later. This abstracts the differences in interfaces between providers.
Workflow
Following the summary, the process flows as follows:
- Fetch content from the URL.
- Convert to Markdown appropriately using MarkItDown.
-
Create a commentary article using Gemini Flash.
- I included this step because I thought it might be easier than generating a script from scratch, though I haven't done a comparison, so it might not be necessary.
- However, since the script seems to rely heavily on this commentary article, it may not be a bad way to decompose the task.
- Plus, there’s the minor benefit of being able to read the written text while listening to the audio.
-
Create a dialogue-style script using Gemini Flash.
- Structured output is not used at this stage (I decided to separate the steps as performing tasks with structured output reportedly degrades performance[1]).
-
Structured output with Gemini Flash.
- Feed the created script and have it output according to the JSON schema.
- Although it's a relatively simple task, Flash is one of the few models capable of structured output, so I used it here as well.
- Speech synthesis via VOICEVOX API.
- Synthesize audio based on the structured dialogue data.
- Once all dialogue is generated, concatenate the audio files.
Thoughts
Thanks to the maturity of surrounding technologies, I was able to build this without much trouble. In particular:
- Gemini Flash was quite impressive, generating podcast scripts without needing very detailed instructions.
- The experience with Aivis Speech was excellent; it naturally reads not just English words but even coined terms often found in research papers with ambiguous pronunciations.
These aspects were particularly good, and I didn't run into any strange roadblocks.
Before I started, I expected to struggle with prompt engineering or registering custom pronunciations for specific words, but that wasn't the case at all.
The only hurdle I faced was resolving versions and handling manifest files when trying to include Aivis Speech Engine as a dependency on HuggingFace Spaces. I managed the versioning by trial and error to find a combination that worked. For manifests and resources, I couldn't find a clean solution, so I settled for using a submodule.
I wanted to try "Vibe Coding," but I didn't feel like the LLM could handle these libraries yet—and even if it could, I figured it would be faster to just write it myself... I need to work on my vibes...
Overall, being able to generate podcasts with such high-quality voices is quite a lot of fun.
Discussion