diff --git a/android/kernel/speech.py b/android/kernel/speech.py index 16eb591..35b9f2c 100644 --- a/android/kernel/speech.py +++ b/android/kernel/speech.py @@ -326,14 +326,24 @@ DEFAULT_SPEECH = { 'ttsModel': 'tts-1', } -# 常用音色,给界面做下拉。火山那几个是文档里的常见 voice_type。 +# 常用音色。★ 名字全部照官方音色列表核对过: +# https://docs.volcengine.com/docs/DoubaoVoice/Tonelist +# 之前这份列表是按印象写的,实测 6 个里错了 4 个(BV701 其实叫「擎苍」不是「通用男声2」, +# BV138 是「情感女声-Lawrence」不是「沉稳男声」)。音色名是用户唯一的识别依据, +# 写错等于让人盲选,所以这里宁可少列几个也要列准。 VOLC_VOICES = [ - {'value': 'BV700_streaming', 'label': '通用女声(BV700)'}, - {'value': 'BV001_streaming', 'label': '通用女声 2(BV001)'}, - {'value': 'BV002_streaming', 'label': '通用男声(BV002)'}, - {'value': 'BV701_streaming', 'label': '通用男声 2(BV701)'}, - {'value': 'BV064_streaming', 'label': '甜美女声(BV064)'}, - {'value': 'BV138_streaming', 'label': '沉稳男声(BV138)'}, + {'value': 'BV700_streaming', 'label': '灿灿 · 通用女声(22 种情感,推荐)'}, + {'value': 'BV700_V2_streaming', 'label': '灿灿 2.0(升级版)'}, + {'value': 'BV001_streaming', 'label': '通用女声'}, + {'value': 'BV001_V2_streaming', 'label': '通用女声 2.0'}, + {'value': 'BV002_streaming', 'label': '通用男声'}, + {'value': 'BV701_streaming', 'label': '擎苍 · 有声阅读'}, + {'value': 'BV701_V2_streaming', 'label': '擎苍 2.0'}, + {'value': 'BV705_streaming', 'label': '炀炀 · 自然对话'}, + {'value': 'BV009_streaming', 'label': '知性女声'}, + {'value': 'BV007_streaming', 'label': '亲切女声'}, + {'value': 'BV123_streaming', 'label': '阳光青年'}, + {'value': 'BV406_streaming', 'label': '超自然音色 · 梓梓'}, ] OPENAI_VOICES = [ diff --git a/scripts/verify-speech.mjs b/scripts/verify-speech.mjs index 5e6cb70..c8c7414 100644 --- a/scripts/verify-speech.mjs +++ b/scripts/verify-speech.mjs @@ -100,6 +100,24 @@ check('默认引擎是 system(不联网)', st.speech?.ttsEngine === 'system' check('音色选项已下发', Array.isArray(st.speechVoices?.volc) && st.speechVoices.volc.length > 0, `火山 ${st.speechVoices?.volc?.length} 个 / OpenAI ${st.speechVoices?.openai?.length} 个`); +// 音色名是用户唯一的识别依据,必须对得上官方列表。 +// 之前这份列表是凭印象写的,6 个错了 4 个(BV701 官方叫「擎苍」不是「通用男声2」), +// 所以这里钉死几个已知正确的对应关系,防止再被改错。 +const VOICE_TRUTH = { + BV700_streaming: '灿灿', + BV001_streaming: '通用女声', + BV002_streaming: '通用男声', + BV701_streaming: '擎苍', +}; +const volcVoices = st.speechVoices?.volc || []; +let voiceBad = []; +for (const [id, name] of Object.entries(VOICE_TRUTH)) { + const hit = volcVoices.find((v) => v.value === id); + if (!hit) voiceBad.push(`${id} 缺失`); + else if (!hit.label.includes(name)) voiceBad.push(`${id} 名字是「${hit.label}」,官方叫「${name}」`); +} +check('音色名和官方列表一致', voiceBad.length === 0, voiceBad.join(';') || `${Object.keys(VOICE_TRUTH).length} 个已核对`); + const ttsSystem = await api('/api/tts', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ text: '你好' }), diff --git a/server/src/speech.mjs b/server/src/speech.mjs index 67fa90c..842c84b 100644 --- a/server/src/speech.mjs +++ b/server/src/speech.mjs @@ -261,13 +261,25 @@ export const DEFAULT_SPEECH = { ttsModel: 'tts-1', }; +/** + * 常用音色。★ 名字照官方音色列表核对过: + * https://docs.volcengine.com/docs/DoubaoVoice/Tonelist + * 之前是凭印象写的,6 个错了 4 个(BV701 叫「擎苍」不是「通用男声2」)。 + * 音色名是用户唯一的识别依据,写错等于让人盲选。 + */ export const VOLC_VOICES = [ - { value: 'BV700_streaming', label: '通用女声(BV700)' }, - { value: 'BV001_streaming', label: '通用女声 2(BV001)' }, - { value: 'BV002_streaming', label: '通用男声(BV002)' }, - { value: 'BV701_streaming', label: '通用男声 2(BV701)' }, - { value: 'BV064_streaming', label: '甜美女声(BV064)' }, - { value: 'BV138_streaming', label: '沉稳男声(BV138)' }, + { value: 'BV700_streaming', label: '灿灿 · 通用女声(22 种情感,推荐)' }, + { value: 'BV700_V2_streaming', label: '灿灿 2.0(升级版)' }, + { value: 'BV001_streaming', label: '通用女声' }, + { value: 'BV001_V2_streaming', label: '通用女声 2.0' }, + { value: 'BV002_streaming', label: '通用男声' }, + { value: 'BV701_streaming', label: '擎苍 · 有声阅读' }, + { value: 'BV701_V2_streaming', label: '擎苍 2.0' }, + { value: 'BV705_streaming', label: '炀炀 · 自然对话' }, + { value: 'BV009_streaming', label: '知性女声' }, + { value: 'BV007_streaming', label: '亲切女声' }, + { value: 'BV123_streaming', label: '阳光青年' }, + { value: 'BV406_streaming', label: '超自然音色 · 梓梓' }, ]; export const OPENAI_VOICES = [