Skip to main content

Local Transcription (Whisper)

window.electronAPI.transcribeLocalWhisper()

Transcribe audio using a locally-installed Whisper model.
audioBlob
ArrayBuffer
required
Audio data as an ArrayBuffer. Typically obtained from a Blob:
const arrayBuffer = await audioBlob.arrayBuffer();
options
object
success
boolean
Whether transcription succeeded
text
string
Transcribed text
error
string
Error message if success is false
message
string
Additional info (e.g., “No audio detected”)

Example

const audioBlob = await recorder.stop(); // From MediaRecorder
const arrayBuffer = await audioBlob.arrayBuffer();

const result = await window.electronAPI.transcribeLocalWhisper(arrayBuffer, {
  model: "base",
  language: "en"
});

if (result.success) {
  console.log("Transcription:", result.text);
} else {
  console.error("Error:", result.error);
}
No Audio Detected: If the audio is too short or silent, the API returns success: false with message: "No audio detected". Listen for the onNoAudioDetected event to handle this in the UI.

Local Transcription (Parakeet)

window.electronAPI.transcribeLocalParakeet()

Transcribe audio using NVIDIA’s Parakeet model via sherpa-onnx.
audioBlob
ArrayBuffer
required
Audio data as an ArrayBuffer
options
object
success
boolean
Whether transcription succeeded
text
string
Transcribed text
error
string
Error message if failed

Example

const result = await window.electronAPI.transcribeLocalParakeet(arrayBuffer, {
  model: "parakeet-tdt-0.6b-v3",
  language: "en"
});

if (result.success) {
  console.log("Parakeet transcription:", result.text);
}

Cloud Transcription

window.electronAPI.cloudTranscribe()

Transcribe audio using the OpenWhispr Cloud API (requires authentication).
audioBuffer
ArrayBuffer
required
Audio data as an ArrayBuffer
opts
object
success
boolean
Whether transcription succeeded
text
string
Transcribed text
error
string
Error message if failed
code
string
Error code (e.g., “AUTH_EXPIRED”, “OFFLINE”)
limitReached
boolean
Whether usage limit was reached
wordsUsed
number
Total words used in current period
wordsRemaining
number
Words remaining in current period

Example

const result = await window.electronAPI.cloudTranscribe(arrayBuffer, {
  language: "en",
  prompt: "OpenWhispr, API, transcription"
});

if (result.success) {
  console.log("Transcription:", result.text);
  console.log("Words remaining:", result.wordsRemaining);
} else if (result.code === "AUTH_EXPIRED") {
  // Redirect to login
}

Audio File Transcription

window.electronAPI.transcribeAudioFile()

Transcribe an audio file from disk using local models.
filePath
string
required
Absolute path to the audio file
options
object
success
boolean
Whether transcription succeeded
text
string
Transcribed text
error
string
Error message if failed

Example

const { filePath } = await window.electronAPI.selectAudioFile();

if (!filePath) return; // User cancelled

const result = await window.electronAPI.transcribeAudioFile(filePath, {
  provider: "whisper",
  model: "base",
  language: "en"
});

if (result.success) {
  console.log("File transcription:", result.text);
}

Audio File Selection

window.electronAPI.selectAudioFile()

Open a file picker to select an audio file.
canceled
boolean
Whether the user cancelled the dialog
filePath
string
Path to the selected audio file (if not cancelled)

Supported Formats

  • MP3 (.mp3)
  • WAV (.wav)
  • M4A (.m4a)
  • WebM (.webm)
  • OGG (.ogg)
  • FLAC (.flac)
  • AAC (.aac)

Example

const { canceled, filePath } = await window.electronAPI.selectAudioFile();

if (!canceled) {
  const size = await window.electronAPI.getFileSize(filePath);
  console.log(`Selected file: ${filePath} (${size} bytes)`);
}

Transcription Events

window.electronAPI.onNoAudioDetected()

Listen for “no audio detected” events during recording.
const cleanup = window.electronAPI.onNoAudioDetected(() => {
  showToast("No audio detected. Try speaking louder or check your microphone.");
});

// Clean up listener when component unmounts
cleanup();

Installation Checks

window.electronAPI.checkWhisperInstallation()

Check if Whisper binaries are available.
installed
boolean
Whether Whisper is installed
path
string
Path to the Whisper binary

Example

const status = await window.electronAPI.checkWhisperInstallation();

if (!status.installed) {
  console.log("Whisper not found. Please download models.");
}

window.electronAPI.checkParakeetInstallation()

Check if Parakeet (sherpa-onnx) binaries are available.
installed
boolean
Whether Parakeet is installed
path
string
Path to the sherpa-onnx binary

Build docs developers (and LLMs) love