fix(voice): expose TTS format in user settings

This commit is contained in:
Haileyesus
2026-06-24 10:05:35 +03:00
parent 9919851be7
commit 8cbfac6ab1
5 changed files with 18 additions and 58 deletions

View File

@@ -54,7 +54,7 @@ export default function VoiceSettingsTab() {
value={config.apiKey}
onChange={(e) => update({ apiKey: e.target.value })}
/>
<div className="grid grid-cols-1 gap-4 sm:grid-cols-3">
<div className="grid grid-cols-1 gap-4 sm:grid-cols-4">
<Field
label={t('voiceSettings.sttModel')}
placeholder="whisper-1"
@@ -73,6 +73,12 @@ export default function VoiceSettingsTab() {
value={config.ttsVoice}
onChange={(e) => update({ ttsVoice: e.target.value })}
/>
<Field
label={t('voiceSettings.format')}
placeholder="mp3"
value={config.ttsFormat}
onChange={(e) => update({ ttsFormat: e.target.value })}
/>
</div>
<p className="text-xs text-muted-foreground">{t('voiceSettings.note')}</p>
</div>

View File

@@ -6,17 +6,20 @@ export type VoiceConfig = {
sttModel: string;
ttsModel: string;
ttsVoice: string;
ttsFormat: string;
};
const STORAGE_KEY = 'voiceConfig';
const DEFAULTS: VoiceConfig = { baseUrl: '', apiKey: '', sttModel: '', ttsModel: '', ttsVoice: '' };
const DEFAULTS: VoiceConfig = { baseUrl: '', apiKey: '', sttModel: '', ttsModel: '', ttsVoice: '', ttsFormat: 'mp3' };
function read(): VoiceConfig {
try {
const raw = localStorage.getItem(STORAGE_KEY);
if (!raw) return { ...DEFAULTS };
const parsed = JSON.parse(raw);
return { ...DEFAULTS, ...(parsed && typeof parsed === 'object' ? parsed : {}) };
const next = { ...DEFAULTS, ...(parsed && typeof parsed === 'object' ? parsed : {}) };
if (!next.ttsFormat) next.ttsFormat = DEFAULTS.ttsFormat;
return next;
} catch {
return { ...DEFAULTS };
}
@@ -33,6 +36,7 @@ export function voiceConfigHeaders(): Record<string, string> {
if (c.sttModel) h['x-voice-stt-model'] = c.sttModel;
if (c.ttsModel) h['x-voice-tts-model'] = c.ttsModel;
if (c.ttsVoice) h['x-voice-tts-voice'] = c.ttsVoice;
if (c.ttsFormat) h['x-voice-tts-format'] = c.ttsFormat;
return h;
}

View File

@@ -61,7 +61,8 @@
"sttModel": "Speech-to-text model",
"ttsModel": "Text-to-speech model",
"voice": "Voice",
"note": "The shown defaults work with OpenAI once you add a key. For other providers, set the base URL and model names to match."
"format": "Audio format",
"note": "The shown defaults work with OpenAI once you add a key. For other providers, set the base URL, model names, and audio format to match."
},
"quickSettings": {
"title": "Quick Settings",