Asset Generation Scripts
Relevant source files
The following files were used as context for generating this wiki page:The youtube_notes project includes several scripts and modules dedicated to generating assets. These assets fall into two primary categories: audio voiceovers for marketing materials and AI-generated text content derived from YouTube video transcripts. The audio generation pipeline creates voiceovers for promotional videos, while the text generation system leverages the Google Gemini API to transform raw transcripts into structured content like Twitter threads, LinkedIn posts, and blog outlines.
These generation capabilities are central to the project's vision of turning long-form video content into "actionable intelligence." The audio assets support the "Agency-Grade Marketing Engine," and the text assets power the "Smart Board Analysis" feature, which automatically creates high-fidelity content structures from video transcripts.
Sources: README.md, generate_vo.py, services/geminiService.ts
Audio Asset Generation
This pipeline is responsible for creating and embedding an MP3 voiceover for the project's marketing videos. It consists of two main Python scripts: generate_vo.py for creating the audio file and inject_audio_unified.py for embedding it into an HTML file.
Sources: generate_vo.py, inject_audio_unified.py
Voiceover Generation (generate_vo.py)
This script converts a predefined text script into an MP3 audio file using the Google Cloud Text-to-Speech API.
The script defines a marketing script using Speech Synthesis Markup Language (SSML) to control pronunciation and pacing. It then sends this script to the Google TTS API with specific voice and audio configurations. The resulting audio content is base64-decoded and saved as assets/nota_voiceover.mp3.
Sources: generate_vo.py:10-22, 30-36
The overall process is illustrated below:
This diagram shows the flow of the voiceover generation script from reading the internal script to saving the final MP3 file.
Sources: generate_vo.py:24-41
The API request is configured with the following parameters:
| Parameter | Value | Description |
|---|---|---|
input | SSML Text | The script to be synthesized. |
voice.languageCode | en-US | The language of the voice. |
voice.name | en-US-Studio-M | The specific voice model. |
voice.ssmlGender | MALE | The gender of the voice. |
audioConfig.audioEncoding | MP3 | The desired audio output format. |
audioConfig.speakingRate | 1.3 | The speed of the speech (30% faster). |
audioConfig.pitch | -2.0 | The pitch of the voice (lower). |
Sources: generate_vo.py:25-29
Audio Injection (inject_audio_unified.py)
This script is a command-line utility designed to embed the generated nota_voiceover.mp3 file directly into a marketing HTML file as a base64-encoded data URI. This makes the HTML file self-contained without external audio dependencies.
The script is flexible and accepts arguments to specify the target HTML file, the audio file, a placeholder string to find in the HTML, and a replacement template.
Sources: inject_audio_unified.py:3-20
The injection process is as follows:
This diagram shows how the inject_audio_unified.py script embeds an audio file into an HTML document.
Sources: inject_audio_unified.py:23-51
The script is executed via the command line with the following arguments:
| Argument | Required | Default | Description |
|---|---|---|---|
--html | Yes | N/A | Path to the HTML file to modify. |
--audio | No | assets/nota_voiceover.mp3 | Path to the MP3 audio file. |
--target | Yes | N/A | The placeholder string to find and replace in the HTML. |
--replacement | Yes | N/A | The replacement template, which must include a {b64_audio} placeholder. |
Sources: inject_audio_unified.py:60-79
AI-Powered Text Content Generation
This system is responsible for generating various forms of text-based content from a raw video transcript. It is a core part of the "Smart Board Analysis" feature. The architecture involves a React hook (useContentGenerator) that orchestrates calls to a service module (geminiService), which in turn communicates with the Google Gemini API.
Sources: README.md:20-25, hooks/useContentGenerator.ts, services/geminiService.ts
System Architecture
The generation process is initiated on the frontend after a video transcript is successfully loaded. The useContentGenerator hook triggers multiple parallel requests to the geminiService, which has specific functions for each type of content.
The following sequence diagram illustrates the flow:
This diagram shows the parallel content generation process initiated by the useContentGenerator hook.
Sources: hooks/useContentGenerator.ts:88-100, services/geminiService.ts
Gemini Service (geminiService.ts)
This TypeScript module is the sole interface for communicating with the Google Gemini API. It contains specialized functions for generating different types of content, each with a carefully crafted system instruction (prompt) to guide the AI model. All functions use the gemini-2.0-flash model.
Sources: services/geminiService.ts:40, 78, 126
The primary content generation functions are:
| Function | System Instruction Goal | Output Format |
|---|---|---|
generateTwitterThread | Create a 7-10 tweet thread from the transcript. | string[] |
generateLinkedInPost | Create a professional LinkedIn post with a hook, body, CTA, and hashtags. | LinkedInPost (JSON) |
generateBlogOutline | Create an SEO-optimized blog post outline with a title, sections, and keywords. | BlogOutline (JSON) |
generateKeyTakeaways | Extract 5-7 concise, actionable takeaways with emojis. | KeyTakeaway[] (JSON) |
cleanTranscriptText | Transform a raw transcript snippet into a clean, grammatically correct sentence. | string |
Sources: services/geminiService.ts:6-12, 68-76, 119-124, 134-141, 149-156, types.ts:42-65
An example of a system instruction is the one for generating a LinkedIn post, which strictly defines the JSON output structure:
const LINKEDIN_INSTRUCTION = `
You are a professional LinkedIn thought leader. Convert this video transcript into a compelling LinkedIn post.
Output EXACTLY in this JSON format (no markdown, no code blocks):
{"hook":"[Attention-grabbing first line]","body":"[3-4 paragraphs of value]","cta":"[Call to action]","hashtags":["tag1","tag2","tag3"]}
Rules:
- Hook: Bold statement or question (under 100 chars)
- Body: Professional tone, insights, lessons learned
- CTA: Encourage engagement
- Hashtags: 3-5 relevant tags
`;
Sources: services/geminiService.ts:119-132
Content Generation Hook (useContentGenerator.ts)
This React hook manages the state and logic for the content generation process. Its key responsibilities include:
- Orchestration: Calling all generation functions from
geminiServicein parallel viaPromise.allSettledfor efficiency. - State Management: Tracking the progress of each generation task (
loading,done,error) and storing the finalContentOutput. - Persistence: Automatically saving generated content to
localStoragewith a key based on thevideoIdand loading it back on subsequent visits.