Fix tts voice bug
This commit is contained in:
@@ -19,6 +19,29 @@ const isSiliconflowVendor = (vendor?: string) => {
|
||||
return normalized === 'siliconflow' || normalized === '硅基流动';
|
||||
};
|
||||
|
||||
const SILICONFLOW_DEFAULT_MODEL = 'FunAudioLLM/CosyVoice2-0.5B';
|
||||
|
||||
const buildSiliconflowVoiceKey = (voiceId: string, model?: string) => {
|
||||
const id = String(voiceId || '').trim();
|
||||
if (!id) return '';
|
||||
if (id.includes(':')) return id;
|
||||
return `${model || SILICONFLOW_DEFAULT_MODEL}:${id}`;
|
||||
};
|
||||
|
||||
const resolveRuntimeTtsVoice = (selectedVoiceId: string, voice: Voice) => {
|
||||
const explicitKey = String(voice.voiceKey || '').trim();
|
||||
if (!isSiliconflowVendor(voice.vendor)) {
|
||||
return explicitKey || selectedVoiceId;
|
||||
}
|
||||
if (voice.isSystem) {
|
||||
const canonical = buildSiliconflowVoiceKey(selectedVoiceId, voice.model);
|
||||
if (!explicitKey) return canonical;
|
||||
const explicitSuffix = explicitKey.includes(':') ? explicitKey.split(':').pop() : explicitKey;
|
||||
if (explicitSuffix && explicitSuffix !== selectedVoiceId) return canonical;
|
||||
}
|
||||
return explicitKey || buildSiliconflowVoiceKey(selectedVoiceId, voice.model);
|
||||
};
|
||||
|
||||
export const AssistantsPage: React.FC = () => {
|
||||
const [assistants, setAssistants] = useState<Assistant[]>([]);
|
||||
const [voices, setVoices] = useState<Voice[]>([]);
|
||||
@@ -1404,7 +1427,7 @@ export const DebugDrawer: React.FC<{
|
||||
provider: ttsProvider,
|
||||
model: voice.model,
|
||||
apiKey: ttsProvider === 'siliconflow' ? voice.apiKey : null,
|
||||
voice: voice.voiceKey || voice.id,
|
||||
voice: resolveRuntimeTtsVoice(assistant.voice, voice),
|
||||
speed: assistant.speed || voice.speed || 1.0,
|
||||
};
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user