Skip to content

Voice-to-text dictation app with local (Nvidia Parakeet/Whisper) and cloud models (BYOK). Privacy-first and available cross-platform.

fix: truncate custom dictionary prompt to respect Groq's 896-char limit

Gabriel Stein5fb8d90ef5a8
diff --git a/src/components/OnboardingFlow.tsx b/src/components/OnboardingFlow.tsx
index adf37f3a6..c250c003a 100644
--- a/src/components/OnboardingFlow.tsx
+++ b/src/components/OnboardingFlow.tsx
@@ -281,7 +281,15 @@ export default function OnboardingFlow({ onComplete }: OnboardingFlowProps) {
}
return true;
- }, [hotkey, agentName, setDictationKey, ensureHotkeyRegistered, isSignedIn, useLocalWhisper, updateTranscriptionSettings]);
+ }, [
+ hotkey,
+ agentName,
+ setDictationKey,
+ ensureHotkeyRegistered,
+ isSignedIn,
+ useLocalWhisper,
+ updateTranscriptionSettings,
+ ]);
const nextStep = useCallback(async () => {
if (currentStep >= steps.length - 1) {
diff --git a/src/helpers/audioManager.js b/src/helpers/audioManager.js
index 9e5ce2fb5..e56f22d8a 100644
--- a/src/helpers/audioManager.js
+++ b/src/helpers/audioManager.js
@@ -1421,8 +1421,26 @@ registerProcessor("pcm-streaming-processor", PCMStreamingProcessor);
}
// Add custom dictionary as prompt hint for cloud transcription
- const dictionaryPrompt = this.getCustomDictionaryPrompt();
+ // Groq Whisper API limits prompt to 896 chars; OpenAI ~900 chars.
+ // Truncate at last comma boundary so we never send a partial word.
+ const MAX_PROMPT_CHARS = provider === "groq" ? 896 : 900;
+ let dictionaryPrompt = this.getCustomDictionaryPrompt();
if (dictionaryPrompt) {
+ if (dictionaryPrompt.length > MAX_PROMPT_CHARS) {
+ const originalLength = dictionaryPrompt.length;
+ const truncated = dictionaryPrompt.slice(0, MAX_PROMPT_CHARS);
+ const lastComma = truncated.lastIndexOf(",");
+ dictionaryPrompt = lastComma > 0 ? truncated.slice(0, lastComma) : truncated;
+ logger.debug(
+ "Custom dictionary prompt truncated",
+ {
+ originalLength,
+ truncatedLength: dictionaryPrompt.length,
+ maxChars: MAX_PROMPT_CHARS,
+ },
+ "transcription"
+ );
+ }
formData.append("prompt", dictionaryPrompt);
}
@@ -1963,7 +1981,11 @@ registerProcessor("pcm-streaming-processor", PCMStreamingProcessor);
const [, wsResult] = await Promise.all([
this.cacheMicrophoneDeviceId(),
withSessionRefresh(async () => {
- const { preferredLanguage: warmupLang, cloudTranscriptionModel, cloudTranscriptionMode } = getSettings();
+ const {
+ preferredLanguage: warmupLang,
+ cloudTranscriptionModel,
+ cloudTranscriptionMode,
+ } = getSettings();
const res = await provider.warmup({
sampleRate: 16000,
language: warmupLang && warmupLang !== "auto" ? warmupLang : undefined,
@@ -2179,7 +2201,11 @@ registerProcessor("pcm-streaming-processor", PCMStreamingProcessor);
// 4. Connect WebSocket — audio is already flowing from the pipeline above,
// so Deepgram receives data immediately (no idle timeout).
const result = await withSessionRefresh(async () => {
- const { preferredLanguage: preferredLang, cloudTranscriptionModel, cloudTranscriptionMode } = getSettings();
+ const {
+ preferredLanguage: preferredLang,
+ cloudTranscriptionModel,
+ cloudTranscriptionMode,
+ } = getSettings();
const res = await provider.start({
sampleRate: 16000,
language: preferredLang && preferredLang !== "auto" ? preferredLang : undefined,
diff --git a/src/helpers/openaiRealtimeStreaming.js b/src/helpers/openaiRealtimeStreaming.js
index 2c1735525..1a0330824 100644
--- a/src/helpers/openaiRealtimeStreaming.js
+++ b/src/helpers/openaiRealtimeStreaming.js
@@ -252,7 +252,10 @@ class OpenAIRealtimeStreaming {
// Server VAD may have already committed all audio, causing an
// empty-buffer error. Resolve immediately instead of waiting for timeout.
this.onError = (err) => {
- if (err?.message?.includes("buffer too small") || err?.message?.includes("commit_empty")) {
+ if (
+ err?.message?.includes("buffer too small") ||
+ err?.message?.includes("commit_empty")
+ ) {
done();
} else {
prevOnError?.(err);