Voice-to-text dictation app with local (Nvidia Parakeet/Whisper) and cloud models (BYOK). Privacy-first and available cross-platform.
JavaScript aianthropiccross-platformgeminigroqlinuxmacosnvidiaopen-sourceopenaiparakeetspeech-to-texttranscribewhisperwindows
feat: push to talk
Gabriel Steinb7eb2dd05c59
diff --git a/main.js b/main.jsindex aba216b64..84a7a6b6c 100644--- a/main.js+++ b/main.js@@ -171,7 +171,11 @@ trayManager.setWindowManager(windowManager);updateManager.checkForUpdatesOnStartup();if (process.platform === "darwin") {- globeKeyManager.on("globe-down", () => {+ let globeKeyDownTime = 0;+ let globeKeyIsRecording = false;+ const MIN_HOLD_DURATION_MS = 150; // Minimum hold time to trigger push-to-talk++ globeKeyManager.on("globe-down", async () => {// Forward to control panel for hotkey captureif (windowManager.controlPanelWindow &&@@ -180,14 +184,45 @@ trayManager.setWindowManager(windowManager);windowManager.controlPanelWindow.webContents.send("globe-key-pressed");}- // Handle dictation toggle if Globe is the current hotkey+ // Handle dictation if Globe is the current hotkeyif (hotkeyManager.getCurrentHotkey && hotkeyManager.getCurrentHotkey() === "GLOBE") {if (windowManager.mainWindow &&!windowManager.mainWindow.isDestroyed()) {+ const activationMode = await windowManager.getActivationMode();windowManager.showDictationPanel();- windowManager.mainWindow.webContents.send("toggle-dictation");+ if (activationMode === "push") {+ // Track when key was pressed for push-to-talk+ globeKeyDownTime = Date.now();+ globeKeyIsRecording = false;+ // Start recording after a brief delay to distinguish tap from hold+ setTimeout(async () => {+ // Only start if key is still being held+ if (globeKeyDownTime > 0 && !globeKeyIsRecording) {+ globeKeyIsRecording = true;+ windowManager.sendStartDictation();+ }+ }, MIN_HOLD_DURATION_MS);+ } else {+ windowManager.mainWindow.webContents.send("toggle-dictation");+ }+ }+ }+ });++ globeKeyManager.on("globe-up", async () => {+ // Handle push-to-talk release if Globe is the current hotkey+ if (hotkeyManager.getCurrentHotkey && hotkeyManager.getCurrentHotkey() === "GLOBE") {+ const activationMode = await windowManager.getActivationMode();+ if (activationMode === "push") {+ globeKeyDownTime = 0;+ // Only stop if we actually started recording+ if (globeKeyIsRecording) {+ globeKeyIsRecording = false;+ windowManager.sendStopDictation();+ }+ // If released too quickly, don't do anything (tap is ignored in push mode)}}});diff --git a/preload.js b/preload.jsindex 54326a486..3ab869748 100644--- a/preload.js+++ b/preload.js@@ -30,6 +30,14 @@ contextBridge.exposeInMainWorld("electronAPI", {"toggle-dictation",(callback) => () => callback()),+ onStartDictation: registerListener(+ "start-dictation",+ (callback) => () => callback()+ ),+ onStopDictation: registerListener(+ "stop-dictation",+ (callback) => () => callback()+ ),// Database functionssaveTranscription: (text) =>diff --git a/src/components/OnboardingFlow.tsx b/src/components/OnboardingFlow.tsxindex 274d36758..35e7db93a 100644--- a/src/components/OnboardingFlow.tsx+++ b/src/components/OnboardingFlow.tsx@@ -39,6 +39,7 @@ import { formatHotkeyLabel, getDefaultHotkey } from "../utils/hotkeys";import { API_ENDPOINTS, buildApiUrl, normalizeBaseUrl } from "../config/constants";import { HotkeyInput } from "./ui/HotkeyInput";import { useHotkeyRegistration } from "../hooks/useHotkeyRegistration";+import { ActivationModeSelector } from "./ui/ActivationModeSelector";interface OnboardingFlowProps {onComplete: () => void;@@ -81,6 +82,8 @@ export default function OnboardingFlow({ onComplete }: OnboardingFlowProps) {reasoningModel,openaiApiKey,dictationKey,+ activationMode,+ setActivationMode,setUseLocalWhisper,setWhisperModel,setPreferredLanguage,@@ -824,7 +827,7 @@ export default function OnboardingFlow({ onComplete }: OnboardingFlowProps) {<div className="space-y-6"><div className="text-center"><h2 className="text-2xl font-bold text-gray-900 mb-2">Set Your Hotkey & Test</h2>- <p className="text-gray-600">Choose your hotkey and try it out</p>+ <p className="text-gray-600">Choose your hotkey and activation style</p></div><HotkeyInput@@ -838,14 +841,33 @@ export default function OnboardingFlow({ onComplete }: OnboardingFlowProps) {disabled={isHotkeyRegistering}/>+ <div className="pt-2">+ <label className="block text-sm font-medium text-gray-700 mb-3">+ Activation Mode+ </label>+ <ActivationModeSelector value={activationMode} onChange={setActivationMode} />+ </div>+<div className="bg-blue-50/50 p-5 rounded-lg border border-blue-200/60"><h3 className="font-semibold text-blue-900 mb-3">Try It Now</h3><p className="text-sm text-blue-800 mb-3">- Click in the text area, press{" "}- <kbd className="bg-white px-2 py-1 rounded text-xs font-mono border border-blue-200">- {readableHotkey}- </kbd>{" "}- to start recording, speak, then press it again to stop.+ {activationMode === "tap" ? (+ <>+ Click in the text area, press{" "}+ <kbd className="bg-white px-2 py-1 rounded text-xs font-mono border border-blue-200">+ {readableHotkey}+ </kbd>{" "}+ to start recording, speak, then press it again to stop.+ </>+ ) : (+ <>+ Click in the text area, hold{" "}+ <kbd className="bg-white px-2 py-1 rounded text-xs font-mono border border-blue-200">+ {readableHotkey}+ </kbd>{" "}+ while speaking, then release to process.+ </>+ )}</p><div>diff --git a/src/components/SettingsPage.tsx b/src/components/SettingsPage.tsxindex 591457084..1bd10bc62 100644--- a/src/components/SettingsPage.tsx+++ b/src/components/SettingsPage.tsx@@ -21,6 +21,7 @@ import ReasoningModelSelector from "./ReasoningModelSelector";import type { UpdateInfoResult } from "../types/electron";import { HotkeyInput } from "./ui/HotkeyInput";import { useHotkeyRegistration } from "../hooks/useHotkeyRegistration";+import { ActivationModeSelector } from "./ui/ActivationModeSelector";export type SettingsSectionType =| "general"@@ -58,6 +59,8 @@ export default function SettingsPage({ activeSection = "general" }: SettingsPagegeminiApiKey,groqApiKey,dictationKey,+ activationMode,+ setActivationMode,preferBuiltInMic,selectedMicDeviceId,setPreferBuiltInMic,@@ -437,6 +440,13 @@ export default function SettingsPage({ activeSection = "general" }: SettingsPage}}disabled={isHotkeyRegistering}/>++ <div className="mt-6">+ <label className="block text-sm font-medium text-gray-700 mb-3">+ Activation Mode+ </label>+ <ActivationModeSelector value={activationMode} onChange={setActivationMode} />+ </div></div><div className="border-t pt-8">diff --git a/src/components/ui/ActivationModeSelector.tsx b/src/components/ui/ActivationModeSelector.tsxnew file mode 100644index 000000000..b711b4b1d--- /dev/null+++ b/src/components/ui/ActivationModeSelector.tsx@@ -0,0 +1,76 @@+import { MousePointerClick, MicVocal } from "lucide-react";++type ActivationMode = "tap" | "push";++interface ActivationModeSelectorProps {+ value: ActivationMode;+ onChange: (mode: ActivationMode) => void;+ disabled?: boolean;+}++export function ActivationModeSelector({+ value,+ onChange,+ disabled = false,+}: ActivationModeSelectorProps) {+ return (+ <div className="space-y-3">+ <div+ className={`+ relative flex rounded-xl border-2 p-1 transition-all duration-200+ ${disabled ? "bg-gray-50 border-gray-200 opacity-60" : "bg-gray-100/50 border-gray-200"}+ `}+ >+ <div+ className={`+ absolute top-1 bottom-1 w-[calc(50%-4px)] rounded-lg bg-white shadow-sm+ transition-transform duration-200 ease-out+ ${value === "push" ? "translate-x-[calc(100%+8px)]" : "translate-x-0"}+ `}+ />++ <button+ type="button"+ disabled={disabled}+ onClick={() => onChange("tap")}+ className={`+ relative z-10 flex-1 flex flex-col items-center gap-1 px-4 py-3 rounded-lg+ transition-colors duration-200+ ${disabled ? "cursor-not-allowed" : "cursor-pointer"}+ ${value === "tap" ? "text-gray-900" : "text-gray-500 hover:text-gray-700"}+ `}+ >+ <div className="flex items-center gap-2">+ <MousePointerClick className="w-5 h-5" />+ <span className="font-medium text-sm">Tap to Talk</span>+ </div>+ <span className="text-xs text-gray-400">Tap on, tap off</span>+ </button>++ <button+ type="button"+ disabled={disabled}+ onClick={() => onChange("push")}+ className={`+ relative z-10 flex-1 flex flex-col items-center gap-1 px-4 py-3 rounded-lg+ transition-colors duration-200+ ${disabled ? "cursor-not-allowed" : "cursor-pointer"}+ ${value === "push" ? "text-gray-900" : "text-gray-500 hover:text-gray-700"}+ `}+ >+ <div className="flex items-center gap-2">+ <MicVocal className="w-5 h-5" />+ <span className="font-medium text-sm">Push to Talk</span>+ </div>+ <span className="text-xs text-gray-400">Hold to record</span>+ </button>+ </div>++ <p className="text-xs text-gray-500 text-center">+ {value === "tap"+ ? "Press hotkey to start recording, press again to stop"+ : "Hold hotkey while speaking, release to process"}+ </p>+ </div>+ );+}diff --git a/src/helpers/windowManager.js b/src/helpers/windowManager.jsindex 15f9500a8..9e02d0574 100644--- a/src/helpers/windowManager.js+++ b/src/helpers/windowManager.js@@ -126,6 +126,41 @@ class WindowManager {};}+ sendStartDictation() {+ if (this.hotkeyManager.isInListeningMode()) {+ return;+ }+ if (this.mainWindow && !this.mainWindow.isDestroyed()) {+ if (!this.mainWindow.isVisible()) {+ this.mainWindow.show();+ }+ this.mainWindow.webContents.send("start-dictation");+ }+ }++ sendStopDictation() {+ if (this.hotkeyManager.isInListeningMode()) {+ return;+ }+ if (this.mainWindow && !this.mainWindow.isDestroyed()) {+ this.mainWindow.webContents.send("stop-dictation");+ }+ }++ async getActivationMode() {+ if (!this.mainWindow || this.mainWindow.isDestroyed()) {+ return "tap";+ }+ try {+ const mode = await this.mainWindow.webContents.executeJavaScript(+ `localStorage.getItem("activationMode") || "tap"`+ );+ return mode === "push" ? "push" : "tap";+ } catch {+ return "tap";+ }+ }+setHotkeyListeningMode(enabled) {this.hotkeyManager.setListeningMode(enabled);}diff --git a/src/hooks/useAudioRecording.js b/src/hooks/useAudioRecording.jsindex d0e470487..ce423092d 100644--- a/src/hooks/useAudioRecording.js+++ b/src/hooks/useAudioRecording.js@@ -42,7 +42,7 @@ export const useAudioRecording = (toast, options = {}) => {},});- // Set up hotkey listener+ // Set up hotkey listener for tap-to-talk modeconst handleToggle = () => {const currentState = audioManagerRef.current.getState();@@ -53,11 +53,37 @@ export const useAudioRecording = (toast, options = {}) => {}};+ // Set up listener for push-to-talk start+ const handleStart = () => {+ const currentState = audioManagerRef.current.getState();+ if (!currentState.isRecording && !currentState.isProcessing) {+ audioManagerRef.current.startRecording();+ }+ };++ // Set up listener for push-to-talk stop+ const handleStop = () => {+ const currentState = audioManagerRef.current.getState();+ if (currentState.isRecording) {+ audioManagerRef.current.stopRecording();+ }+ };+const disposeToggle = window.electronAPI.onToggleDictation(() => {handleToggle();onToggle?.();});+ const disposeStart = window.electronAPI.onStartDictation?.(() => {+ handleStart();+ onToggle?.();+ });++ const disposeStop = window.electronAPI.onStopDictation?.(() => {+ handleStop();+ onToggle?.();+ });+const handleNoAudioDetected = () => {toast({title: "No Audio Detected",@@ -71,6 +97,8 @@ export const useAudioRecording = (toast, options = {}) => {// Cleanupreturn () => {disposeToggle?.();+ disposeStart?.();+ disposeStop?.();disposeNoAudio?.();if (audioManagerRef.current) {audioManagerRef.current.cleanup();diff --git a/src/hooks/useSettings.ts b/src/hooks/useSettings.tsindex 2d56669e8..a0af1480a 100644--- a/src/hooks/useSettings.ts+++ b/src/hooks/useSettings.ts@@ -24,6 +24,7 @@ export interface ReasoningSettings {export interface HotkeySettings {dictationKey: string;+ activationMode: "tap" | "push";}export interface MicrophoneSettings {@@ -151,6 +152,15 @@ export function useSettings() {deserialize: String,});+ const [activationMode, setActivationMode] = useLocalStorage<"tap" | "push">(+ "activationMode",+ "tap",+ {+ serialize: String,+ deserialize: (value) => (value === "push" ? "push" : "tap"),+ }+ );+// Microphone settingsconst [preferBuiltInMic, setPreferBuiltInMic] = useLocalStorage("preferBuiltInMic", true, {serialize: String,@@ -261,6 +271,8 @@ export function useSettings() {setGeminiApiKey,setGroqApiKey,setDictationKey,+ activationMode,+ setActivationMode,preferBuiltInMic,selectedMicDeviceId,setPreferBuiltInMic,diff --git a/src/types/electron.ts b/src/types/electron.tsindex 4f91e1a0b..596b84b44 100644--- a/src/types/electron.ts+++ b/src/types/electron.ts@@ -100,6 +100,8 @@ declare global {hideWindow: () => Promise<void>;showDictationPanel: () => Promise<void>;onToggleDictation: (callback: () => void) => (() => void) | void;+ onStartDictation?: (callback: () => void) => (() => void) | void;+ onStopDictation?: (callback: () => void) => (() => void) | void;// Database operationssaveTranscription: (text: string) => Promise<{ id: number; success: boolean }>;