Skip to content
Merged
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
25 changes: 17 additions & 8 deletions src/renderer/components/custom/control-panel/live-signal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,20 @@ export function LiveSignal() {

const [stream, setStream] = useState<MediaStream | null>(null);
const [connected, setConnected] = useState(true);
// Socket up but no audio reaching it - another app took the microphone or speakers (#164).
const [audioLost, setAudioLost] = useState(false);

useEffect(() => {
if (!running) {
setStream(null);
setConnected(true);
setAudioLost(false);
return;
}
const poll = () => {
setStream(liveTranscriptionService.getMicStream());
setConnected(liveTranscriptionService.isConnected());
setAudioLost(liveTranscriptionService.isCaptureStalled());
};
poll();
const id = window.setInterval(poll, POLL_MS);
Expand Down Expand Up @@ -71,10 +75,15 @@ export function LiveSignal() {

if (!running) return null;

const label = connected ? t.controlPanel.signal.listening : t.controlPanel.signal.reconnecting;
const hint = connected
? t.controlPanel.signal.listeningHint
: t.controlPanel.signal.reconnectingHint;
const signal = t.controlPanel.signal;
// A dropped socket is reported first: it is what any audio fix would be waiting on.
const healthy = connected && !audioLost;
const label = !connected ? signal.reconnecting : audioLost ? signal.audioLost : signal.listening;
const hint = !connected
? signal.reconnectingHint
: audioLost
? signal.audioLostHint
: signal.listeningHint;

return (
<Tooltip>
Expand All @@ -84,7 +93,7 @@ export function LiveSignal() {
aria-label={`${label}. ${hint}`}
className={cn(
'flex h-8 items-center gap-2 rounded-lg border px-2.5 text-xs font-medium',
connected
healthy
? 'border-border text-muted-foreground'
: 'border-destructive/40 bg-destructive/10 text-destructive'
)}
Expand All @@ -93,16 +102,16 @@ export function LiveSignal() {
aria-hidden="true"
className={cn(
'h-2 w-2 shrink-0 rounded-full',
connected ? 'bg-emerald-500' : 'animate-pulse bg-destructive'
healthy ? 'bg-emerald-500' : 'animate-pulse bg-destructive'
)}
/>
{/* The bar is full at the 840px minimum width, so "Listening" - the state nobody needs
to read - is dropped there and the dot and meter carry it, with the tooltip and the
aria-label holding the words. "Reconnecting" always shows: it is the one to notice. */}
<span className={cn('max-w-28 truncate', connected && 'hidden min-[1000px]:inline')}>
<span className={cn('max-w-28 truncate', healthy && 'hidden min-[1000px]:inline')}>
{label}
</span>
{connected && (
{healthy && (
<span aria-hidden="true" className="flex h-3.5 items-end gap-[2px]">
{Array.from({ length: BAR_COUNT }, (_, i) => (
<span
Expand Down
3 changes: 3 additions & 0 deletions src/renderer/i18n/locales/de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,9 @@ export const de: Translation = {
listeningHint: 'Mikrofon und Transkription sind verbunden',
reconnectingHint:
'Transkriptionsverbindung unterbrochen - wird automatisch wiederhergestellt',
audioLost: 'Audio verloren - wird wiederhergestellt…',
audioLostHint:
'Bei der Transkription kommt kein Audio an - wird automatisch wiederhergestellt. Eine andere App hat möglicherweise Mikrofon oder Lautsprecher übernommen.',
},
},

Expand Down
3 changes: 3 additions & 0 deletions src/renderer/i18n/locales/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,9 @@ export const en = {
reconnecting: 'Reconnecting…',
listeningHint: 'Microphone and transcription are connected',
reconnectingHint: 'Transcription connection dropped - reconnecting automatically',
audioLost: 'Audio lost - recovering…',
audioLostHint:
'No audio is reaching transcription - getting it back automatically. Another app may have taken the microphone or speakers.',
},
},

Expand Down
3 changes: 3 additions & 0 deletions src/renderer/i18n/locales/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,9 @@ export const es: Translation = {
reconnecting: 'Reconectando…',
listeningHint: 'El micrófono y la transcripción están conectados',
reconnectingHint: 'Se perdió la conexión de transcripción - reconectando automáticamente',
audioLost: 'Audio perdido - recuperando…',
audioLostHint:
'No llega audio a la transcripción - recuperándolo automáticamente. Puede que otra aplicación haya tomado el micrófono o los altavoces.',
},
},

Expand Down
3 changes: 3 additions & 0 deletions src/renderer/i18n/locales/fr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,9 @@ export const fr: Translation = {
reconnecting: 'Reconnexion…',
listeningHint: 'Le micro et la transcription sont connectés',
reconnectingHint: 'Connexion de transcription perdue - reconnexion automatique',
audioLost: 'Audio perdu - récupération…',
audioLostHint:
'Aucun son ne parvient à la transcription - récupération automatique. Une autre application a peut-être pris le micro ou les haut-parleurs.',
},
},

Expand Down
3 changes: 3 additions & 0 deletions src/renderer/i18n/locales/ja.ts
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,9 @@ export const ja: Translation = {
reconnecting: '再接続中…',
listeningHint: 'マイクと文字起こしは接続されています',
reconnectingHint: '文字起こしの接続が切れました - 自動で再接続しています',
audioLost: '音声が途切れました - 復旧中…',
audioLostHint:
'文字起こしに音声が届いていません - 自動で復旧しています。別のアプリがマイクまたはスピーカーを占有している可能性があります。',
},
},

Expand Down
3 changes: 3 additions & 0 deletions src/renderer/i18n/locales/ko.ts
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,9 @@ export const ko: Translation = {
reconnecting: '다시 연결 중…',
listeningHint: '마이크와 전사가 연결되어 있습니다',
reconnectingHint: '전사 연결이 끊어졌습니다 - 자동으로 다시 연결하는 중',
audioLost: '오디오 끊김 - 복구 중…',
audioLostHint:
'전사에 오디오가 들어오지 않습니다 - 자동으로 복구하는 중입니다. 다른 앱이 마이크나 스피커를 점유했을 수 있습니다.',
},
},

Expand Down
3 changes: 3 additions & 0 deletions src/renderer/i18n/locales/pt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,9 @@ export const pt: Translation = {
reconnecting: 'Reconectando…',
listeningHint: 'Microfone e transcrição conectados',
reconnectingHint: 'Conexão de transcrição perdida - reconectando automaticamente',
audioLost: 'Áudio perdido - recuperando…',
audioLostHint:
'Nenhum áudio está chegando à transcrição - recuperando automaticamente. Outro aplicativo pode ter assumido o microfone ou os alto-falantes.',
},
},

Expand Down
3 changes: 3 additions & 0 deletions src/renderer/i18n/locales/ru.ts
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,9 @@ export const ru: Translation = {
reconnecting: 'Переподключение…',
listeningHint: 'Микрофон и транскрипция подключены',
reconnectingHint: 'Соединение транскрипции прервано - переподключаемся автоматически',
audioLost: 'Звук потерян - восстанавливаем…',
audioLostHint:
'Звук не поступает в транскрипцию - восстанавливаем автоматически. Возможно, другое приложение заняло микрофон или динамики.',
},
},

Expand Down
2 changes: 2 additions & 0 deletions src/renderer/i18n/locales/zh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,8 @@ export const zh: Translation = {
reconnecting: '正在重新连接…',
listeningHint: '麦克风和转录已连接',
reconnectingHint: '转录连接已断开 - 正在自动重新连接',
audioLost: '音频中断 - 正在恢复…',
audioLostHint: '转录未收到音频 - 正在自动恢复。可能有其他应用占用了麦克风或扬声器。',
},
},

Expand Down
Loading