Skip to main content

🎙️ audio-transcripter

A lightweight TypeScript library for transcribing audio files using Google Gemini 2.0 models.


🚀 Installation

npm install audio-transcripter

🧑‍💻 Usage

1️⃣ Transcribe Local File

import { runTranscription } from "audio-transcripter";

const result = await runTranscription({
audioFile: "./assets/audio.webm",
style: "structured", // optional, default: 'conversational'
language: "english", // optional
});

if (result.success) {
console.log("Transcription:", result.transcription);
} else {
console.error("Error:", result.error);
}

2️⃣ Transcribe Remote URL

const result = await runTranscription({
audioFile: "https://example.com/audio.mp3",
style: "clean",
language: "english",
});

3️⃣ Transcribe Blob / Buffer (for browser or Node.js)

import { runTranscriptionWithBlob } from "audio-transcripter";

// Example with a Node.js Buffer
const fs = await import("fs/promises");
const audioBuffer = await fs.readFile("./assets/audio.wav");

const result = await runTranscriptionWithBlob(audioBuffer, {
style: "technical",
language: "english",
});

if (result.success) {
console.log("Transcription:", result.transcription);
} else {
console.error("Error:", result.error);
}

🔐 Authentication

This package requires a Gemini API Key.

1️⃣ Set TRANSCRIBER_KEY in your environment:

export TRANSCRIBER_KEY=your-gemini-api-key-here

or

2️⃣ Create a .env file:

TRANSCRIBER_KEY=your-gemini-api-key-here

Get your API key from Google MakerSuite.