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
fix: add back cancel recording functionality
Gabriel Steinef0dec308ba3
diff --git a/src/App.jsx b/src/App.jsxindex 12f0f33e3..c8be8c7e4 100644--- a/src/App.jsx+++ b/src/App.jsx@@ -1,5 +1,6 @@import React, { useState, useEffect, useRef } from "react";import "./index.css";+import { X } from "lucide-react";import { useToast } from "./components/ui/Toast";import { LoadingDots } from "./components/ui/LoadingDots";import { useHotkey } from "./hooks/useHotkey";@@ -99,7 +100,7 @@ export default function App() {setWindowInteractivity(false);}, [setWindowInteractivity]);- const { isRecording, isProcessing, toggleListening } = useAudioRecording(toast, {+ const { isRecording, isProcessing, toggleListening, cancelRecording } = useAudioRecording(toast, {onToggle: handleDictationToggle,});@@ -205,6 +206,20 @@ export default function App() {}}}>+ {isRecording && isHovered && (+ <Tooltip content="Cancel recording">+ <button+ aria-label="Cancel recording"+ onClick={(e) => {+ e.stopPropagation();+ cancelRecording();+ }}+ className="w-7 h-7 rounded-full bg-neutral-800/90 hover:bg-red-500 border border-white/20 hover:border-red-400 flex items-center justify-center transition-all duration-150 shadow-lg backdrop-blur-sm"+ >+ <X size={12} strokeWidth={2.5} color="white" />+ </button>+ </Tooltip>+ )}<Tooltip content={micProps.tooltip}><buttonref={buttonRef}diff --git a/src/helpers/audioManager.js b/src/helpers/audioManager.jsindex fc8939392..74d27b4fb 100644--- a/src/helpers/audioManager.js+++ b/src/helpers/audioManager.js@@ -43,7 +43,7 @@ class AudioManager {async startRecording() {try {- if (this.isRecording) {+ if (this.isRecording || this.isProcessing || this.mediaRecorder?.state === "recording") {return false;}@@ -65,9 +65,6 @@ class AudioManager {const audioBlob = new Blob(this.audioChunks, { type: this.recordingMimeType });- if (audioBlob.size === 0) {- }-const durationSeconds = this.recordingStartTime? (Date.now() - this.recordingStartTime) / 1000: null;@@ -110,7 +107,7 @@ class AudioManager {}stopRecording() {- if (this.mediaRecorder && this.isRecording) {+ if (this.mediaRecorder?.state === "recording") {this.mediaRecorder.stop();// State change will be handled in onstop callbackreturn true;@@ -118,6 +115,27 @@ class AudioManager {return false;}+ cancelRecording() {+ if (this.mediaRecorder && this.mediaRecorder.state === "recording") {+ this.mediaRecorder.onstop = () => {+ this.isRecording = false;+ this.isProcessing = false;+ this.audioChunks = [];+ this.recordingStartTime = null;+ this.onStateChange?.({ isRecording: false, isProcessing: false });+ };++ this.mediaRecorder.stop();++ if (this.mediaRecorder.stream) {+ this.mediaRecorder.stream.getTracks().forEach((track) => track.stop());+ }++ return true;+ }+ return false;+ }+async processAudio(audioBlob, metadata = {}) {try {const useLocalWhisper = localStorage.getItem("useLocalWhisper") === "true";@@ -1048,7 +1066,7 @@ class AudioManager {}cleanup() {- if (this.mediaRecorder && this.isRecording) {+ if (this.mediaRecorder?.state === "recording") {this.stopRecording();}this.onStateChange = null;