-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Feat/parakeet transcription #907
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Istiyaq-Khan
wants to merge
7
commits into
webadderallorg:main
Choose a base branch
from
Istiyaq-Khan:feat/parakeet-transcription
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 6 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
88c03e0
feat(transcription): add NVIDIA Parakeet-TDT backend via sherpa-onnx
Istiyaq-Khan c622fb5
feat(captions): automate cross-platform sherpa-onnx runtime resolutio…
Istiyaq-Khan d8a45b3
feat(captions): implement automatic audio chunking for Parakeet-TDT o…
Istiyaq-Khan 9f89955
fix(parakeet): resolve CodeRabbit review findings and harden runtime …
Istiyaq-Khan 3449990
fix(captions): resolve CodeRabbit findings and synchronize audio chun…
Istiyaq-Khan cfa9ac1
fix(captions): synchronize Parakeet chunk offsets with timeline coord…
Istiyaq-Khan a8ab7ce
fix(captions): synchronize companion audio start delay with timeline …
Istiyaq-Khan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,114 @@ | ||
| import os from "node:os"; | ||
| import path from "node:path"; | ||
| import fs from "node:fs/promises"; | ||
| import { existsSync } from "node:fs"; | ||
| import { describe, expect, it, vi } from "vitest"; | ||
| import { ParakeetEngineAdapter } from "./engine"; | ||
| import { segmentCuesIntoPhrases } from "./segment"; | ||
| import { detectSilenceIntervals } from "./silence"; | ||
| import { findExistingSherpaOnnxExecutable, resolveParakeetModelFiles } from "./parakeet"; | ||
| import { PARAKEET_MODEL_DIR } from "../constants"; | ||
| import { getFfmpegBinaryPath } from "../ffmpeg/binary"; | ||
| import { probeAudioDuration } from "./chunking"; | ||
|
|
||
| // Vitest hoisted mock setup so electron paths are dynamically resolved per platform | ||
| const { mockTempDir, mockUserDataDir } = await vi.hoisted(async () => { | ||
| const nodeOs = await import("node:os"); | ||
| const nodePath = await import("node:path"); | ||
| const temp = nodeOs.tmpdir(); | ||
| const userData = | ||
| process.platform === "win32" | ||
| ? nodePath.join( | ||
| process.env["APPDATA"] || nodePath.join(nodeOs.homedir(), "AppData", "Roaming"), | ||
| "Recordly-dev", | ||
| ) | ||
| : nodePath.join(nodeOs.homedir(), ".config", "Recordly-dev"); | ||
| return { mockTempDir: temp, mockUserDataDir: userData }; | ||
| }); | ||
|
|
||
| vi.mock("electron", () => ({ | ||
| app: { | ||
| isPackaged: false, | ||
| getPath: vi.fn((name: string) => { | ||
| if (name === "userData") return mockUserDataDir; | ||
| if (name === "temp") return mockTempDir; | ||
| return path.join(mockTempDir, "recordly-mock"); | ||
| }), | ||
| getAppPath: vi.fn(() => process.cwd()), | ||
| }, | ||
| })); | ||
|
|
||
| describe("ParakeetEngineAdapter Long Audio Integration", () => { | ||
| it("dynamically resolves runtime & model and transcribes long audio without ONNX broadcast mismatch", async () => { | ||
| // Dynamically locate sherpa-onnx binary and Parakeet model on the current system | ||
| const executablePath = await findExistingSherpaOnnxExecutable(); | ||
| let modelDir: string | null = null; | ||
| try { | ||
| const resolved = await resolveParakeetModelFiles(PARAKEET_MODEL_DIR); | ||
| modelDir = resolved.modelDir; | ||
| } catch { | ||
| // Model directory not downloaded on this machine | ||
| } | ||
|
|
||
| if (!executablePath || !modelDir) { | ||
| console.log( | ||
| "[Parakeet Integration] Skipping live inference: sherpa-onnx runtime or model is not installed on this machine.", | ||
| ); | ||
| return; | ||
| } | ||
|
|
||
| // Check for candidate recording files in user data | ||
| const recordingsDir = path.join(mockUserDataDir, "recordings"); | ||
| let candidateWav: string | null = null; | ||
|
|
||
| if (existsSync(recordingsDir)) { | ||
| const entries = await fs.readdir(recordingsDir).catch(() => [] as string[]); | ||
| for (const entry of entries) { | ||
| if (entry.endsWith(".wav")) { | ||
| const candidatePath = path.join(recordingsDir, entry); | ||
| try { | ||
| const dur = await probeAudioDuration(candidatePath); | ||
| if (dur > 25) { | ||
| candidateWav = candidatePath; | ||
| break; | ||
| } | ||
| } catch { | ||
| // Continue searching | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| if (!candidateWav) { | ||
| console.log( | ||
| "[Parakeet Integration] No audio recording > 25s found in recordings folder. Skipping live multi-chunk inference.", | ||
| ); | ||
| return; | ||
| } | ||
|
|
||
| const adapter = new ParakeetEngineAdapter(); | ||
| const result = await adapter.transcribe({ | ||
| videoPath: candidateWav, | ||
| audioWavPath: candidateWav, | ||
| executablePath, | ||
| modelPath: modelDir, | ||
| }); | ||
|
|
||
| expect(result.engine).toBe("parakeet"); | ||
| expect(result.cues.length).toBeGreaterThan(0); | ||
|
|
||
| // Verify phrase segmentation on chunked results | ||
| const ffmpegPath = getFfmpegBinaryPath(); | ||
| const silences = await detectSilenceIntervals({ | ||
| ffmpegPath, | ||
| wavPath: candidateWav, | ||
| }).catch(() => []); | ||
|
|
||
| const phrases = segmentCuesIntoPhrases(result.cues, silences); | ||
| expect(phrases.length).toBeGreaterThan(0); | ||
| for (const phrase of phrases) { | ||
| expect(phrase.text.trim().length).toBeGreaterThan(0); | ||
| expect(phrase.endMs).toBeGreaterThan(phrase.startMs); | ||
| } | ||
| }, 180_000); | ||
| }); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win
Use
AutoCaptionGenerateOptionsfor this IPC input.This declaration repeats the request shape already exported by
electron/ipc/types.ts. The duplicated fields can drift from the main-process contract. Typeoptionsasimport("./ipc/types").AutoCaptionGenerateOptionsinstead.🤖 Prompt for AI Agents