Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -1107,6 +1107,7 @@ if (gotSingleInstanceLock) {
googleCalendarManager.stop();
}
if (ipcHandlers) {
ipcHandlers.cleanupAllStreaming();
ipcHandlers._cleanupTextEditMonitor();
}
if (textEditMonitor) {
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
"format:check": "eslint . && cd src && eslint . && prettier --check \"**/*.{js,jsx,ts,tsx,json,css,md}\"",
"lint": "eslint . && cd src && eslint .",
"typecheck": "cd src && tsc --noEmit",
"test": "node --test",
"quality-check": "npm run format:check && npm run typecheck",
"i18n:check": "node scripts/check-i18n.js",
"preview": "cd src && vite preview",
Expand Down
28 changes: 28 additions & 0 deletions preload.js
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,10 @@ contextBridge.exposeInMainWorld("electronAPI", {
saveMistralKey: (key) => ipcRenderer.invoke("save-mistral-key", key),
proxyMistralTranscription: (data) => ipcRenderer.invoke("proxy-mistral-transcription", data),

// Soniox API
getSonioxKey: () => ipcRenderer.invoke("get-soniox-key"),
saveSonioxKey: (key) => ipcRenderer.invoke("save-soniox-key", key),

// Custom endpoint API keys
getCustomTranscriptionKey: () => ipcRenderer.invoke("get-custom-transcription-key"),
saveCustomTranscriptionKey: (key) => ipcRenderer.invoke("save-custom-transcription-key", key),
Expand Down Expand Up @@ -493,6 +497,30 @@ contextBridge.exposeInMainWorld("electronAPI", {
(callback) => (_event, data) => callback(data)
),

// Soniox streaming
sonioxStreamingWarmup: (options) => ipcRenderer.invoke("soniox-streaming-warmup", options),
sonioxStreamingStart: (options) => ipcRenderer.invoke("soniox-streaming-start", options),
sonioxStreamingSend: (audioBuffer) => ipcRenderer.send("soniox-streaming-send", audioBuffer),
sonioxStreamingFinalize: () => ipcRenderer.send("soniox-streaming-finalize"),
sonioxStreamingStop: () => ipcRenderer.invoke("soniox-streaming-stop"),
sonioxStreamingStatus: () => ipcRenderer.invoke("soniox-streaming-status"),
onSonioxPartialTranscript: registerListener(
"soniox-streaming-partial",
(callback) => (_event, text) => callback(text)
),
onSonioxFinalTranscript: registerListener(
"soniox-streaming-final",
(callback) => (_event, text) => callback(text)
),
onSonioxError: registerListener(
"soniox-streaming-error",
(callback) => (_event, error) => callback(error)
),
onSonioxSessionEnd: registerListener(
"soniox-streaming-session-end",
(callback) => (_event, data) => callback(data)
),

// Usage limit events (for showing UpgradePrompt in ControlPanel)
notifyLimitReached: (data) => ipcRenderer.send("limit-reached", data),
onLimitReached: registerListener("limit-reached", (callback) => (_event, data) => callback(data)),
Expand Down
1 change: 1 addition & 0 deletions src/assets/icons/providers/soniox.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions src/components/OnboardingFlow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ export default function OnboardingFlow({ onComplete }: OnboardingFlowProps) {
openaiApiKey,
groqApiKey,
mistralApiKey,
sonioxApiKey,
setSonioxApiKey,
customTranscriptionApiKey,
setCustomTranscriptionApiKey,
dictationKey,
Expand Down Expand Up @@ -502,6 +504,8 @@ export default function OnboardingFlow({ onComplete }: OnboardingFlowProps) {
setGroqApiKey={setGroqApiKey}
mistralApiKey={mistralApiKey}
setMistralApiKey={setMistralApiKey}
sonioxApiKey={sonioxApiKey}
setSonioxApiKey={setSonioxApiKey}
customTranscriptionApiKey={customTranscriptionApiKey}
setCustomTranscriptionApiKey={setCustomTranscriptionApiKey}
cloudTranscriptionBaseUrl={cloudTranscriptionBaseUrl}
Expand Down Expand Up @@ -725,6 +729,8 @@ export default function OnboardingFlow({ onComplete }: OnboardingFlowProps) {
return groqApiKey.trim().length > 0;
} else if (cloudTranscriptionProvider === "mistral") {
return mistralApiKey.trim().length > 0;
} else if (cloudTranscriptionProvider === "soniox") {
return sonioxApiKey.trim().length > 0;
} else if (cloudTranscriptionProvider === "custom") {
// Custom can work without API key for local endpoints
return true;
Expand Down
20 changes: 20 additions & 0 deletions src/components/SettingsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,10 @@ interface TranscriptionSectionProps {
setGroqApiKey: (key: string) => void;
mistralApiKey: string;
setMistralApiKey: (key: string) => void;
sonioxApiKey: string;
setSonioxApiKey: (key: string) => void;
sonioxSecondaryLanguage: string;
setSonioxSecondaryLanguage: (lang: string) => void;
customTranscriptionApiKey: string;
setCustomTranscriptionApiKey: (key: string) => void;
cloudTranscriptionBaseUrl?: string;
Expand Down Expand Up @@ -207,6 +211,10 @@ function TranscriptionSection({
setGroqApiKey,
mistralApiKey,
setMistralApiKey,
sonioxApiKey,
setSonioxApiKey,
sonioxSecondaryLanguage,
setSonioxSecondaryLanguage,
customTranscriptionApiKey,
setCustomTranscriptionApiKey,
cloudTranscriptionBaseUrl,
Expand Down Expand Up @@ -383,6 +391,10 @@ function TranscriptionSection({
setGroqApiKey={setGroqApiKey}
mistralApiKey={mistralApiKey}
setMistralApiKey={setMistralApiKey}
sonioxApiKey={sonioxApiKey}
setSonioxApiKey={setSonioxApiKey}
sonioxSecondaryLanguage={sonioxSecondaryLanguage}
setSonioxSecondaryLanguage={setSonioxSecondaryLanguage}
customTranscriptionApiKey={customTranscriptionApiKey}
setCustomTranscriptionApiKey={setCustomTranscriptionApiKey}
cloudTranscriptionBaseUrl={cloudTranscriptionBaseUrl}
Expand Down Expand Up @@ -676,6 +688,10 @@ export default function SettingsPage({ activeSection = "general" }: SettingsPage
setGeminiApiKey,
setGroqApiKey,
setMistralApiKey,
sonioxApiKey,
setSonioxApiKey,
sonioxSecondaryLanguage,
setSonioxSecondaryLanguage,
customTranscriptionApiKey,
setCustomTranscriptionApiKey,
customReasoningApiKey,
Expand Down Expand Up @@ -2670,6 +2686,10 @@ EOF`,
setGroqApiKey={setGroqApiKey}
mistralApiKey={mistralApiKey}
setMistralApiKey={setMistralApiKey}
sonioxApiKey={sonioxApiKey}
setSonioxApiKey={setSonioxApiKey}
sonioxSecondaryLanguage={sonioxSecondaryLanguage}
setSonioxSecondaryLanguage={setSonioxSecondaryLanguage}
customTranscriptionApiKey={customTranscriptionApiKey}
setCustomTranscriptionApiKey={setCustomTranscriptionApiKey}
cloudTranscriptionBaseUrl={cloudTranscriptionBaseUrl}
Expand Down
98 changes: 83 additions & 15 deletions src/components/TranscriptionModelPicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import { ProviderTabs } from "./ui/ProviderTabs";
import ModelCardList from "./ui/ModelCardList";
import { DownloadProgressBar } from "./ui/DownloadProgressBar";
import ApiKeyInput from "./ui/ApiKeyInput";
import LanguageSelector, { type LanguageOption } from "./ui/LanguageSelector";
import languageRegistry from "../config/languageRegistry.json";
import { ConfirmDialog } from "./ui/dialog";
import { useDialogs } from "../hooks/useDialogs";
import { useModelDownload, type DownloadProgress } from "../hooks/useModelDownload";
Expand All @@ -26,6 +28,7 @@ import { getProviderIcon, isMonochromeProvider } from "../utils/providerIcons";
import { API_ENDPOINTS, normalizeBaseUrl } from "../config/constants";
import { createExternalLinkHandler } from "../utils/externalLinks";
import { getCachedPlatform } from "../utils/platform";
import { useSettingsStore } from "../stores/settingsStore";
import type { CudaWhisperStatus } from "../types/electron";
import logger from "../utils/logger";

Expand Down Expand Up @@ -199,16 +202,25 @@ interface TranscriptionModelPickerProps {
setMistralApiKey: (key: string) => void;
customTranscriptionApiKey?: string;
setCustomTranscriptionApiKey?: (key: string) => void;
sonioxApiKey?: string;
setSonioxApiKey?: (key: string) => void;
sonioxSecondaryLanguage?: string;
setSonioxSecondaryLanguage?: (lang: string) => void;
cloudTranscriptionBaseUrl?: string;
setCloudTranscriptionBaseUrl?: (url: string) => void;
className?: string;
variant?: "onboarding" | "settings";
}

const SECONDARY_LANGUAGE_OPTIONS: LanguageOption[] = languageRegistry.languages
.filter((l) => l.code !== "auto")
.map(({ code, label, flag }) => ({ value: code, label, flag }));

const CLOUD_PROVIDER_TABS = [
{ id: "openai", name: "OpenAI" },
{ id: "groq", name: "Groq", recommended: true },
{ id: "mistral", name: "Mistral" },
{ id: "soniox", name: "Soniox" },
{ id: "custom", name: "Custom" },
];

Expand Down Expand Up @@ -274,12 +286,18 @@ export default function TranscriptionModelPicker({
setMistralApiKey,
customTranscriptionApiKey = "",
setCustomTranscriptionApiKey,
sonioxApiKey = "",
setSonioxApiKey,
sonioxSecondaryLanguage = "",
setSonioxSecondaryLanguage,
cloudTranscriptionBaseUrl = "",
setCloudTranscriptionBaseUrl,
className = "",
variant = "settings",
}: TranscriptionModelPickerProps) {
const { t } = useTranslation();
const preferredLanguage = useSettingsStore((s) => s.preferredLanguage);
const isAutoLanguage = !preferredLanguage || preferredLanguage === "auto";
const [localModels, setLocalModels] = useState<LocalModel[]>([]);
const [parakeetModels, setParakeetModels] = useState<LocalModel[]>([]);
const [internalLocalProvider, setInternalLocalProvider] = useState(selectedLocalProvider);
Expand Down Expand Up @@ -393,8 +411,13 @@ export default function TranscriptionModelPicker({
}
}
}
} else if (selectedCloudProvider !== "custom" && !selectedCloudModel) {
const provider = cloudProviders.find((p) => p.id === selectedCloudProvider);
} else if (
selectedCloudProvider !== "custom" &&
!selectedCloudModel
) {
const provider = cloudProviders.find(
(p) => p.id === selectedCloudProvider
);
if (provider?.models?.length) {
onCloudModelSelect(provider.models[0].id);
}
Expand Down Expand Up @@ -527,7 +550,9 @@ export default function TranscriptionModelPicker({
const handleCloudProviderChange = useCallback(
(providerId: string) => {
onCloudProviderSelect(providerId);
const provider = cloudProviders.find((p) => p.id === providerId);
const provider = cloudProviders.find(
(p) => p.id === providerId
);

if (providerId === "custom") {
onCloudModelSelect("whisper-1");
Expand All @@ -541,7 +566,12 @@ export default function TranscriptionModelPicker({
}
}
},
[cloudProviders, onCloudProviderSelect, onCloudModelSelect, setCloudTranscriptionBaseUrl]
[
cloudProviders,
onCloudProviderSelect,
onCloudModelSelect,
setCloudTranscriptionBaseUrl,
]
);

const handleLocalProviderChange = useCallback(
Expand Down Expand Up @@ -837,7 +867,11 @@ export default function TranscriptionModelPicker({
</label>
<Input
value={cloudTranscriptionBaseUrl}
onChange={(e) => setCloudTranscriptionBaseUrl?.(e.target.value)}
onChange={(e) =>
setCloudTranscriptionBaseUrl?.(
e.target.value
)
}
onBlur={handleBaseUrlBlur}
placeholder="https://your-api.example.com/v1"
className="h-8 text-sm"
Expand All @@ -846,7 +880,10 @@ export default function TranscriptionModelPicker({

<ApiKeyInput
apiKey={customTranscriptionApiKey}
setApiKey={setCustomTranscriptionApiKey || (() => {})}
setApiKey={
setCustomTranscriptionApiKey ||
(() => {})
}
label={t("transcription.apiKeyOptional")}
helpText=""
/>
Expand All @@ -857,7 +894,9 @@ export default function TranscriptionModelPicker({
</label>
<Input
value={selectedCloudModel}
onChange={(e) => onCloudModelSelect(e.target.value)}
onChange={(e) =>
onCloudModelSelect(e.target.value)
}
placeholder="whisper-1"
className="h-8 text-sm"
/>
Expand All @@ -877,7 +916,9 @@ export default function TranscriptionModelPicker({
groq: "https://console.groq.com/keys",
mistral: "https://console.mistral.ai/api-keys",
openai: "https://platform.openai.com/api-keys",
}[selectedCloudProvider] || "https://platform.openai.com/api-keys"
soniox: "https://console.soniox.com/",
}[selectedCloudProvider] ||
"https://platform.openai.com/api-keys"
)}
className="text-xs text-primary/70 hover:text-primary transition-colors cursor-pointer"
>
Expand All @@ -886,22 +927,49 @@ export default function TranscriptionModelPicker({
</div>
<ApiKeyInput
apiKey={
{ groq: groqApiKey, mistral: mistralApiKey, openai: openaiApiKey }[
selectedCloudProvider
] || openaiApiKey
{
groq: groqApiKey,
mistral: mistralApiKey,
openai: openaiApiKey,
soniox: sonioxApiKey,
}[selectedCloudProvider] ||
openaiApiKey
}
setApiKey={
{ groq: setGroqApiKey, mistral: setMistralApiKey, openai: setOpenaiApiKey }[
selectedCloudProvider
] || setOpenaiApiKey
{
groq: setGroqApiKey,
mistral: setMistralApiKey,
openai: setOpenaiApiKey,
soniox: setSonioxApiKey,
}[selectedCloudProvider] ||
setOpenaiApiKey
}
label=""
helpText=""
/>
</div>

{selectedCloudProvider === "soniox" && setSonioxSecondaryLanguage && (
<div className={`flex items-center justify-between gap-3 ${isAutoLanguage ? "opacity-50 pointer-events-none" : ""}`}>
<label className="text-xs font-medium text-foreground whitespace-nowrap">
{t("common.secondaryLanguage")}
</label>
<LanguageSelector
value={isAutoLanguage ? "none" : (sonioxSecondaryLanguage || "none")}
onChange={(value) => setSonioxSecondaryLanguage(value === "none" ? "" : value)}
options={[
{ value: "none", label: t("common.none"), flag: "" },
...SECONDARY_LANGUAGE_OPTIONS,
]}
className="min-w-32"
/>
</div>
)}

<div className="space-y-1.5">
<label className="text-xs font-medium text-foreground">{t("common.model")}</label>
<label className="text-xs font-medium text-foreground">
{t("common.model")}
</label>
<ModelCardList
models={cloudModelOptions}
selectedModel={selectedCloudModel}
Expand Down
Loading