This commit is contained in:
Timothy Jaeryang Baek
2026-06-18 16:16:44 +02:00
Unverified
parent 06cbe36130
commit ca91fe5efd
@@ -97,280 +97,286 @@
}
</script>
<div class="flex flex-col min-h-full">
<h2 class="text-sm font-medium text-gray-900 dark:text-white mb-4">{$t('admin.audio.title')}</h2>
<div class="flex flex-col h-full">
{#if loading}
<div class="flex justify-center py-8"><Spinner size={16} /></div>
{:else}
<!-- Voice Notes -->
<h3 class="text-xs text-gray-400 dark:text-gray-600 mb-2">{$t('admin.audio.voiceMemos')}</h3>
<div class="flex-1 min-h-0 overflow-y-auto">
<h2 class="text-sm font-medium text-gray-900 dark:text-white mb-4">
{$t('admin.audio.title')}
</h2>
<div class="flex flex-col gap-2.5">
<label class="flex items-center justify-between cursor-pointer">
<span class="text-xs text-gray-600 dark:text-gray-400"
>{$t('admin.audio.enableVoiceMemos')}</span
>
<ToggleSwitch
value={voiceMemosEnabled}
onchange={(v) => {
voiceMemosEnabled = v;
}}
/>
</label>
<p class="text-[11px] text-gray-400 dark:text-gray-600 -mt-1">
{$t('admin.audio.voiceMemosHint')}
</p>
<!-- Voice Notes -->
<h3 class="text-xs text-gray-400 dark:text-gray-600 mb-2">{$t('admin.audio.voiceMemos')}</h3>
<label class="flex items-center justify-between cursor-pointer">
<span class="text-xs text-gray-600 dark:text-gray-400"
>{$t('admin.audio.autoTranscribe')}</span
>
<ToggleSwitch
value={transcribeEnabled}
onchange={(v) => {
transcribeEnabled = v;
}}
/>
</label>
<p class="text-[11px] text-gray-400 dark:text-gray-600 -mt-1">
{transcribeEnabled
? $t('admin.audio.transcribeOnHint')
: $t('admin.audio.transcribeOffHint')}
</p>
<div class="flex items-center justify-between">
<span class="text-xs text-gray-600 dark:text-gray-400"
>{$t('admin.audio.recordingQuality')}</span
>
<select
bind:value={quality}
class="bg-transparent text-xs text-gray-600 dark:text-gray-400 outline-none cursor-pointer"
>
<option value="high">{$t('admin.audio.qualityHigh')}</option>
<option value="medium">{$t('admin.audio.qualityMedium')}</option>
<option value="low">{$t('admin.audio.qualityLow')}</option>
</select>
</div>
<p class="text-[11px] text-gray-400 dark:text-gray-600 -mt-1">
{quality === 'high'
? $t('admin.audio.qualityHintHigh')
: quality === 'medium'
? $t('admin.audio.qualityHintMedium')
: $t('admin.audio.qualityHintLow')}
</p>
</div>
<!-- Speech-to-Text -->
<h3 class="text-xs text-gray-400 dark:text-gray-600 mb-2 mt-5">{$t('admin.audio.stt')}</h3>
<div class="flex flex-col gap-2.5">
<div>
<label class="text-xs text-gray-600 dark:text-gray-400" for="stt-base-url"
>{$t('connections.baseUrl')}</label
>
<input
id="stt-base-url"
type="text"
bind:value={sttBaseUrl}
placeholder="https://api.openai.com/v1"
class="w-full mt-1 h-7 px-2 rounded-lg text-xs bg-gray-100 dark:bg-white/6 text-gray-700 dark:text-gray-300 border border-gray-200 dark:border-white/8 outline-none focus:border-blue-400 dark:focus:border-blue-500 transition-colors"
/>
</div>
<div>
<label class="text-xs text-gray-600 dark:text-gray-400" for="stt-api-key"
>{$t('connections.apiKey')}</label
>
<input
id="stt-api-key"
type="password"
bind:value={sttApiKey}
placeholder={hasExistingKey ? '••••••••' : 'sk-...'}
class="w-full mt-1 h-7 px-2 rounded-lg text-xs bg-gray-100 dark:bg-white/6 text-gray-700 dark:text-gray-300 border border-gray-200 dark:border-white/8 outline-none focus:border-blue-400 dark:focus:border-blue-500 transition-colors"
/>
</div>
<div>
<label class="text-xs text-gray-600 dark:text-gray-400" for="stt-model"
>{$t('automations.model')}</label
>
<input
id="stt-model"
type="text"
bind:value={sttModel}
placeholder="whisper-1"
class="w-full mt-1 h-7 px-2 rounded-lg text-xs bg-gray-100 dark:bg-white/6 text-gray-700 dark:text-gray-300 border border-gray-200 dark:border-white/8 outline-none focus:border-blue-400 dark:focus:border-blue-500 transition-colors"
/>
</div>
<p class="text-[11px] text-gray-400 dark:text-gray-600">
{$t('admin.audio.sttHint')}
</p>
</div>
<!-- Text-to-Speech -->
<h3 class="text-xs text-gray-400 dark:text-gray-600 mb-2 mt-5">{$t('admin.audio.tts')}</h3>
<div class="flex flex-col gap-2.5">
<label class="flex items-center justify-between cursor-pointer">
<span class="text-xs text-gray-600 dark:text-gray-400">{$t('admin.audio.enableTts')}</span>
<ToggleSwitch
value={ttsEnabled}
onchange={(v) => {
ttsEnabled = v;
}}
/>
</label>
<p class="text-[11px] text-gray-400 dark:text-gray-600 -mt-1">
{$t('admin.audio.ttsEnabledHint')}
</p>
<label class="flex items-center justify-between cursor-pointer">
<span class="text-xs text-gray-600 dark:text-gray-400"
>{$t('admin.audio.ttsAutoStream')}</span
>
<ToggleSwitch
value={ttsAutoStreamEnabled}
onchange={(v) => {
ttsAutoStreamEnabled = v;
}}
/>
</label>
<p class="text-[11px] text-gray-400 dark:text-gray-600 -mt-1">
{$t('admin.audio.ttsAutoStreamHint')}
</p>
<div>
<label class="text-xs text-gray-600 dark:text-gray-400" for="tts-base-url"
>{$t('connections.baseUrl')}</label
>
<input
id="tts-base-url"
type="text"
bind:value={ttsBaseUrl}
placeholder="https://api.openai.com/v1"
class="w-full mt-1 h-7 px-2 rounded-lg text-xs bg-gray-100 dark:bg-white/6 text-gray-700 dark:text-gray-300 border border-gray-200 dark:border-white/8 outline-none focus:border-blue-400 dark:focus:border-blue-500 transition-colors"
/>
</div>
<div>
<label class="text-xs text-gray-600 dark:text-gray-400" for="tts-api-key"
>{$t('connections.apiKey')}</label
>
<input
id="tts-api-key"
type="password"
bind:value={ttsApiKey}
placeholder={hasExistingTtsKey ? '••••••••' : $t('admin.audio.ttsKeyPlaceholder')}
class="w-full mt-1 h-7 px-2 rounded-lg text-xs bg-gray-100 dark:bg-white/6 text-gray-700 dark:text-gray-300 border border-gray-200 dark:border-white/8 outline-none focus:border-blue-400 dark:focus:border-blue-500 transition-colors"
/>
</div>
<div>
<label class="text-xs text-gray-600 dark:text-gray-400" for="tts-model"
>{$t('automations.model')}</label
>
<input
id="tts-model"
type="text"
bind:value={ttsModel}
placeholder="tts-1"
class="w-full mt-1 h-7 px-2 rounded-lg text-xs bg-gray-100 dark:bg-white/6 text-gray-700 dark:text-gray-300 border border-gray-200 dark:border-white/8 outline-none focus:border-blue-400 dark:focus:border-blue-500 transition-colors"
/>
</div>
<div>
<label class="text-xs text-gray-600 dark:text-gray-400" for="tts-voice"
>{$t('admin.audio.ttsVoice')}</label
>
<input
id="tts-voice"
type="text"
bind:value={ttsVoice}
placeholder="alloy"
class="w-full mt-1 h-7 px-2 rounded-lg text-xs bg-gray-100 dark:bg-white/6 text-gray-700 dark:text-gray-300 border border-gray-200 dark:border-white/8 outline-none focus:border-blue-400 dark:focus:border-blue-500 transition-colors"
/>
</div>
<div class="flex items-center justify-between">
<span class="text-xs text-gray-600 dark:text-gray-400">{$t('admin.audio.ttsFormat')}</span>
<select
bind:value={ttsFormat}
class="bg-transparent text-xs text-gray-600 dark:text-gray-400 outline-none cursor-pointer"
>
<option value="mp3">MP3</option>
<option value="opus">Opus</option>
<option value="aac">AAC</option>
<option value="flac">FLAC</option>
<option value="wav">WAV</option>
<option value="pcm">PCM</option>
</select>
</div>
<div class="flex items-center justify-between gap-3">
<label class="text-xs text-gray-600 dark:text-gray-400" for="tts-playback-speed">
{$t('admin.audio.ttsPlaybackSpeed')}
</label>
<div class="flex items-center gap-2">
<input
id="tts-playback-speed"
type="range"
min="0.5"
max="2"
step="0.05"
bind:value={ttsPlaybackSpeed}
class="w-28 accent-gray-700 dark:accent-gray-300"
/>
<span class="w-9 text-right text-xs text-gray-500 dark:text-gray-400"
>{ttsPlaybackSpeed.toFixed(2)}x</span
<div class="flex flex-col gap-2.5">
<label class="flex items-center justify-between cursor-pointer">
<span class="text-xs text-gray-600 dark:text-gray-400"
>{$t('admin.audio.enableVoiceMemos')}</span
>
</div>
</div>
<p class="text-[11px] text-gray-400 dark:text-gray-600">
{$t('admin.audio.ttsHint')}
</p>
</div>
<!-- Voice Mode -->
<h3 class="text-xs text-gray-400 dark:text-gray-600 mb-2 mt-5">
{$t('admin.audio.voiceMode')}
</h3>
<div class="flex flex-col gap-2.5">
<div class="flex items-center justify-between">
<span class="text-xs text-gray-600 dark:text-gray-400"
>{$t('admin.audio.voiceModeSttMode')}</span
>
<select
bind:value={voiceModeSttMode}
class="bg-transparent text-xs text-gray-600 dark:text-gray-400 outline-none cursor-pointer"
>
<option value="browser">{$t('admin.audio.voiceModeSttBrowser')}</option>
<option value="provider">{$t('admin.audio.voiceModeSttProvider')}</option>
</select>
</div>
<p class="text-[11px] text-gray-400 dark:text-gray-600 -mt-1">
{voiceModeSttMode === 'browser'
? $t('admin.audio.voiceModeBrowserSttHint')
: $t('admin.audio.voiceModeProviderSttHint')}
</p>
<div>
<label class="text-xs text-gray-600 dark:text-gray-400" for="voice-mode-system-prompt">
{$t('admin.audio.voiceModeSystemPrompt')}
<ToggleSwitch
value={voiceMemosEnabled}
onchange={(v) => {
voiceMemosEnabled = v;
}}
/>
</label>
<textarea
id="voice-mode-system-prompt"
bind:value={voiceModeSystemPrompt}
rows="5"
placeholder={VOICE_MODE_SYSTEM_PROMPT_PLACEHOLDER}
class="w-full mt-1 px-2 py-1.5 rounded-lg text-xs bg-gray-100 dark:bg-white/6 text-gray-700 dark:text-gray-300 border border-gray-200 dark:border-white/8 outline-none focus:border-blue-400 dark:focus:border-blue-500 transition-colors resize-y min-h-24"
></textarea>
<p class="text-[11px] text-gray-400 dark:text-gray-600 -mt-1">
{$t('admin.audio.voiceMemosHint')}
</p>
<label class="flex items-center justify-between cursor-pointer">
<span class="text-xs text-gray-600 dark:text-gray-400"
>{$t('admin.audio.autoTranscribe')}</span
>
<ToggleSwitch
value={transcribeEnabled}
onchange={(v) => {
transcribeEnabled = v;
}}
/>
</label>
<p class="text-[11px] text-gray-400 dark:text-gray-600 -mt-1">
{transcribeEnabled
? $t('admin.audio.transcribeOnHint')
: $t('admin.audio.transcribeOffHint')}
</p>
<div class="flex items-center justify-between">
<span class="text-xs text-gray-600 dark:text-gray-400"
>{$t('admin.audio.recordingQuality')}</span
>
<select
bind:value={quality}
class="bg-transparent text-xs text-gray-600 dark:text-gray-400 outline-none cursor-pointer"
>
<option value="high">{$t('admin.audio.qualityHigh')}</option>
<option value="medium">{$t('admin.audio.qualityMedium')}</option>
<option value="low">{$t('admin.audio.qualityLow')}</option>
</select>
</div>
<p class="text-[11px] text-gray-400 dark:text-gray-600 -mt-1">
{quality === 'high'
? $t('admin.audio.qualityHintHigh')
: quality === 'medium'
? $t('admin.audio.qualityHintMedium')
: $t('admin.audio.qualityHintLow')}
</p>
</div>
<!-- Speech-to-Text -->
<h3 class="text-xs text-gray-400 dark:text-gray-600 mb-2 mt-5">{$t('admin.audio.stt')}</h3>
<div class="flex flex-col gap-2.5">
<div>
<label class="text-xs text-gray-600 dark:text-gray-400" for="stt-base-url"
>{$t('connections.baseUrl')}</label
>
<input
id="stt-base-url"
type="text"
bind:value={sttBaseUrl}
placeholder="https://api.openai.com/v1"
class="w-full mt-1 h-7 px-2 rounded-lg text-xs bg-gray-100 dark:bg-white/6 text-gray-700 dark:text-gray-300 border border-gray-200 dark:border-white/8 outline-none focus:border-blue-400 dark:focus:border-blue-500 transition-colors"
/>
</div>
<div>
<label class="text-xs text-gray-600 dark:text-gray-400" for="stt-api-key"
>{$t('connections.apiKey')}</label
>
<input
id="stt-api-key"
type="password"
bind:value={sttApiKey}
placeholder={hasExistingKey ? '••••••••' : 'sk-...'}
class="w-full mt-1 h-7 px-2 rounded-lg text-xs bg-gray-100 dark:bg-white/6 text-gray-700 dark:text-gray-300 border border-gray-200 dark:border-white/8 outline-none focus:border-blue-400 dark:focus:border-blue-500 transition-colors"
/>
</div>
<div>
<label class="text-xs text-gray-600 dark:text-gray-400" for="stt-model"
>{$t('automations.model')}</label
>
<input
id="stt-model"
type="text"
bind:value={sttModel}
placeholder="whisper-1"
class="w-full mt-1 h-7 px-2 rounded-lg text-xs bg-gray-100 dark:bg-white/6 text-gray-700 dark:text-gray-300 border border-gray-200 dark:border-white/8 outline-none focus:border-blue-400 dark:focus:border-blue-500 transition-colors"
/>
</div>
<p class="text-[11px] text-gray-400 dark:text-gray-600">
{$t('admin.audio.sttHint')}
</p>
</div>
<!-- Text-to-Speech -->
<h3 class="text-xs text-gray-400 dark:text-gray-600 mb-2 mt-5">{$t('admin.audio.tts')}</h3>
<div class="flex flex-col gap-2.5">
<label class="flex items-center justify-between cursor-pointer">
<span class="text-xs text-gray-600 dark:text-gray-400">{$t('admin.audio.enableTts')}</span
>
<ToggleSwitch
value={ttsEnabled}
onchange={(v) => {
ttsEnabled = v;
}}
/>
</label>
<p class="text-[11px] text-gray-400 dark:text-gray-600 -mt-1">
{$t('admin.audio.ttsEnabledHint')}
</p>
<label class="flex items-center justify-between cursor-pointer">
<span class="text-xs text-gray-600 dark:text-gray-400"
>{$t('admin.audio.ttsAutoStream')}</span
>
<ToggleSwitch
value={ttsAutoStreamEnabled}
onchange={(v) => {
ttsAutoStreamEnabled = v;
}}
/>
</label>
<p class="text-[11px] text-gray-400 dark:text-gray-600 -mt-1">
{$t('admin.audio.ttsAutoStreamHint')}
</p>
<div>
<label class="text-xs text-gray-600 dark:text-gray-400" for="tts-base-url"
>{$t('connections.baseUrl')}</label
>
<input
id="tts-base-url"
type="text"
bind:value={ttsBaseUrl}
placeholder="https://api.openai.com/v1"
class="w-full mt-1 h-7 px-2 rounded-lg text-xs bg-gray-100 dark:bg-white/6 text-gray-700 dark:text-gray-300 border border-gray-200 dark:border-white/8 outline-none focus:border-blue-400 dark:focus:border-blue-500 transition-colors"
/>
</div>
<div>
<label class="text-xs text-gray-600 dark:text-gray-400" for="tts-api-key"
>{$t('connections.apiKey')}</label
>
<input
id="tts-api-key"
type="password"
bind:value={ttsApiKey}
placeholder={hasExistingTtsKey ? '••••••••' : $t('admin.audio.ttsKeyPlaceholder')}
class="w-full mt-1 h-7 px-2 rounded-lg text-xs bg-gray-100 dark:bg-white/6 text-gray-700 dark:text-gray-300 border border-gray-200 dark:border-white/8 outline-none focus:border-blue-400 dark:focus:border-blue-500 transition-colors"
/>
</div>
<div>
<label class="text-xs text-gray-600 dark:text-gray-400" for="tts-model"
>{$t('automations.model')}</label
>
<input
id="tts-model"
type="text"
bind:value={ttsModel}
placeholder="tts-1"
class="w-full mt-1 h-7 px-2 rounded-lg text-xs bg-gray-100 dark:bg-white/6 text-gray-700 dark:text-gray-300 border border-gray-200 dark:border-white/8 outline-none focus:border-blue-400 dark:focus:border-blue-500 transition-colors"
/>
</div>
<div>
<label class="text-xs text-gray-600 dark:text-gray-400" for="tts-voice"
>{$t('admin.audio.ttsVoice')}</label
>
<input
id="tts-voice"
type="text"
bind:value={ttsVoice}
placeholder="alloy"
class="w-full mt-1 h-7 px-2 rounded-lg text-xs bg-gray-100 dark:bg-white/6 text-gray-700 dark:text-gray-300 border border-gray-200 dark:border-white/8 outline-none focus:border-blue-400 dark:focus:border-blue-500 transition-colors"
/>
</div>
<div class="flex items-center justify-between">
<span class="text-xs text-gray-600 dark:text-gray-400">{$t('admin.audio.ttsFormat')}</span
>
<select
bind:value={ttsFormat}
class="bg-transparent text-xs text-gray-600 dark:text-gray-400 outline-none cursor-pointer"
>
<option value="mp3">MP3</option>
<option value="opus">Opus</option>
<option value="aac">AAC</option>
<option value="flac">FLAC</option>
<option value="wav">WAV</option>
<option value="pcm">PCM</option>
</select>
</div>
<div class="flex items-center justify-between gap-3">
<label class="text-xs text-gray-600 dark:text-gray-400" for="tts-playback-speed">
{$t('admin.audio.ttsPlaybackSpeed')}
</label>
<div class="flex items-center gap-2">
<input
id="tts-playback-speed"
type="range"
min="0.5"
max="2"
step="0.05"
bind:value={ttsPlaybackSpeed}
class="w-28 accent-gray-700 dark:accent-gray-300"
/>
<span class="w-9 text-right text-xs text-gray-500 dark:text-gray-400"
>{ttsPlaybackSpeed.toFixed(2)}x</span
>
</div>
</div>
<p class="text-[11px] text-gray-400 dark:text-gray-600">
{$t('admin.audio.ttsHint')}
</p>
</div>
<!-- Voice Mode -->
<h3 class="text-xs text-gray-400 dark:text-gray-600 mb-2 mt-5">
{$t('admin.audio.voiceMode')}
</h3>
<div class="flex flex-col gap-2.5">
<div class="flex items-center justify-between">
<span class="text-xs text-gray-600 dark:text-gray-400"
>{$t('admin.audio.voiceModeSttMode')}</span
>
<select
bind:value={voiceModeSttMode}
class="bg-transparent text-xs text-gray-600 dark:text-gray-400 outline-none cursor-pointer"
>
<option value="browser">{$t('admin.audio.voiceModeSttBrowser')}</option>
<option value="provider">{$t('admin.audio.voiceModeSttProvider')}</option>
</select>
</div>
<p class="text-[11px] text-gray-400 dark:text-gray-600 -mt-1">
{voiceModeSttMode === 'browser'
? $t('admin.audio.voiceModeBrowserSttHint')
: $t('admin.audio.voiceModeProviderSttHint')}
</p>
<div>
<label class="text-xs text-gray-600 dark:text-gray-400" for="voice-mode-system-prompt">
{$t('admin.audio.voiceModeSystemPrompt')}
</label>
<textarea
id="voice-mode-system-prompt"
bind:value={voiceModeSystemPrompt}
rows="5"
placeholder={VOICE_MODE_SYSTEM_PROMPT_PLACEHOLDER}
class="w-full mt-1 px-2 py-1.5 rounded-lg text-xs bg-gray-100 dark:bg-white/6 text-gray-700 dark:text-gray-300 border border-gray-200 dark:border-white/8 outline-none focus:border-blue-400 dark:focus:border-blue-500 transition-colors resize-y min-h-24"
></textarea>
</div>
<p class="text-[11px] text-gray-400 dark:text-gray-600">
{$t('admin.audio.voiceModeSystemPromptHint')}
</p>
</div>
<p class="text-[11px] text-gray-400 dark:text-gray-600">
{$t('admin.audio.voiceModeSystemPromptHint')}
</p>
</div>
<!-- Save -->
<div
class="sticky bottom-0 -mx-4 md:-mx-5 mt-6 flex justify-end border-t border-gray-100 bg-white/95 px-4 py-3 backdrop-blur dark:border-white/6 dark:bg-black/95 md:px-5"
>
<div class="shrink-0 pt-3 flex justify-end">
<button
class="text-[13px] text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white transition-colors duration-100 disabled:opacity-50"
onclick={() => save()}
disabled={saving}>{$t('settings.save')}</button
disabled={saving}
>
{#if saving}{$t('settings.saving')}{:else}{$t('settings.save')}{/if}
</button>
</div>
{/if}
</div>