diff --git a/cptr/frontend/src/lib/components/Admin/AudioSettings.svelte b/cptr/frontend/src/lib/components/Admin/AudioSettings.svelte
index e25a847..7c05c4d 100644
--- a/cptr/frontend/src/lib/components/Admin/AudioSettings.svelte
+++ b/cptr/frontend/src/lib/components/Admin/AudioSettings.svelte
@@ -25,6 +25,7 @@
let ttsVoice = $state('alloy');
let ttsFormat = $state('mp3');
let ttsPlaybackSpeed = $state(1);
+ let ttsAutoStreamEnabled = $state(false);
let hasExistingTtsKey = $state(false);
let voiceModeSystemPrompt = $state('');
let voiceModeSttMode = $state<'browser' | 'provider'>('browser');
@@ -49,6 +50,7 @@
ttsFormat = (config['audio.tts_format'] as string) || 'mp3';
const speed = Number(config['audio.tts_playback_speed']);
ttsPlaybackSpeed = Number.isFinite(speed) ? Math.min(Math.max(speed, 0.5), 2) : 1;
+ ttsAutoStreamEnabled = config['audio.tts_auto_stream_enabled'] === true;
hasExistingTtsKey = !!config['audio.tts_api_key'];
voiceModeSystemPrompt = (config['audio.voice_mode_system_prompt'] as string) || '';
voiceModeSttMode =
@@ -72,6 +74,7 @@
'audio.tts_voice': ttsVoice,
'audio.tts_format': ttsFormat,
'audio.tts_playback_speed': ttsPlaybackSpeed,
+ 'audio.tts_auto_stream_enabled': ttsAutoStreamEnabled,
'audio.voice_mode_system_prompt': voiceModeSystemPrompt,
'audio.voice_mode_stt_mode': voiceModeSttMode
};
@@ -105,23 +108,41 @@
- {$t('admin.audio.voiceModeSttMode')}
+ {$t('admin.audio.voiceModeSttMode')}
- {voiceModeSttMode === 'browser' ? $t('admin.audio.voiceModeBrowserSttHint') : $t('admin.audio.voiceModeProviderSttHint')}
+ {voiceModeSttMode === 'browser'
+ ? $t('admin.audio.voiceModeBrowserSttHint')
+ : $t('admin.audio.voiceModeProviderSttHint')}
-
+
+ disabled={saving}>{$t('settings.save')}
{/if}
diff --git a/cptr/frontend/src/lib/components/chat/ChatPanel.svelte b/cptr/frontend/src/lib/components/chat/ChatPanel.svelte
index 92cbdf6..71e5f6a 100644
--- a/cptr/frontend/src/lib/components/chat/ChatPanel.svelte
+++ b/cptr/frontend/src/lib/components/chat/ChatPanel.svelte
@@ -38,6 +38,7 @@
ttsConfigured,
ttsFormat,
setTtsAudioPlaybackSource,
+ ttsAutoStreamEnabled,
ttsPlaybackEnabled,
ttsVoice,
unlockTtsAudioPlayback,
@@ -952,6 +953,10 @@
return $ttsEnabled && $ttsConfigured && ($ttsPlaybackEnabled || $voiceModeEnabled);
}
+ function shouldStreamTts() {
+ return $ttsEnabled && $ttsConfigured && ($voiceModeEnabled || $ttsAutoStreamEnabled);
+ }
+
function resetTtsBuffer() {
ttsBuffer = '';
ttsInsideCodeFence = false;
@@ -1023,7 +1028,7 @@
}
function handleTtsDelta(messageId: string, delta: string) {
- if (!shouldUseTts()) return;
+ if (!shouldStreamTts()) return;
if (!delta.trim()) return;
const active = allMessages.find((m) => m.id === messageId);
@@ -1043,7 +1048,7 @@
}
function flushTtsBuffer() {
- if (!shouldUseTts()) return;
+ if (!shouldStreamTts()) return;
const chunk = cleanSpeechText(ttsBuffer);
resetTtsBuffer();
if (chunk.length > 1) enqueueSpeech(chunk);
@@ -1242,6 +1247,7 @@
if (generation === ttsGeneration) ttsPlaying = false;
if (generation === ttsGeneration) speakingMessageId = null;
if (generation === ttsGeneration) ttsStopRequested = false;
+ if (generation === ttsGeneration && !$voiceModeEnabled) ttsPlaybackEnabled.set(false);
}
}
diff --git a/cptr/frontend/src/lib/i18n/locales/de.json b/cptr/frontend/src/lib/i18n/locales/de.json
index 814312e..b8b05e4 100644
--- a/cptr/frontend/src/lib/i18n/locales/de.json
+++ b/cptr/frontend/src/lib/i18n/locales/de.json
@@ -478,6 +478,8 @@
"admin.audio.tts": "Text-to-Speech",
"admin.audio.enableTts": "Text-to-Speech aktivieren",
"admin.audio.ttsEnabledHint": "Aktiviert den Sprachmodus und die Vorlesen-Schaltflächen, wenn ein TTS-Schlüssel verfügbar ist.",
+ "admin.audio.ttsAutoStream": "Stream-Antworten vorlesen",
+ "admin.audio.ttsAutoStreamHint": "Liest jede Assistentenantwort beim Streamen laut vor, auch außerhalb des Sprachmodus.",
"admin.audio.ttsKeyPlaceholder": "Leave blank to reuse STT key",
"admin.audio.ttsVoice": "Voice",
"admin.audio.ttsFormat": "Format",
diff --git a/cptr/frontend/src/lib/i18n/locales/en.json b/cptr/frontend/src/lib/i18n/locales/en.json
index bb9f2dd..9e60fe7 100644
--- a/cptr/frontend/src/lib/i18n/locales/en.json
+++ b/cptr/frontend/src/lib/i18n/locales/en.json
@@ -593,6 +593,8 @@
"admin.audio.tts": "Text-to-Speech",
"admin.audio.enableTts": "Enable Text-to-Speech",
"admin.audio.ttsEnabledHint": "Enables voice mode and assistant speak buttons when a TTS key is available.",
+ "admin.audio.ttsAutoStream": "Speak streamed responses",
+ "admin.audio.ttsAutoStreamHint": "Read every assistant response aloud as it streams, even outside voice mode.",
"admin.audio.ttsKeyPlaceholder": "Leave blank to reuse STT key",
"admin.audio.ttsVoice": "Voice",
"admin.audio.ttsFormat": "Format",
diff --git a/cptr/frontend/src/lib/i18n/locales/es.json b/cptr/frontend/src/lib/i18n/locales/es.json
index 3487841..f318917 100644
--- a/cptr/frontend/src/lib/i18n/locales/es.json
+++ b/cptr/frontend/src/lib/i18n/locales/es.json
@@ -478,6 +478,8 @@
"admin.audio.tts": "Text-to-Speech",
"admin.audio.enableTts": "Enable Text-to-Speech",
"admin.audio.ttsEnabledHint": "Enables voice mode and assistant speak buttons when a TTS key is available.",
+ "admin.audio.ttsAutoStream": "Speak streamed responses",
+ "admin.audio.ttsAutoStreamHint": "Read every assistant response aloud as it streams, even outside voice mode.",
"admin.audio.ttsKeyPlaceholder": "Leave blank to reuse STT key",
"admin.audio.ttsVoice": "Voice",
"admin.audio.ttsFormat": "Format",
diff --git a/cptr/frontend/src/lib/i18n/locales/fr.json b/cptr/frontend/src/lib/i18n/locales/fr.json
index bfb2bcc..86c7edb 100644
--- a/cptr/frontend/src/lib/i18n/locales/fr.json
+++ b/cptr/frontend/src/lib/i18n/locales/fr.json
@@ -477,6 +477,8 @@
"admin.audio.tts": "Text-to-Speech",
"admin.audio.enableTts": "Enable Text-to-Speech",
"admin.audio.ttsEnabledHint": "Enables voice mode and assistant speak buttons when a TTS key is available.",
+ "admin.audio.ttsAutoStream": "Speak streamed responses",
+ "admin.audio.ttsAutoStreamHint": "Read every assistant response aloud as it streams, even outside voice mode.",
"admin.audio.ttsKeyPlaceholder": "Leave blank to reuse STT key",
"admin.audio.ttsVoice": "Voice",
"admin.audio.ttsFormat": "Format",
diff --git a/cptr/frontend/src/lib/i18n/locales/ja.json b/cptr/frontend/src/lib/i18n/locales/ja.json
index e99ebe7..4e5fc6c 100644
--- a/cptr/frontend/src/lib/i18n/locales/ja.json
+++ b/cptr/frontend/src/lib/i18n/locales/ja.json
@@ -478,6 +478,8 @@
"admin.audio.tts": "Text-to-Speech",
"admin.audio.enableTts": "Enable Text-to-Speech",
"admin.audio.ttsEnabledHint": "Enables voice mode and assistant speak buttons when a TTS key is available.",
+ "admin.audio.ttsAutoStream": "Speak streamed responses",
+ "admin.audio.ttsAutoStreamHint": "Read every assistant response aloud as it streams, even outside voice mode.",
"admin.audio.ttsKeyPlaceholder": "Leave blank to reuse STT key",
"admin.audio.ttsVoice": "Voice",
"admin.audio.ttsFormat": "Format",
diff --git a/cptr/frontend/src/lib/i18n/locales/ko.json b/cptr/frontend/src/lib/i18n/locales/ko.json
index e4be28c..f159f42 100644
--- a/cptr/frontend/src/lib/i18n/locales/ko.json
+++ b/cptr/frontend/src/lib/i18n/locales/ko.json
@@ -478,6 +478,8 @@
"admin.audio.tts": "Text-to-Speech",
"admin.audio.enableTts": "Enable Text-to-Speech",
"admin.audio.ttsEnabledHint": "Enables voice mode and assistant speak buttons when a TTS key is available.",
+ "admin.audio.ttsAutoStream": "Speak streamed responses",
+ "admin.audio.ttsAutoStreamHint": "Read every assistant response aloud as it streams, even outside voice mode.",
"admin.audio.ttsKeyPlaceholder": "Leave blank to reuse STT key",
"admin.audio.ttsVoice": "Voice",
"admin.audio.ttsFormat": "Format",
diff --git a/cptr/frontend/src/lib/i18n/locales/pt-BR.json b/cptr/frontend/src/lib/i18n/locales/pt-BR.json
index 84435e7..b797ae4 100644
--- a/cptr/frontend/src/lib/i18n/locales/pt-BR.json
+++ b/cptr/frontend/src/lib/i18n/locales/pt-BR.json
@@ -478,6 +478,8 @@
"admin.audio.tts": "Text-to-Speech",
"admin.audio.enableTts": "Enable Text-to-Speech",
"admin.audio.ttsEnabledHint": "Enables voice mode and assistant speak buttons when a TTS key is available.",
+ "admin.audio.ttsAutoStream": "Speak streamed responses",
+ "admin.audio.ttsAutoStreamHint": "Read every assistant response aloud as it streams, even outside voice mode.",
"admin.audio.ttsKeyPlaceholder": "Leave blank to reuse STT key",
"admin.audio.ttsVoice": "Voice",
"admin.audio.ttsFormat": "Format",
diff --git a/cptr/frontend/src/lib/i18n/locales/ru.json b/cptr/frontend/src/lib/i18n/locales/ru.json
index 7ba5e1f..e887831 100644
--- a/cptr/frontend/src/lib/i18n/locales/ru.json
+++ b/cptr/frontend/src/lib/i18n/locales/ru.json
@@ -478,6 +478,8 @@
"admin.audio.tts": "Text-to-Speech",
"admin.audio.enableTts": "Enable Text-to-Speech",
"admin.audio.ttsEnabledHint": "Enables voice mode and assistant speak buttons when a TTS key is available.",
+ "admin.audio.ttsAutoStream": "Speak streamed responses",
+ "admin.audio.ttsAutoStreamHint": "Read every assistant response aloud as it streams, even outside voice mode.",
"admin.audio.ttsKeyPlaceholder": "Leave blank to reuse STT key",
"admin.audio.ttsVoice": "Voice",
"admin.audio.ttsFormat": "Format",
diff --git a/cptr/frontend/src/lib/i18n/locales/zh-CN.json b/cptr/frontend/src/lib/i18n/locales/zh-CN.json
index 244b332..75a8636 100644
--- a/cptr/frontend/src/lib/i18n/locales/zh-CN.json
+++ b/cptr/frontend/src/lib/i18n/locales/zh-CN.json
@@ -478,6 +478,8 @@
"admin.audio.tts": "Text-to-Speech",
"admin.audio.enableTts": "Enable Text-to-Speech",
"admin.audio.ttsEnabledHint": "Enables voice mode and assistant speak buttons when a TTS key is available.",
+ "admin.audio.ttsAutoStream": "Speak streamed responses",
+ "admin.audio.ttsAutoStreamHint": "Read every assistant response aloud as it streams, even outside voice mode.",
"admin.audio.ttsKeyPlaceholder": "Leave blank to reuse STT key",
"admin.audio.ttsVoice": "Voice",
"admin.audio.ttsFormat": "Format",
diff --git a/cptr/frontend/src/lib/i18n/locales/zh-TW.json b/cptr/frontend/src/lib/i18n/locales/zh-TW.json
index ec001b1..cdceede 100644
--- a/cptr/frontend/src/lib/i18n/locales/zh-TW.json
+++ b/cptr/frontend/src/lib/i18n/locales/zh-TW.json
@@ -478,6 +478,8 @@
"admin.audio.tts": "Text-to-Speech",
"admin.audio.enableTts": "Enable Text-to-Speech",
"admin.audio.ttsEnabledHint": "Enables voice mode and assistant speak buttons when a TTS key is available.",
+ "admin.audio.ttsAutoStream": "Speak streamed responses",
+ "admin.audio.ttsAutoStreamHint": "Read every assistant response aloud as it streams, even outside voice mode.",
"admin.audio.ttsKeyPlaceholder": "Leave blank to reuse STT key",
"admin.audio.ttsVoice": "Voice",
"admin.audio.ttsFormat": "Format",
diff --git a/cptr/frontend/src/lib/stores/audio.ts b/cptr/frontend/src/lib/stores/audio.ts
index 67e15f0..6840acd 100644
--- a/cptr/frontend/src/lib/stores/audio.ts
+++ b/cptr/frontend/src/lib/stores/audio.ts
@@ -22,10 +22,13 @@ export const ttsConfigured = writable
(false);
export const ttsVoice = writable('alloy');
export const ttsFormat = writable('mp3');
export const ttsPlaybackSpeed = writable(1);
+export const ttsAutoStreamEnabled = writable(false);
export const voiceModeEnabled = writable(false);
export const voiceModeSttMode = writable<'browser' | 'provider'>('browser');
export const ttsPlaybackEnabled = writable(
- typeof localStorage !== 'undefined' ? localStorage.getItem('ttsPlaybackEnabled') === 'true' : false
+ typeof localStorage !== 'undefined'
+ ? localStorage.getItem('ttsPlaybackEnabled') === 'true'
+ : false
);
const SILENT_WAV =
@@ -74,7 +77,8 @@ export async function unlockTtsAudioPlayback() {
const unlocks: Promise[] = [];
const AudioContextCtor =
- window.AudioContext || (window as Window & { webkitAudioContext?: typeof AudioContext }).webkitAudioContext;
+ window.AudioContext ||
+ (window as Window & { webkitAudioContext?: typeof AudioContext }).webkitAudioContext;
try {
if (AudioContextCtor) {
ttsAudioContext ??= new AudioContextCtor();
@@ -128,6 +132,7 @@ export async function refreshAudioState() {
tts_voice: string;
tts_format: string;
tts_playback_speed?: number;
+ tts_auto_stream_enabled?: boolean;
voice_mode_stt_mode?: string;
}>('/api/audio/state');
voiceMemosEnabled.set(data.voice_memos_enabled === true);
@@ -142,6 +147,7 @@ export async function refreshAudioState() {
ttsFormat.set(data.tts_format || 'mp3');
const speed = Number(data.tts_playback_speed);
ttsPlaybackSpeed.set(Number.isFinite(speed) ? Math.min(Math.max(speed, 0.5), 2) : 1);
+ ttsAutoStreamEnabled.set(data.tts_auto_stream_enabled === true);
voiceModeSttMode.set(data.voice_mode_stt_mode === 'provider' ? 'provider' : 'browser');
} catch {
voiceMemosEnabled.set(false);
@@ -149,6 +155,7 @@ export async function refreshAudioState() {
ttsEnabled.set(false);
ttsConfigured.set(false);
ttsPlaybackSpeed.set(1);
+ ttsAutoStreamEnabled.set(false);
voiceModeSttMode.set('browser');
}
}
diff --git a/cptr/routers/audio.py b/cptr/routers/audio.py
index 7dfc605..e0ba52a 100644
--- a/cptr/routers/audio.py
+++ b/cptr/routers/audio.py
@@ -55,6 +55,7 @@ class AudioStateResponse(BaseModel):
tts_voice: str
tts_format: str
tts_playback_speed: float
+ tts_auto_stream_enabled: bool
voice_mode_stt_mode: str
@@ -218,6 +219,7 @@ async def audio_state(request: Request):
tts_voice=str((await Config.get("audio.tts_voice")) or "alloy"),
tts_format=str((await Config.get("audio.tts_format")) or "mp3"),
tts_playback_speed=playback_speed,
+ tts_auto_stream_enabled=await Config.get("audio.tts_auto_stream_enabled") is True,
voice_mode_stt_mode=str((await Config.get("audio.voice_mode_stt_mode")) or "browser"),
)