Skip to content

armgit / mimik

Public Imported from GitHub
0

🎬 A browser extension and desktop app that turns your clicks into step-by-step guides with annotated screenshots 📖

fix(voice): disable the mic toggle until a transcription key resolves

Luis Ortiz428f7adde737
diff --git a/src/locales/en.yml b/src/locales/en.yml
index 19f4c08..397d530 100644
--- a/src/locales/en.yml
+++ b/src/locales/en.yml
@@ -85,6 +85,8 @@ settings:
aiLanguage: Description Language
voiceNarration: Voice Narration
voiceDescription: Narrate out loud while you record and your words become the step descriptions.
+ voiceUsingAiKey: "No voice key is set, so Mimik uses the OpenAI key from AI Descriptions above."
+ voiceNoKey: "Voice narration is on but no API key is set, so your recordings will not be narrated."
voiceDataNotice: Your recorded audio is sent to the provider you choose above, using your own API key. This is the one part of Mimik that sends anything out of your browser.
microphone: Microphone
microphoneDefault: System default
@@ -258,6 +260,7 @@ background:
voice:
turnOn: Turn on voice narration
turnOff: Turn off voice narration
+ needsApiKey: Add a transcription API key in Settings to narrate
micStarting: Starting microphone...
micHearing: Hearing you
micQuiet: No sound
diff --git a/src/locales/es.yml b/src/locales/es.yml
index 6e5aa63..9f76c18 100644
--- a/src/locales/es.yml
+++ b/src/locales/es.yml
@@ -85,6 +85,8 @@ settings:
aiLanguage: Idioma de descripciones
voiceNarration: "Narración por voz"
voiceDescription: "Narra en voz alta mientras grabas y tus palabras se convierten en las descripciones de los pasos."
+ voiceUsingAiKey: "No hay clave de voz, así que Mimik usa la clave de OpenAI de Descripciones con IA de arriba."
+ voiceNoKey: "La narración por voz está activada pero no hay ninguna clave API, así que tus grabaciones no se narrarán."
voiceDataNotice: "El audio que grabes se envía al proveedor que elijas arriba, usando tu propia clave API. Es la única parte de Mimik que saca algo de tu navegador."
microphone: "Micrófono"
microphoneDefault: Predeterminado del sistema
@@ -258,6 +260,7 @@ background:
voice:
turnOn: "Activar narración por voz"
turnOff: "Desactivar narración por voz"
+ needsApiKey: "Añade una clave API de transcripción en Ajustes para narrar"
micStarting: "Iniciando el micrófono..."
micHearing: Te estamos oyendo
micQuiet: Sin sonido
diff --git a/src/locales/fr.yml b/src/locales/fr.yml
index 69e79df..08ecc64 100644
--- a/src/locales/fr.yml
+++ b/src/locales/fr.yml
@@ -85,6 +85,8 @@ settings:
aiLanguage: Langue des descriptions
voiceNarration: "Narration vocale"
voiceDescription: "Commentez à voix haute pendant l'enregistrement : vos mots deviennent les descriptions des étapes."
+ voiceUsingAiKey: "Aucune clé vocale n'est définie : Mimik utilise la clé OpenAI des descriptions IA ci-dessus."
+ voiceNoKey: "La narration vocale est activée mais aucune clé API n'est définie : vos enregistrements ne seront pas narrés."
voiceDataNotice: "L'audio enregistré est envoyé au fournisseur choisi ci-dessus, avec votre propre clé API. C'est la seule partie de Mimik qui fait sortir quelque chose de votre navigateur."
microphone: Microphone
microphoneDefault: "Micro par défaut du système"
@@ -258,6 +260,7 @@ background:
voice:
turnOn: "Activer la narration vocale"
turnOff: "Désactiver la narration vocale"
+ needsApiKey: "Ajoutez une clé API de transcription dans les paramètres pour commenter"
micStarting: "Démarrage du micro..."
micHearing: Nous vous entendons
micQuiet: Aucun son
diff --git a/src/locales/pt-BR.yml b/src/locales/pt-BR.yml
index 837a943..cbd3fd5 100644
--- a/src/locales/pt-BR.yml
+++ b/src/locales/pt-BR.yml
@@ -85,6 +85,8 @@ settings:
aiLanguage: "Idioma das descrições"
voiceNarration: "Narração por voz"
voiceDescription: "Narre em voz alta enquanto grava e suas palavras viram as descrições dos passos."
+ voiceUsingAiKey: "Não tem chave de voz, então o Mimik usa a chave da OpenAI das Descrições com IA lá de cima."
+ voiceNoKey: "A narração por voz tá ligada, mas não tem nenhuma chave API, então suas gravações não vão ser narradas."
voiceDataNotice: "O áudio gravado é enviado pro provedor que você escolher acima, usando sua própria chave API. É a única parte do Mimik que manda algo pra fora do seu navegador."
microphone: Microfone
microphoneDefault: "Padrão do sistema"
@@ -258,6 +260,7 @@ background:
voice:
turnOn: "Ligar narração por voz"
turnOff: "Desligar narração por voz"
+ needsApiKey: "Adicione uma chave API de transcrição nos Ajustes pra narrar"
micStarting: "Ligando o microfone..."
micHearing: "Tô te ouvindo"
micQuiet: Sem som
diff --git a/src/ui/shared/SettingsView.tsx b/src/ui/shared/SettingsView.tsx
index 787ed5a..f17f3a2 100644
--- a/src/ui/shared/SettingsView.tsx
+++ b/src/ui/shared/SettingsView.tsx
@@ -1,9 +1,22 @@
-import { ArrowLeft, Bug, Check, ChevronRight, EyeOff, Globe, Mic, Shield, Sparkles, Star } from 'lucide-react';
+import {
+ ArrowLeft,
+ Bug,
+ Check,
+ ChevronRight,
+ EyeOff,
+ Globe,
+ Mic,
+ Shield,
+ Sparkles,
+ Star,
+ TriangleAlert,
+} from 'lucide-react';
import { useEffect, useState } from 'react';
import { i18n } from '#imports';
import { PRESET_LABELS, type PresetKey } from '@/core/blur/regexes';
import { AI_PROVIDERS, type AIProviderKey } from '@/core/capture/ai/models';
import { AI_LANGUAGES, type AILanguageCode } from '@/core/capture/ai/prompts';
+import { resolveVoiceApiKey } from '@/core/capture/voice/api-key';
import type { VoiceProvider } from '@/core/capture/voice/transcribe';
import { localStorage } from '@/lib/browser-api';
import { Button } from '@/ui/components/ui/button';
@@ -82,6 +95,7 @@ export default function SettingsView({ onBack }: SettingsViewProps) {
};
const providerConfig = AI_PROVIDERS[provider];
+ const voiceKey = resolveVoiceApiKey({ voiceProvider, voiceApiKey, aiProvider: provider, aiApiKey: apiKey });
const BLUR_PRESET_I18N: Record<PresetKey, string> = {
email: 'blurPresets.email',
@@ -217,6 +231,18 @@ export default function SettingsView({ onBack }: SettingsViewProps) {
onChange={(e) => setVoiceApiKey(e.target.value)}
placeholder={voiceProvider === 'groq' ? 'gsk_...' : 'sk-...'}
/>
+ {voiceKey.source === 'ai' && (
+ <p className="mt-1.5 flex items-start gap-1.5 text-[10px] text-muted-foreground leading-relaxed">
+ <Sparkles size={11} className="shrink-0 mt-0.5 text-accent" />
+ <span>{i18n.t('settings.voiceUsingAiKey')}</span>
+ </p>
+ )}
+ {voiceEnabled && voiceKey.source === 'none' && (
+ <p className="mt-1.5 flex items-start gap-1.5 text-[10px] text-destructive leading-relaxed" role="alert">
+ <TriangleAlert size={11} className="shrink-0 mt-0.5" />
+ <span>{i18n.t('settings.voiceNoKey')}</span>
+ </p>
+ )}
</div>
{import.meta.env.BROWSER !== 'firefox' && (
diff --git a/src/ui/sidepanel/MicToggle.tsx b/src/ui/sidepanel/MicToggle.tsx
index 689bdb0..588b46a 100644
--- a/src/ui/sidepanel/MicToggle.tsx
+++ b/src/ui/sidepanel/MicToggle.tsx
@@ -1,6 +1,7 @@
import { Mic, MicOff } from 'lucide-react';
-import { useCallback } from 'react';
-import { i18n } from '#imports';
+import { useCallback, useEffect, useState } from 'react';
+import { browser, i18n } from '#imports';
+import { hasVoiceApiKey, VOICE_KEY_SETTINGS } from '@/core/capture/voice/api-key';
import { getActiveTab, localStorage } from '@/lib/browser-api';
import { abortVoiceCapture, openMicPermissionPage } from '@/lib/offscreen';
@@ -22,7 +23,32 @@ async function microphoneGranted(): Promise<boolean> {
}
export default function MicToggle({ enabled, live, onChange }: MicToggleProps) {
+ const [keyed, setKeyed] = useState(false);
+
+ useEffect(() => {
+ let active = true;
+ const read = () =>
+ localStorage.get([...VOICE_KEY_SETTINGS]).then((stored) => {
+ if (active) setKeyed(hasVoiceApiKey(stored));
+ });
+
+ void read();
+
+ const handler = (changes: Record<string, unknown>) => {
+ if (VOICE_KEY_SETTINGS.some((key) => key in changes)) void read();
+ };
+
+ browser.storage.local.onChanged.addListener(handler);
+ return () => {
+ active = false;
+ browser.storage.local.onChanged.removeListener(handler);
+ };
+ }, []);
+
+ const locked = !keyed && !enabled;
+
const toggle = useCallback(async () => {
+ if (locked) return;
const next = !enabled;
onChange(next);
await localStorage.set({ voiceEnabled: next });
@@ -35,20 +61,25 @@ export default function MicToggle({ enabled, live, onChange }: MicToggleProps) {
if (await microphoneGranted()) return;
const tab = await getActiveTab();
await openMicPermissionPage(tab?.id).catch(() => undefined);
- }, [enabled, live, onChange]);
+ }, [enabled, live, locked, onChange]);
const Icon = enabled ? Mic : MicOff;
+ const label = locked ? i18n.t('voice.needsApiKey') : i18n.t(enabled ? 'voice.turnOff' : 'voice.turnOn');
return (
<button
onClick={() => void toggle()}
aria-pressed={enabled}
+ aria-disabled={locked}
+ aria-label={label}
className={`w-10 h-10 rounded-full border flex items-center justify-center transition-colors ${
- enabled
- ? 'border-accent bg-secondary text-accent'
- : 'border-border text-muted-foreground hover:border-accent hover:text-accent'
+ locked
+ ? 'border-dashed border-border text-muted-foreground opacity-60 cursor-not-allowed'
+ : enabled
+ ? 'border-accent bg-secondary text-accent'
+ : 'border-border text-muted-foreground hover:border-accent hover:text-accent'
}`}
- title={i18n.t(enabled ? 'voice.turnOff' : 'voice.turnOn')}
+ title={label}
>
<Icon size={16} />
</button>