Developed an API integration for Google Gemini AI to automatically generate Markdown documentation from transcripts.

This commit is contained in:
MikeHughes-BIN
2025-11-11 00:11:42 +01:00
parent af794e0245
commit e7271f216a
3 changed files with 1566 additions and 4 deletions
+1532
View File
File diff suppressed because it is too large Load Diff
+3 -4
View File
@@ -1,10 +1,11 @@
{ {
"type": "module", "type": "module",
"dependencies": { "dependencies": {
"@google/genai": "^1.29.0",
"cli-progress": "^3.12.0", "cli-progress": "^3.12.0",
"express": "^5.1.0",
"ffmpeg-static": "^5.2.0", "ffmpeg-static": "^5.2.0",
"fluent-ffmpeg": "^2.1.3", "fluent-ffmpeg": "^2.1.3"
"express": "^5.1.0"
}, },
"devDependencies": { "devDependencies": {
"@types/cli-progress": "^3.11.6", "@types/cli-progress": "^3.11.6",
@@ -31,5 +32,3 @@
"author": "", "author": "",
"license": "ISC" "license": "ISC"
} }
@@ -0,0 +1,31 @@
import { GoogleGenAI } from "@google/genai";
import fs from "fs";
// Written by Mike Hughes 10/11/25 - Code from
// https://www.geeksforgeeks.org/javascript/javascript-program-to-read-text-file/ for reading text files in JS
// and from https://ai.google.dev/gemini-api/docs/quickstart?hl=de for using Gemini API
// Before using, make sure to export the Google Gemini API key as an environment variable:
// export GOOGLE_API_KEY="your_api_key_here"
// Keys can be obtained from https://aistudio.google.com/app/api-keys
// Also make sure to install the package via sudo npm install @google/genai
const ai = new GoogleGenAI({});
let transcript = "";
async function main() {
try {
const transcript = await fs.promises.readFile('../../../../storage/transcripts/Kurzgesagt.txt', 'utf-8');
const response = await ai.models.generateContent({
model: "gemini-2.5-flash",
contents: `Create a short documentation about the content of the following transcript:\n\n${transcript}`,
});
console.log(response.text);
fs.writeFileSync("../../../../storage/documents/Kurzgesagt_documentation.md", response.text, "utf8");
} catch (error) {
console.error('Error generating content:', error);
}
}
main();