dsh-xiaomi-tts 2.3.2 → 2.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.en.md +198 -120
- package/README.md +193 -185
- package/assets/menu.png +0 -0
- package/assets/preset.png +0 -0
- package/assets/social.png +0 -0
- package/assets/voice-avatars/baihua.webp +0 -0
- package/assets/voice-avatars/bingtang.webp +0 -0
- package/assets/voice-avatars/chloe.webp +0 -0
- package/assets/voice-avatars/dean.webp +0 -0
- package/assets/voice-avatars/mia.webp +0 -0
- package/assets/voice-avatars/milo.webp +0 -0
- package/assets/voice-avatars/moli.webp +0 -0
- package/assets/voice-avatars/suda.webp +0 -0
- package/assets/voice-presets/energetic-girl.webp +0 -0
- package/assets/voice-presets/liang-wenfeng.webp +0 -0
- package/cordis.patch.yml +4 -1
- package/lib/client/built-in-voice-picker.d.ts +10 -0
- package/lib/client/built-in-voice-picker.d.ts.map +1 -0
- package/lib/client/conversation.d.ts.map +1 -1
- package/lib/client/live-speech-controller.d.ts +6 -0
- package/lib/client/live-speech-controller.d.ts.map +1 -1
- package/lib/client/localization.d.ts +15 -4
- package/lib/client/localization.d.ts.map +1 -1
- package/lib/client/pcm-audio-queue.d.ts +7 -0
- package/lib/client/pcm-audio-queue.d.ts.map +1 -1
- package/lib/client/playback-controller.d.ts +4 -0
- package/lib/client/playback-controller.d.ts.map +1 -1
- package/lib/client/playback-types.d.ts +1 -1
- package/lib/client/playback-types.d.ts.map +1 -1
- package/lib/client/settings-card.d.ts.map +1 -1
- package/lib/client/settings-scope.d.ts.map +1 -1
- package/lib/client/styles.d.ts +1 -1
- package/lib/client/styles.d.ts.map +1 -1
- package/lib/client/voice-design-picker.d.ts.map +1 -1
- package/lib/client.js +880 -242
- package/lib/client.js.map +1 -1
- package/lib/index.d.ts +10 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +122 -33
- package/lib/{shared-9qFFYsWe.js → shared-CIx9nBxX.js} +226 -44
- package/lib/shared.d.ts +100 -29
- package/lib/shared.d.ts.map +1 -1
- package/lib/shared.js +2 -2
- package/package.json +104 -103
package/lib/client.js
CHANGED
|
@@ -41,22 +41,54 @@ const TTS_STREAM_ROUTE = "/plugins/xiaomi-mimo-tts/synthesize-stream";
|
|
|
41
41
|
const TTS_UNINSTALL_ROUTE = "/plugins/xiaomi-mimo-tts/uninstall";
|
|
42
42
|
/** Same-origin route that checks the published npm version. */
|
|
43
43
|
const TTS_UPDATE_ROUTE = "/plugins/xiaomi-mimo-tts/update";
|
|
44
|
-
/** Keep the UI version visible without making the browser bundle load package.json. */
|
|
45
|
-
const TTS_VERSION = "2.3.2";
|
|
46
44
|
/** Same-origin route that reports API key configuration status without exposing the key. */
|
|
47
45
|
const TTS_API_KEY_STATUS_ROUTE = "/plugins/xiaomi-mimo-tts/api-key-status";
|
|
48
46
|
/** Same-origin prefix used by the Web client to load voice-design preset icons. */
|
|
49
47
|
const TTS_VOICE_DESIGN_ASSET_ROUTE = "/plugins/xiaomi-mimo-tts/voice-presets";
|
|
50
|
-
/**
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
48
|
+
/** Same-origin prefix used by the Web client to load official built-in voice avatars. */
|
|
49
|
+
const TTS_VOICE_ASSET_ROUTE = "/plugins/xiaomi-mimo-tts/voice-avatars";
|
|
50
|
+
/** Built-in voice metadata mirrored from Xiaomi MiMo's official selector. */
|
|
51
|
+
const TTS_VOICE_PRESETS = [
|
|
52
|
+
{
|
|
53
|
+
id: "bingtang",
|
|
54
|
+
value: "冰糖",
|
|
55
|
+
summary: "活泼少女"
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
id: "mia",
|
|
59
|
+
value: "Mia",
|
|
60
|
+
summary: "Lively girl"
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
id: "moli",
|
|
64
|
+
value: "茉莉",
|
|
65
|
+
summary: "知性女声"
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
id: "chloe",
|
|
69
|
+
value: "Chloe",
|
|
70
|
+
summary: "Witty Grace"
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
id: "suda",
|
|
74
|
+
value: "苏打",
|
|
75
|
+
summary: "阳光少年"
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
id: "milo",
|
|
79
|
+
value: "Milo",
|
|
80
|
+
summary: "Sunny boy"
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
id: "baihua",
|
|
84
|
+
value: "白桦",
|
|
85
|
+
summary: "成熟男声"
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
id: "dean",
|
|
89
|
+
value: "Dean",
|
|
90
|
+
summary: "Steady Gentle"
|
|
91
|
+
}
|
|
60
92
|
];
|
|
61
93
|
/** TTS models supported by this plugin. */
|
|
62
94
|
const TTS_MODELS = ["mimo-v2.5-tts", "mimo-v2.5-tts-voicedesign"];
|
|
@@ -64,61 +96,85 @@ const TTS_MODELS = ["mimo-v2.5-tts", "mimo-v2.5-tts-voicedesign"];
|
|
|
64
96
|
const TTS_VOICE_DESIGN_PRESETS = [
|
|
65
97
|
{
|
|
66
98
|
id: "energetic-girl",
|
|
67
|
-
label: "
|
|
68
|
-
summary: "
|
|
69
|
-
prompt: "年轻女性
|
|
99
|
+
label: "鲸鱼娘",
|
|
100
|
+
summary: "爱吃白米饭",
|
|
101
|
+
prompt: "年轻女性16-22岁,标准普通话,清透甜美的中高音,音色明亮而不尖锐,带一点轻盈柔软的空气感;吐字清楚、节奏灵动,语速中等偏快,语调自然上扬,情绪开朗亲切又略带俏皮,整体听感温柔、有陪伴感。"
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
id: "liang-wenfeng",
|
|
105
|
+
label: "梁文峰",
|
|
106
|
+
summary: "理性克制",
|
|
107
|
+
prompt: "成年男性 35–40 岁,普通话,温和克制的中低音,声线清晰自然,声音偏亮不沉闷,略带书卷气和理工感,语速中等偏慢,停顿审慎,表达理性简洁,情绪稳定,不夸张。"
|
|
70
108
|
},
|
|
71
109
|
{
|
|
72
110
|
id: "asmr-whisper",
|
|
73
111
|
label: "沈听澜",
|
|
74
|
-
summary: "
|
|
112
|
+
summary: "ASMR低语",
|
|
75
113
|
prompt: "女性18-20岁,轻柔耳语带微弱气息,普通话,声线细腻清晰,私密温柔感,安静平和带轻柔低语,语速缓慢音量很轻,私密低语场景。"
|
|
76
114
|
},
|
|
115
|
+
{
|
|
116
|
+
id: "young-man",
|
|
117
|
+
label: "江予辰",
|
|
118
|
+
summary: "阳光少年",
|
|
119
|
+
prompt: "男性青年16-22岁,清亮干净的中高音带少年感,普通话标准无口音,轻快明亮的活力声线,气息轻盈吐字利索,语速偏快语调自然上扬,情绪积极阳光带朝气,广告旁白或轻松解说场景。"
|
|
120
|
+
},
|
|
77
121
|
{
|
|
78
122
|
id: "gentle-girlfriend",
|
|
79
|
-
label: "
|
|
80
|
-
summary: "
|
|
123
|
+
label: "张子苜",
|
|
124
|
+
summary: "温柔陪伴",
|
|
81
125
|
prompt: "年轻女性16-22岁,声线柔软细腻,低饱和带微微暖意,标准普通话,温柔亲密的邻家风格,语速偏慢,语调轻柔连贯,气息自然流畅,安静私密陪伴场景。"
|
|
82
126
|
},
|
|
127
|
+
{
|
|
128
|
+
id: "tech-explainer",
|
|
129
|
+
label: "周砚川",
|
|
130
|
+
summary: "科技解说",
|
|
131
|
+
prompt: "成年男性25-35岁,清晰利落中音、干净偏冷,标准普通话,精准干练的都市精英感,语速中等偏快、语调平稳,理性简洁、逻辑感强,现代资讯播报或商业讲解场景。"
|
|
132
|
+
},
|
|
83
133
|
{
|
|
84
134
|
id: "girl-next-door",
|
|
85
135
|
label: "陈念安",
|
|
86
|
-
summary: "
|
|
136
|
+
summary: "邻家甜声",
|
|
87
137
|
prompt: "年轻女性20-25岁,柔润清甜带撒娇感,普通话,清澈明亮的少女音,轻松温柔的亲近感,轻松平缓带温柔,中等偏快语速中等音量,生活分享场景。"
|
|
88
138
|
},
|
|
139
|
+
{
|
|
140
|
+
id: "documentary-narrator",
|
|
141
|
+
label: "陆远山",
|
|
142
|
+
summary: "纪录片旁白",
|
|
143
|
+
prompt: "男性40-50岁,低沉醇厚有胸腔共鸣,普通话,稳重可靠的叙事者风格,语速中等偏慢,语调沉稳克制带叙事纵深感,气息舒展停顿有留白,纪录片旁白或深度访谈场景。"
|
|
144
|
+
},
|
|
89
145
|
{
|
|
90
146
|
id: "news-anchor",
|
|
91
147
|
label: "顾知微",
|
|
92
|
-
summary: "
|
|
148
|
+
summary: "沉稳播报",
|
|
93
149
|
prompt: "专业新闻播音女主持,成年女性30-40岁,普通话标准无口音,声线中低音区饱满清晰,端庄知性沉稳,语气克制权威,语速从容均匀,音量适中稳定,新闻播报与专题解说场景。"
|
|
94
150
|
},
|
|
95
|
-
{
|
|
96
|
-
id: "young-man",
|
|
97
|
-
label: "江予辰",
|
|
98
|
-
summary: "男 · 19岁 · 青年男声,清亮干净的中高音带少年感",
|
|
99
|
-
prompt: "男性青年16-22岁,清亮干净的中高音带少年感,普通话标准无口音,轻快明亮的活力声线,气息轻盈吐字利索,语速偏快语调自然上扬,情绪积极阳光带朝气,广告旁白或轻松解说场景。"
|
|
100
|
-
},
|
|
101
|
-
{
|
|
102
|
-
id: "tech-explainer",
|
|
103
|
-
label: "周砚川",
|
|
104
|
-
summary: "男 · 30岁 · 科技解说,清晰利落中音、干净偏冷",
|
|
105
|
-
prompt: "成年男性25-35岁,清晰利落中音、干净偏冷,标准普通话,精准干练的都市精英感,语速中等偏快、语调平稳,理性简洁、逻辑感强,现代资讯播报或商业讲解场景。"
|
|
106
|
-
},
|
|
107
151
|
{
|
|
108
152
|
id: "suspense-narrator",
|
|
109
153
|
label: "裴沉舟",
|
|
110
|
-
summary: "
|
|
154
|
+
summary: "悬疑旁白",
|
|
111
155
|
prompt: "男性中年30-40岁,低沉沉稳带神秘磁性,普通话,压抑克制的叙事风格,语速缓慢均匀,语调低沉平稳,情绪冷静悬疑,旁白解说场景。"
|
|
112
|
-
},
|
|
113
|
-
{
|
|
114
|
-
id: "documentary-narrator",
|
|
115
|
-
label: "陆远山",
|
|
116
|
-
summary: "男 · 45岁 · 纪录片,低沉醇厚有胸腔共鸣",
|
|
117
|
-
prompt: "男性40-50岁,低沉醇厚有胸腔共鸣,普通话,稳重可靠的叙事者风格,语速中等偏慢,语调沉稳克制带叙事纵深感,气息舒展停顿有留白,纪录片旁白或深度访谈场景。"
|
|
118
156
|
}
|
|
119
157
|
];
|
|
158
|
+
/** Supported audio formats. */
|
|
159
|
+
const TTS_FORMATS = [
|
|
160
|
+
"pcm",
|
|
161
|
+
"mp3",
|
|
162
|
+
"wav"
|
|
163
|
+
];
|
|
164
|
+
/** Voice-design playback strategies. Segmented playback keeps each upstream request short. */
|
|
165
|
+
const TTS_VOICE_DESIGN_PLAYBACK_MODES = ["complete", "segmented"];
|
|
166
|
+
const DEFAULT_TTS_SEGMENT_CHARACTERS = 120;
|
|
167
|
+
const MAX_TTS_SEGMENT_CHARACTERS = 180;
|
|
168
|
+
const MIN_TTS_SEGMENT_CHARACTERS = 40;
|
|
120
169
|
/** Minimum spoken characters to accumulate before starting one PCM stream request. */
|
|
121
170
|
const MIN_TTS_STREAM_CHARACTERS = 20;
|
|
171
|
+
/** Maximum decoded complete MP3 payload accepted from Xiaomi MiMo. */
|
|
172
|
+
const DEFAULT_MAX_MP3_AUDIO_BYTES = 32 * 1024 * 1024;
|
|
173
|
+
/** Maximum decoded complete WAV payload accepted from Xiaomi MiMo. */
|
|
174
|
+
const DEFAULT_MAX_WAV_AUDIO_BYTES = 128 * 1024 * 1024;
|
|
175
|
+
const DEFAULT_MAX_PAUSED_PCM_BYTES = 32 * 1024 * 1024;
|
|
176
|
+
/** Extra JSON envelope allowance around a Base64 audio payload. */
|
|
177
|
+
const TTS_AUDIO_RESPONSE_JSON_OVERHEAD_BYTES = 1024 * 1024;
|
|
122
178
|
const TTS_PUNCTUATION = {
|
|
123
179
|
",": ",",
|
|
124
180
|
"。": ".",
|
|
@@ -133,21 +189,33 @@ const TTS_PUNCTUATION = {
|
|
|
133
189
|
/** Decorative punctuation can make TTS emit non-speech artifacts, so omit it entirely. */
|
|
134
190
|
const TTS_NON_SPEECH_PUNCTUATION = /[()\[\]【】[]〔〕〖〗{}{}「」『』《》〈〉“”‘’"'`<>:…—–-~]/gu;
|
|
135
191
|
const TTS_URL_PATTERN = /\b(?:https?|ftp):\/\/[^\s<>()]+|\bwww\.[^\s<>()]+|\b(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+(?:com|cn|net|org|io|ai|dev|me|co|edu|gov|xyz|tech|info|app|site|link)(?:[/:?#][^\s<>()]*)?/giu;
|
|
136
|
-
const TTS_WINDOWS_PATH_PATTERN = /(?:\b[A-Za-z]:[\\/]|\\\\)(?:[A-Za-z0-9._ -]+[\\/])
|
|
137
|
-
const TTS_UNIX_PATH_PATTERN = /\/(?:[A-Za-z0-9._-]+\/)
|
|
192
|
+
const TTS_WINDOWS_PATH_PATTERN = /(?:\b[A-Za-z]:[\\/]|\\\\)(?:[A-Za-z0-9._ -]+[\\/])+(?:[A-Za-z0-9._ -]+)/gu;
|
|
193
|
+
const TTS_UNIX_PATH_PATTERN = /\/(?:[A-Za-z0-9._-]+\/)+(?:[A-Za-z0-9._-]+)/gu;
|
|
138
194
|
const TTS_RELATIVE_PATH_PATTERN = /(?:\.\.?[\\/])(?:[A-Za-z0-9._-]+[\\/])*(?:[A-Za-z0-9._-]+(?:\.[A-Za-z0-9_-]+)?)/gu;
|
|
139
195
|
const TTS_PROJECT_PATH_PATTERN = /\b(?:[A-Za-z0-9_-]+[\\/])+[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\b/gu;
|
|
196
|
+
/** Combined Markdown syntax and path removal in a single pass. */
|
|
197
|
+
const MARKDOWN_CODE_BLOCK_RE = /```[\s\S]*?```|~~~[\s\S]*?~~~/g;
|
|
198
|
+
const MARKDOWN_INDENTED_CODE_RE = /(^|\n)(?: {4}|\t)[^\n]*(?=\n|$)/g;
|
|
199
|
+
const MARKDOWN_IMAGE_RE = /!\[([^\]\r\n]*)\]\([^\)\r\n]*\)/g;
|
|
200
|
+
const MARKDOWN_LINK_RE = /\[([^\]\r\n]*)\]\([^\)\r\n]*\)/g;
|
|
201
|
+
const MARKDOWN_HTML_TAG_RE = /<[^>\r\n]*>/g;
|
|
202
|
+
const MARKDOWN_HEADING_RE = /(^|\n)\s{0,3}#{1,6}\s+/g;
|
|
203
|
+
const MARKDOWN_LIST_RE = /(^|\n)\s*(?:[-*+]|\d+[.)])\s+/g;
|
|
204
|
+
const MARKDOWN_BLOCKQUOTE_RE = /(^|\n)\s*>\s?/g;
|
|
205
|
+
const MARKDOWN_INLINE_FORMAT_RE = /`+|[*_~]{1,3}/g;
|
|
206
|
+
const MARKDOWN_TABLE_SEP_RE = /[|]/g;
|
|
140
207
|
function removeTtsPaths(value) {
|
|
141
208
|
return value.replace(TTS_WINDOWS_PATH_PATTERN, " ").replace(TTS_RELATIVE_PATH_PATTERN, " ").replace(TTS_PROJECT_PATH_PATTERN, " ").replace(TTS_UNIX_PATH_PATTERN, " ");
|
|
142
209
|
}
|
|
143
210
|
function removeTtsMarkup(value) {
|
|
144
|
-
let text = value.replace(
|
|
211
|
+
let text = value.replace(MARKDOWN_CODE_BLOCK_RE, " ").replace(MARKDOWN_INDENTED_CODE_RE, "$1").replace(MARKDOWN_IMAGE_RE, " ").replace(MARKDOWN_LINK_RE, "$1").replace(MARKDOWN_HTML_TAG_RE, " ").replace(MARKDOWN_HEADING_RE, "$1").replace(MARKDOWN_LIST_RE, "$1").replace(MARKDOWN_BLOCKQUOTE_RE, "$1").replace(MARKDOWN_INLINE_FORMAT_RE, "").replace(MARKDOWN_TABLE_SEP_RE, " ");
|
|
145
212
|
text = text.replace(TTS_URL_PATTERN, " ");
|
|
146
213
|
return removeTtsPaths(text);
|
|
147
214
|
}
|
|
148
215
|
function removeTtsSymbols(value) {
|
|
149
216
|
return value.replace(/[\u0000-\u0008\u000B\u000C\u000E-\u001F\u007F-\u009F\u200B-\u200F\u202A-\u202E\u2060-\u2064\u2066-\u206F\uFEFF]/g, " ").replace(/(?:\p{Extended_Pictographic}|\p{Emoji_Presentation}|\p{Regional_Indicator}|\p{Emoji_Modifier}|\p{So}|\uFE0E|\uFE0F|\u200D|\u20E3)/gu, " ");
|
|
150
217
|
}
|
|
218
|
+
/** Combined punctuation normalization: collapse adjacent punctuation, remove non-speech characters, and normalize Chinese punctuation. */
|
|
151
219
|
function normalizeTtsPunctuation(value) {
|
|
152
220
|
return value.replace(TTS_NON_SPEECH_PUNCTUATION, "").replace(/[,。!?;、() ]/gu, (character) => TTS_PUNCTUATION[character] ?? character).replace(/(^|\s)[,;:!?]+(?=\s|$)/g, "$1").replace(/([,;:])\s*([.!?])/g, "$2").replace(/\s+([,.;:!?])/g, "$1");
|
|
153
221
|
}
|
|
@@ -161,24 +229,116 @@ function prepareTtsText(value) {
|
|
|
161
229
|
if (value.length === 0) return "";
|
|
162
230
|
return normalizeTtsPunctuation(removeTtsSymbols(removeTtsMarkup(value).replace(/\\[rn]|\/n/gi, " ").replace(/\r\n?|\n/g, "."))).replace(/\s+/g, " ").trim();
|
|
163
231
|
}
|
|
164
|
-
/**
|
|
232
|
+
/** Locate fenced code blocks in raw streaming text so their content is never read aloud. */
|
|
233
|
+
function findFencedCodeRegions(value) {
|
|
234
|
+
const regions = [];
|
|
235
|
+
let pendingStart = null;
|
|
236
|
+
const fence = /(^|\n)[ \t]{0,3}(`{3,}|~{3,})[^\r\n]*/g;
|
|
237
|
+
let open = null;
|
|
238
|
+
for (const match of value.matchAll(fence)) {
|
|
239
|
+
const lineStart = match.index + (match[1] === "\n" ? 1 : 0);
|
|
240
|
+
const char = match[2][0];
|
|
241
|
+
if (open === null) open = {
|
|
242
|
+
start: lineStart,
|
|
243
|
+
char
|
|
244
|
+
};
|
|
245
|
+
else if (open.char === char) {
|
|
246
|
+
regions.push([open.start, match.index + match[0].length]);
|
|
247
|
+
open = null;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
if (open !== null) pendingStart = open.start;
|
|
251
|
+
return {
|
|
252
|
+
regions,
|
|
253
|
+
pendingStart
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
/** Split an accumulated model delta at completed sentence-ending punctuation, skipping fenced code blocks whole. */
|
|
165
257
|
function splitCompletedTtsSentences(value) {
|
|
166
|
-
const
|
|
258
|
+
const { regions, pendingStart } = findFencedCodeRegions(value);
|
|
259
|
+
const limit = pendingStart ?? value.length;
|
|
167
260
|
const boundary = /[。!?!?;;\n]+(?:[”’)】》〕\]}'"]*\s*)/gu;
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
261
|
+
const sentences = [];
|
|
262
|
+
let sentenceStart = 0;
|
|
263
|
+
let consumed = 0;
|
|
264
|
+
const splitSegment = (from, to) => {
|
|
265
|
+
boundary.lastIndex = from;
|
|
266
|
+
let match;
|
|
267
|
+
while ((match = boundary.exec(value)) !== null) {
|
|
268
|
+
const end = match.index + match[0].length;
|
|
269
|
+
if (end > to) break;
|
|
270
|
+
const sentence = value.slice(sentenceStart, end);
|
|
271
|
+
if (sentence.trim().length > 0) sentences.push(sentence);
|
|
272
|
+
sentenceStart = end;
|
|
273
|
+
consumed = end;
|
|
274
|
+
}
|
|
275
|
+
};
|
|
276
|
+
let pos = 0;
|
|
277
|
+
for (const [start, end] of regions) {
|
|
278
|
+
if (start >= limit) break;
|
|
279
|
+
if (pos < start) splitSegment(pos, Math.min(start, limit));
|
|
280
|
+
sentenceStart = Math.max(sentenceStart, end);
|
|
281
|
+
consumed = Math.max(consumed, end);
|
|
282
|
+
pos = end;
|
|
173
283
|
}
|
|
284
|
+
if (pos < limit) splitSegment(pos, limit);
|
|
285
|
+
if (pendingStart !== null) return {
|
|
286
|
+
sentences,
|
|
287
|
+
remainder: value.slice(pendingStart),
|
|
288
|
+
consumed: pendingStart,
|
|
289
|
+
inCode: true
|
|
290
|
+
};
|
|
174
291
|
return {
|
|
175
292
|
sentences,
|
|
176
|
-
remainder: value.slice(
|
|
293
|
+
remainder: value.slice(consumed),
|
|
294
|
+
consumed,
|
|
295
|
+
inCode: false
|
|
177
296
|
};
|
|
178
297
|
}
|
|
179
298
|
/** Count text-bearing characters only, excluding punctuation and whitespace. */
|
|
180
299
|
function countTtsSpeechCharacters(value) {
|
|
181
|
-
return
|
|
300
|
+
return (value.match(/[\p{L}\p{N}]/gu) ?? []).length;
|
|
301
|
+
}
|
|
302
|
+
/** Split cleaned speech text on natural boundaries while bounding VoiceDesign requests. */
|
|
303
|
+
function splitTtsSegments(value, target = DEFAULT_TTS_SEGMENT_CHARACTERS, maximum = MAX_TTS_SEGMENT_CHARACTERS) {
|
|
304
|
+
const text = prepareTtsText(value);
|
|
305
|
+
if (text.length === 0) return [];
|
|
306
|
+
const preferred = Math.max(MIN_TTS_SEGMENT_CHARACTERS, Math.min(target, maximum));
|
|
307
|
+
const pieces = text.match(/[^.!?;]+[.!?;]*|[.!?;]+/gu) ?? [text];
|
|
308
|
+
const segments = [];
|
|
309
|
+
let pending = "";
|
|
310
|
+
const append = (piece) => {
|
|
311
|
+
const candidate = `${pending}${piece}`.trim();
|
|
312
|
+
if (candidate.length === 0) return;
|
|
313
|
+
if (countTtsSpeechCharacters(candidate) <= maximum) {
|
|
314
|
+
pending = candidate;
|
|
315
|
+
if (countTtsSpeechCharacters(pending) >= preferred) {
|
|
316
|
+
segments.push(pending);
|
|
317
|
+
pending = "";
|
|
318
|
+
}
|
|
319
|
+
return;
|
|
320
|
+
}
|
|
321
|
+
if (pending.length > 0) {
|
|
322
|
+
segments.push(pending);
|
|
323
|
+
pending = "";
|
|
324
|
+
}
|
|
325
|
+
let rest = piece.trim();
|
|
326
|
+
while (countTtsSpeechCharacters(rest) > maximum) {
|
|
327
|
+
let cut = Math.min(rest.length, maximum);
|
|
328
|
+
const boundary = Math.max(rest.lastIndexOf(",", cut), rest.lastIndexOf(" ", cut), rest.lastIndexOf(":", cut));
|
|
329
|
+
if (boundary >= MIN_TTS_SEGMENT_CHARACTERS) cut = boundary + 1;
|
|
330
|
+
segments.push(rest.slice(0, cut).trim());
|
|
331
|
+
rest = rest.slice(cut).trim();
|
|
332
|
+
}
|
|
333
|
+
pending = rest;
|
|
334
|
+
};
|
|
335
|
+
for (const piece of pieces) append(piece);
|
|
336
|
+
if (pending.length > 0) {
|
|
337
|
+
const last = segments.at(-1);
|
|
338
|
+
if (last !== void 0 && countTtsSpeechCharacters(pending) < MIN_TTS_SEGMENT_CHARACTERS && countTtsSpeechCharacters(`${last}${pending}`) <= maximum) segments[segments.length - 1] = `${last}${pending}`;
|
|
339
|
+
else segments.push(pending);
|
|
340
|
+
}
|
|
341
|
+
return segments;
|
|
182
342
|
}
|
|
183
343
|
/** Accumulate short sentences so a PCM stream has enough text to sound natural. */
|
|
184
344
|
function batchTtsStreamText(pending, next, flush) {
|
|
@@ -268,11 +428,15 @@ const DEFAULT_TTS_SETTINGS = {
|
|
|
268
428
|
voiceDesignPrompt: "青年女性,声线清亮、亲切自然,吐字清楚,语速适中,情绪温柔克制。",
|
|
269
429
|
voiceDesignCustomPrompt: "青年女性,声线清亮、亲切自然,吐字清楚,语速适中,情绪温柔克制。",
|
|
270
430
|
presetStylePrompt: "使用清晰、自然、准确的声音朗读,语速适中,停顿自然,语气平和克制,避免夸张表达。",
|
|
271
|
-
format: "
|
|
431
|
+
format: "pcm",
|
|
432
|
+
voiceDesignPlaybackMode: "complete",
|
|
272
433
|
autoPlay: true,
|
|
273
434
|
instruction: "请忠实朗读原文,根据文本语气自然表达,不添加或改写内容。",
|
|
274
435
|
maxTextLength: 12e3,
|
|
275
|
-
requestTimeoutMs: 12e4
|
|
436
|
+
requestTimeoutMs: 12e4,
|
|
437
|
+
maxMp3AudioBytes: DEFAULT_MAX_MP3_AUDIO_BYTES,
|
|
438
|
+
maxWavAudioBytes: DEFAULT_MAX_WAV_AUDIO_BYTES,
|
|
439
|
+
maxPausedPcmBytes: DEFAULT_MAX_PAUSED_PCM_BYTES
|
|
276
440
|
};
|
|
277
441
|
/** Whether an API key selects one of the Xiaomi endpoints supported by this plugin. */
|
|
278
442
|
function isSupportedTtsApiKey(apiKey) {
|
|
@@ -299,12 +463,27 @@ var PcmAudioQueue = class {
|
|
|
299
463
|
context = null;
|
|
300
464
|
scheduledAt = 0;
|
|
301
465
|
sources = /* @__PURE__ */ new Set();
|
|
466
|
+
sourceBytes = /* @__PURE__ */ new Map();
|
|
302
467
|
revision = 0;
|
|
303
468
|
chain = Promise.resolve();
|
|
304
469
|
busy = false;
|
|
470
|
+
userPaused = false;
|
|
471
|
+
queuedBytes = 0;
|
|
472
|
+
maxPausedPcmBytes = 32 * 1024 * 1024;
|
|
305
473
|
constructor(callbacks) {
|
|
306
474
|
this.callbacks = callbacks;
|
|
307
475
|
}
|
|
476
|
+
setMaxPausedPcmBytes(value) {
|
|
477
|
+
this.maxPausedPcmBytes = Number.isFinite(value) && value > 0 ? value : 32 * 1024 * 1024;
|
|
478
|
+
}
|
|
479
|
+
async pause() {
|
|
480
|
+
this.userPaused = true;
|
|
481
|
+
if (this.context !== null && this.context.state === "running") await this.context.suspend();
|
|
482
|
+
}
|
|
483
|
+
async resume() {
|
|
484
|
+
if (this.context !== null && this.context.state !== "running") await this.context.resume();
|
|
485
|
+
this.userPaused = false;
|
|
486
|
+
}
|
|
308
487
|
enqueue(base64) {
|
|
309
488
|
const revision = this.revision;
|
|
310
489
|
const run = this.chain.then(() => this.schedule(base64, revision));
|
|
@@ -315,10 +494,13 @@ var PcmAudioQueue = class {
|
|
|
315
494
|
this.revision += 1;
|
|
316
495
|
this.scheduledAt = 0;
|
|
317
496
|
this.chain = Promise.resolve();
|
|
497
|
+
this.userPaused = false;
|
|
498
|
+
this.queuedBytes = 0;
|
|
318
499
|
for (const source of this.sources) try {
|
|
319
500
|
source.stop();
|
|
320
501
|
} catch {}
|
|
321
502
|
this.sources.clear();
|
|
503
|
+
this.sourceBytes.clear();
|
|
322
504
|
this.setBusy(false);
|
|
323
505
|
}
|
|
324
506
|
async dispose() {
|
|
@@ -332,7 +514,7 @@ var PcmAudioQueue = class {
|
|
|
332
514
|
const bytes = Uint8Array.from(atob(base64), (character) => character.charCodeAt(0));
|
|
333
515
|
if (bytes.byteLength < 2) return;
|
|
334
516
|
const context = this.getContext();
|
|
335
|
-
if (context.state !== "running") await context.resume();
|
|
517
|
+
if (context.state !== "running" && !this.userPaused) await context.resume();
|
|
336
518
|
if (revision !== this.revision) return;
|
|
337
519
|
const sampleCount = Math.floor(bytes.byteLength / 2);
|
|
338
520
|
const buffer = context.createBuffer(1, sampleCount, 24e3);
|
|
@@ -344,16 +526,23 @@ var PcmAudioQueue = class {
|
|
|
344
526
|
source.connect(context.destination);
|
|
345
527
|
const startAt = Math.max(context.currentTime + .03, this.scheduledAt);
|
|
346
528
|
this.scheduledAt = startAt + buffer.duration;
|
|
529
|
+
if (this.userPaused && this.queuedBytes + bytes.byteLength > this.maxPausedPcmBytes) throw new Error("pcm-pause-buffer-limit");
|
|
347
530
|
this.sources.add(source);
|
|
531
|
+
this.sourceBytes.set(source, bytes.byteLength);
|
|
532
|
+
this.queuedBytes += bytes.byteLength;
|
|
348
533
|
source.addEventListener("ended", () => {
|
|
349
534
|
if (revision !== this.revision) return;
|
|
350
535
|
this.sources.delete(source);
|
|
536
|
+
this.queuedBytes -= this.sourceBytes.get(source) ?? 0;
|
|
537
|
+
this.sourceBytes.delete(source);
|
|
351
538
|
if (this.sources.size === 0) this.setBusy(false);
|
|
352
539
|
}, { once: true });
|
|
353
540
|
try {
|
|
354
541
|
source.start(startAt);
|
|
355
542
|
} catch (error) {
|
|
356
543
|
this.sources.delete(source);
|
|
544
|
+
this.queuedBytes -= this.sourceBytes.get(source) ?? 0;
|
|
545
|
+
this.sourceBytes.delete(source);
|
|
357
546
|
throw error;
|
|
358
547
|
}
|
|
359
548
|
this.setBusy(true);
|
|
@@ -374,12 +563,11 @@ var PcmAudioQueue = class {
|
|
|
374
563
|
//#region src/client/live-speech-controller.ts
|
|
375
564
|
function pcmDeltaFromSse(data) {
|
|
376
565
|
if (data === "[DONE]") return null;
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
}
|
|
566
|
+
const value = JSON.parse(data);
|
|
567
|
+
const upstreamError = typeof value.error === "string" ? value.error : value.error?.message;
|
|
568
|
+
if (upstreamError !== void 0) throw new Error(upstreamError);
|
|
569
|
+
const pcm = value.choices?.[0]?.delta?.audio?.data;
|
|
570
|
+
return typeof pcm === "string" && pcm.length > 0 ? pcm : null;
|
|
383
571
|
}
|
|
384
572
|
var LiveSpeechController = class {
|
|
385
573
|
audio = new PcmAudioQueue({
|
|
@@ -402,10 +590,33 @@ var LiveSpeechController = class {
|
|
|
402
590
|
requestBusy = false;
|
|
403
591
|
audioBusy = false;
|
|
404
592
|
blockedTurn = null;
|
|
593
|
+
completed = null;
|
|
405
594
|
onStateChange = null;
|
|
406
595
|
setStateChangeListener(listener) {
|
|
407
596
|
this.onStateChange = listener;
|
|
408
597
|
}
|
|
598
|
+
setMaxPausedPcmBytes(value) {
|
|
599
|
+
this.audio.setMaxPausedPcmBytes(value);
|
|
600
|
+
}
|
|
601
|
+
async pause(sessionId) {
|
|
602
|
+
if (this.sessionId !== sessionId || this.status !== "playing") return false;
|
|
603
|
+
await this.audio.pause();
|
|
604
|
+
this.setStatus("paused");
|
|
605
|
+
return true;
|
|
606
|
+
}
|
|
607
|
+
async resume(sessionId) {
|
|
608
|
+
if (this.sessionId !== sessionId || this.status !== "paused") return false;
|
|
609
|
+
try {
|
|
610
|
+
await this.audio.resume();
|
|
611
|
+
this.setStatus("playing");
|
|
612
|
+
return true;
|
|
613
|
+
} catch {
|
|
614
|
+
this.setStatus("error");
|
|
615
|
+
this.replaceQueue();
|
|
616
|
+
this.audio.stop();
|
|
617
|
+
return false;
|
|
618
|
+
}
|
|
619
|
+
}
|
|
409
620
|
activateSession(sessionId) {
|
|
410
621
|
if (this.sessionId === sessionId) return;
|
|
411
622
|
this.cancel();
|
|
@@ -432,6 +643,20 @@ var LiveSpeechController = class {
|
|
|
432
643
|
this.observed = text;
|
|
433
644
|
this.drain(false);
|
|
434
645
|
}
|
|
646
|
+
/** Stream one already-completed preset-model reply as PCM, falling back only before playback starts. */
|
|
647
|
+
playCompleted(sessionId, messageId, text, fallback) {
|
|
648
|
+
if (this.sessionId !== sessionId || text.length === 0) return;
|
|
649
|
+
this.resetState();
|
|
650
|
+
this.completed = {
|
|
651
|
+
sessionId,
|
|
652
|
+
messageId,
|
|
653
|
+
audioStarted: false,
|
|
654
|
+
fallback
|
|
655
|
+
};
|
|
656
|
+
this.messageId = messageId;
|
|
657
|
+
this.setStatus("loading");
|
|
658
|
+
this.queue.enqueue(text);
|
|
659
|
+
}
|
|
435
660
|
finish(sessionId, final) {
|
|
436
661
|
const key = `${sessionId}:${final.turn}:${final.step}`;
|
|
437
662
|
if (this.blockedTurn === `${sessionId}:${final.turn}`) {
|
|
@@ -450,8 +675,8 @@ var LiveSpeechController = class {
|
|
|
450
675
|
this.handled.add(key);
|
|
451
676
|
}
|
|
452
677
|
stop(sessionId) {
|
|
453
|
-
if (this.sessionId !== sessionId || this.
|
|
454
|
-
this.blockedTurn = `${sessionId}:${this.active.turn}`;
|
|
678
|
+
if (this.sessionId !== sessionId || this.status !== "loading" && this.status !== "playing") return false;
|
|
679
|
+
if (this.active !== null) this.blockedTurn = `${sessionId}:${this.active.turn}`;
|
|
455
680
|
this.resetState();
|
|
456
681
|
return true;
|
|
457
682
|
}
|
|
@@ -482,6 +707,7 @@ var LiveSpeechController = class {
|
|
|
482
707
|
this.beginSegment(next, true);
|
|
483
708
|
}
|
|
484
709
|
beginSegment(next, preserveMessageId) {
|
|
710
|
+
this.completed = null;
|
|
485
711
|
this.active = next;
|
|
486
712
|
this.observed = "";
|
|
487
713
|
this.consumed = 0;
|
|
@@ -495,16 +721,17 @@ var LiveSpeechController = class {
|
|
|
495
721
|
this.observed = "";
|
|
496
722
|
this.consumed = 0;
|
|
497
723
|
this.pendingText = "";
|
|
498
|
-
this.messageId = null;
|
|
499
724
|
this.setStatus("idle");
|
|
725
|
+
this.messageId = null;
|
|
726
|
+
this.completed = null;
|
|
500
727
|
}
|
|
501
728
|
cursorKey(cursor) {
|
|
502
729
|
return `${cursor.sessionId}:${cursor.turn}:${cursor.step}`;
|
|
503
730
|
}
|
|
504
731
|
drain(flush) {
|
|
505
|
-
const { sentences, remainder } = splitCompletedTtsSentences(this.observed.slice(this.consumed));
|
|
506
|
-
const ready = flush && remainder.trim().length > 0 ? [...sentences, remainder] : sentences;
|
|
507
|
-
this.consumed +=
|
|
732
|
+
const { sentences, remainder, consumed, inCode } = splitCompletedTtsSentences(this.observed.slice(this.consumed));
|
|
733
|
+
const ready = flush && !inCode && remainder.trim().length > 0 ? [...sentences, remainder] : sentences;
|
|
734
|
+
this.consumed += consumed;
|
|
508
735
|
if (flush) this.consumed = this.observed.length;
|
|
509
736
|
for (const sentence of ready) this.stageSentence(sentence, false);
|
|
510
737
|
if (flush) this.stageSentence("", true);
|
|
@@ -553,6 +780,18 @@ var LiveSpeechController = class {
|
|
|
553
780
|
const reader = response.body.getReader();
|
|
554
781
|
const decoder = new TextDecoder();
|
|
555
782
|
let pending = "";
|
|
783
|
+
let receivedPcm = false;
|
|
784
|
+
const consume = async (events) => {
|
|
785
|
+
for (const event of events) {
|
|
786
|
+
if (!this.isCurrentStream(generation, signal)) return;
|
|
787
|
+
const pcm = pcmDeltaFromSse(event);
|
|
788
|
+
if (pcm !== null) {
|
|
789
|
+
await this.audio.enqueue(pcm);
|
|
790
|
+
receivedPcm = true;
|
|
791
|
+
if (!this.isCurrentStream(generation, signal)) return;
|
|
792
|
+
}
|
|
793
|
+
}
|
|
794
|
+
};
|
|
556
795
|
try {
|
|
557
796
|
while (this.isCurrentStream(generation, signal)) {
|
|
558
797
|
const result = await reader.read();
|
|
@@ -560,23 +799,26 @@ var LiveSpeechController = class {
|
|
|
560
799
|
pending += decoder.decode(result.value, { stream: true });
|
|
561
800
|
const parsed = parseSseRecords(pending);
|
|
562
801
|
pending = parsed.remainder;
|
|
563
|
-
|
|
564
|
-
if (!this.isCurrentStream(generation, signal)) return;
|
|
565
|
-
const pcm = pcmDeltaFromSse(event);
|
|
566
|
-
if (pcm !== null) {
|
|
567
|
-
await this.audio.enqueue(pcm);
|
|
568
|
-
if (!this.isCurrentStream(generation, signal)) return;
|
|
569
|
-
}
|
|
570
|
-
}
|
|
802
|
+
await consume(parsed.events);
|
|
571
803
|
}
|
|
804
|
+
pending += decoder.decode();
|
|
805
|
+
if (pending.trim().length > 0) await consume(parseSseRecords(`${pending}\n\n`).events);
|
|
572
806
|
} finally {
|
|
573
807
|
reader.releaseLock();
|
|
574
808
|
}
|
|
809
|
+
if (!receivedPcm && this.isCurrentStream(generation, signal)) throw new Error("stream-audio-empty");
|
|
575
810
|
} catch (error) {
|
|
576
811
|
if (this.isCurrentStream(generation, signal)) throw error;
|
|
577
812
|
}
|
|
578
813
|
}
|
|
579
814
|
handleStreamError(error) {
|
|
815
|
+
const completed = this.completed;
|
|
816
|
+
if (completed !== null && !completed.audioStarted) {
|
|
817
|
+
const fallback = completed.fallback;
|
|
818
|
+
this.resetState();
|
|
819
|
+
fallback();
|
|
820
|
+
return;
|
|
821
|
+
}
|
|
580
822
|
if (this.active !== null) this.blockedTurn = `${this.active.sessionId}:${this.active.turn}`;
|
|
581
823
|
this.setStatus("error");
|
|
582
824
|
this.replaceQueue();
|
|
@@ -588,6 +830,7 @@ var LiveSpeechController = class {
|
|
|
588
830
|
setStatus(status) {
|
|
589
831
|
if (this.status === status) return;
|
|
590
832
|
this.status = status;
|
|
833
|
+
if (status === "playing" && this.completed !== null) this.completed.audioStarted = true;
|
|
591
834
|
this.reportStatus();
|
|
592
835
|
}
|
|
593
836
|
reportStatus() {
|
|
@@ -612,6 +855,8 @@ var PlaybackController = class {
|
|
|
612
855
|
completedSessions = /* @__PURE__ */ new Set();
|
|
613
856
|
completedMessages = /* @__PURE__ */ new Map();
|
|
614
857
|
current = null;
|
|
858
|
+
segmentQueue = [];
|
|
859
|
+
segmentedState = null;
|
|
615
860
|
request = null;
|
|
616
861
|
generation = 0;
|
|
617
862
|
activeSessionId = null;
|
|
@@ -624,6 +869,7 @@ var PlaybackController = class {
|
|
|
624
869
|
if (this.activeSessionId === sessionId) return;
|
|
625
870
|
this.generation += 1;
|
|
626
871
|
this.stopCurrent();
|
|
872
|
+
this.segmentedState = null;
|
|
627
873
|
this.liveSessions.clear();
|
|
628
874
|
this.completedSessions.clear();
|
|
629
875
|
this.completedMessages.clear();
|
|
@@ -632,6 +878,7 @@ var PlaybackController = class {
|
|
|
632
878
|
}
|
|
633
879
|
cancelPlayback(sessionId) {
|
|
634
880
|
if (this.activeSessionId !== sessionId) return;
|
|
881
|
+
this.segmentedState = null;
|
|
635
882
|
this.generation += 1;
|
|
636
883
|
this.stopCurrent();
|
|
637
884
|
this.publish(this.emptyView());
|
|
@@ -640,6 +887,7 @@ var PlaybackController = class {
|
|
|
640
887
|
if (this.activeSessionId !== sessionId) return;
|
|
641
888
|
this.generation += 1;
|
|
642
889
|
this.stopCurrent();
|
|
890
|
+
this.segmentedState = null;
|
|
643
891
|
this.liveSessions.clear();
|
|
644
892
|
this.completedSessions.clear();
|
|
645
893
|
this.completedMessages.clear();
|
|
@@ -681,6 +929,124 @@ var PlaybackController = class {
|
|
|
681
929
|
error: status === "error" ? "play-failed" : null
|
|
682
930
|
});
|
|
683
931
|
}
|
|
932
|
+
pauseSegmented(sessionId, messageId) {
|
|
933
|
+
if (this.activeSessionId !== sessionId || this.view.source !== "segmented" || this.view.messageId !== messageId) return;
|
|
934
|
+
this.generation += 1;
|
|
935
|
+
this.stopCurrent();
|
|
936
|
+
this.publish({
|
|
937
|
+
sessionId,
|
|
938
|
+
messageId,
|
|
939
|
+
source: "segmented",
|
|
940
|
+
status: "paused",
|
|
941
|
+
error: null
|
|
942
|
+
});
|
|
943
|
+
}
|
|
944
|
+
async segmented(sessionId, messageId, text, automatic) {
|
|
945
|
+
if (this.activeSessionId !== sessionId) return;
|
|
946
|
+
const previous = this.segmentedState;
|
|
947
|
+
const resume = previous !== null && previous.sessionId === sessionId && previous.messageId === messageId;
|
|
948
|
+
this.stopCurrent();
|
|
949
|
+
const segments = resume ? previous.segments : splitTtsSegments(text);
|
|
950
|
+
const startIndex = resume ? previous.index : 0;
|
|
951
|
+
if (segments.length === 0) {
|
|
952
|
+
this.publish({
|
|
953
|
+
sessionId,
|
|
954
|
+
messageId,
|
|
955
|
+
source: "segmented",
|
|
956
|
+
status: "error",
|
|
957
|
+
error: "no-text"
|
|
958
|
+
});
|
|
959
|
+
return;
|
|
960
|
+
}
|
|
961
|
+
this.segmentedState = {
|
|
962
|
+
sessionId,
|
|
963
|
+
messageId,
|
|
964
|
+
segments,
|
|
965
|
+
index: startIndex
|
|
966
|
+
};
|
|
967
|
+
const generation = ++this.generation;
|
|
968
|
+
const controller = new AbortController();
|
|
969
|
+
this.request = controller;
|
|
970
|
+
this.publish({
|
|
971
|
+
sessionId,
|
|
972
|
+
messageId,
|
|
973
|
+
source: "segmented",
|
|
974
|
+
status: "loading",
|
|
975
|
+
error: null
|
|
976
|
+
});
|
|
977
|
+
try {
|
|
978
|
+
const synthesize = async (segment) => {
|
|
979
|
+
let lastError = null;
|
|
980
|
+
for (let attempt = 0; attempt < 2; attempt += 1) try {
|
|
981
|
+
const response = await fetch(TTS_ROUTE, {
|
|
982
|
+
method: "POST",
|
|
983
|
+
headers: { "content-type": "application/json" },
|
|
984
|
+
body: JSON.stringify({
|
|
985
|
+
text: segment,
|
|
986
|
+
format: "wav"
|
|
987
|
+
}),
|
|
988
|
+
signal: controller.signal
|
|
989
|
+
});
|
|
990
|
+
if (!response.ok) throw new Error(`segment-request-${response.status}`);
|
|
991
|
+
return await response.blob();
|
|
992
|
+
} catch (error) {
|
|
993
|
+
lastError = error;
|
|
994
|
+
}
|
|
995
|
+
throw lastError instanceof Error ? lastError : /* @__PURE__ */ new Error("segment-request-failed");
|
|
996
|
+
};
|
|
997
|
+
let nextAudio = synthesize(segments[startIndex]);
|
|
998
|
+
for (let index = startIndex; index < segments.length; index += 1) {
|
|
999
|
+
const blob = await nextAudio;
|
|
1000
|
+
if (generation !== this.generation || this.activeSessionId !== sessionId) return;
|
|
1001
|
+
if (this.segmentedState !== null) this.segmentedState.index = index;
|
|
1002
|
+
if (index + 1 < segments.length) nextAudio = synthesize(segments[index + 1]);
|
|
1003
|
+
const audio = new Audio(URL.createObjectURL(blob));
|
|
1004
|
+
this.segmentQueue.push(audio);
|
|
1005
|
+
await new Promise((resolve, reject) => {
|
|
1006
|
+
const cleanup = () => {
|
|
1007
|
+
audio.removeEventListener("ended", ended);
|
|
1008
|
+
audio.removeEventListener("error", failed);
|
|
1009
|
+
};
|
|
1010
|
+
const ended = () => {
|
|
1011
|
+
cleanup();
|
|
1012
|
+
URL.revokeObjectURL(audio.src);
|
|
1013
|
+
resolve();
|
|
1014
|
+
};
|
|
1015
|
+
const failed = () => {
|
|
1016
|
+
cleanup();
|
|
1017
|
+
URL.revokeObjectURL(audio.src);
|
|
1018
|
+
reject(/* @__PURE__ */ new Error("segment-play-failed"));
|
|
1019
|
+
};
|
|
1020
|
+
audio.addEventListener("ended", ended);
|
|
1021
|
+
audio.addEventListener("error", failed);
|
|
1022
|
+
audio.play().then(() => {
|
|
1023
|
+
if (generation === this.generation && this.activeSessionId === sessionId) this.publish({
|
|
1024
|
+
sessionId,
|
|
1025
|
+
messageId,
|
|
1026
|
+
source: "segmented",
|
|
1027
|
+
status: "playing",
|
|
1028
|
+
error: null
|
|
1029
|
+
});
|
|
1030
|
+
}).catch(() => reject(/* @__PURE__ */ new Error(automatic ? "autoplay-blocked" : "play-failed")));
|
|
1031
|
+
});
|
|
1032
|
+
this.segmentQueue = this.segmentQueue.filter((item) => item !== audio);
|
|
1033
|
+
}
|
|
1034
|
+
if (generation === this.generation && this.activeSessionId === sessionId) {
|
|
1035
|
+
this.segmentedState = null;
|
|
1036
|
+
this.publish(this.emptyView());
|
|
1037
|
+
}
|
|
1038
|
+
} catch (error) {
|
|
1039
|
+
if (!controller.signal.aborted && generation === this.generation && this.activeSessionId === sessionId) this.publish({
|
|
1040
|
+
sessionId,
|
|
1041
|
+
messageId,
|
|
1042
|
+
source: "segmented",
|
|
1043
|
+
status: "error",
|
|
1044
|
+
error: error instanceof Error ? error.message : String(error)
|
|
1045
|
+
});
|
|
1046
|
+
} finally {
|
|
1047
|
+
if (generation === this.generation) this.request = null;
|
|
1048
|
+
}
|
|
1049
|
+
}
|
|
684
1050
|
async toggle(sessionId, messageId, text, automatic) {
|
|
685
1051
|
if (this.activeSessionId !== sessionId) return;
|
|
686
1052
|
if (this.view.source === "complete" && this.view.sessionId === sessionId && this.view.messageId === messageId && this.current !== null) {
|
|
@@ -818,6 +1184,7 @@ var PlaybackController = class {
|
|
|
818
1184
|
dispose() {
|
|
819
1185
|
this.generation += 1;
|
|
820
1186
|
this.stopCurrent();
|
|
1187
|
+
this.segmentedState = null;
|
|
821
1188
|
this.liveSessions.clear();
|
|
822
1189
|
this.completedSessions.clear();
|
|
823
1190
|
this.completedMessages.clear();
|
|
@@ -827,6 +1194,11 @@ var PlaybackController = class {
|
|
|
827
1194
|
stopCurrent() {
|
|
828
1195
|
this.request?.abort();
|
|
829
1196
|
this.request = null;
|
|
1197
|
+
for (const audio of this.segmentQueue) {
|
|
1198
|
+
audio.pause();
|
|
1199
|
+
URL.revokeObjectURL(audio.src);
|
|
1200
|
+
}
|
|
1201
|
+
this.segmentQueue = [];
|
|
830
1202
|
if (this.current !== null) this.releaseCurrentAudio(this.current.audio);
|
|
831
1203
|
}
|
|
832
1204
|
releaseCurrentAudio(audio) {
|
|
@@ -871,10 +1243,12 @@ function decodeSettings(value) {
|
|
|
871
1243
|
if (typeof value.voice === "string") decoded.voice = value.voice;
|
|
872
1244
|
if (typeof value.voiceDesignPrompt === "string") decoded.voiceDesignPrompt = value.voiceDesignPrompt;
|
|
873
1245
|
if (typeof value.voiceDesignCustomPrompt === "string") decoded.voiceDesignCustomPrompt = value.voiceDesignCustomPrompt;
|
|
874
|
-
if (
|
|
1246
|
+
if (TTS_FORMATS.includes(value.format)) decoded.format = value.format;
|
|
1247
|
+
if (TTS_VOICE_DESIGN_PLAYBACK_MODES.includes(value.voiceDesignPlaybackMode)) decoded.voiceDesignPlaybackMode = value.voiceDesignPlaybackMode;
|
|
875
1248
|
if (typeof value.autoPlay === "boolean") decoded.autoPlay = value.autoPlay;
|
|
876
1249
|
if (typeof value.maxTextLength === "number") decoded.maxTextLength = value.maxTextLength;
|
|
877
1250
|
if (typeof value.requestTimeoutMs === "number") decoded.requestTimeoutMs = value.requestTimeoutMs;
|
|
1251
|
+
if (typeof value.maxPausedPcmBytes === "number") decoded.maxPausedPcmBytes = value.maxPausedPcmBytes;
|
|
878
1252
|
return decoded;
|
|
879
1253
|
}
|
|
880
1254
|
function useSettingsSnapshot(scope) {
|
|
@@ -929,6 +1303,7 @@ function messageLiveIdentity(snapshot, messageId) {
|
|
|
929
1303
|
/** Own the active-session boundary and feed its partial assistant output into realtime speech. */
|
|
930
1304
|
function SessionPlaybackObserver({ sessionId, session, playback, live, settings }) {
|
|
931
1305
|
const resolvedSettings = resolveTtsSettings(useSettingsSnapshot(settings).value);
|
|
1306
|
+
live.setMaxPausedPcmBytes(resolvedSettings.maxPausedPcmBytes);
|
|
932
1307
|
const active = (0, react.useRef)(null);
|
|
933
1308
|
const wasRunning = (0, react.useRef)(session.running);
|
|
934
1309
|
const runArmed = (0, react.useRef)(!session.running);
|
|
@@ -962,7 +1337,7 @@ function SessionPlaybackObserver({ sessionId, session, playback, live, settings
|
|
|
962
1337
|
active.current = null;
|
|
963
1338
|
}
|
|
964
1339
|
playback.observeSession(sessionId, session.running && runArmed.current, latestMessageId);
|
|
965
|
-
if (!resolvedSettings.enabled || !resolvedSettings.autoPlay || resolvedSettings.model !== "mimo-v2.5-tts") {
|
|
1340
|
+
if (!resolvedSettings.enabled || !resolvedSettings.autoPlay || resolvedSettings.model !== "mimo-v2.5-tts" || resolvedSettings.format !== "pcm") {
|
|
966
1341
|
live.cancelSession(sessionId);
|
|
967
1342
|
active.current = null;
|
|
968
1343
|
if (session.running) runArmed.current = false;
|
|
@@ -995,6 +1370,7 @@ function SessionPlaybackObserver({ sessionId, session, playback, live, settings
|
|
|
995
1370
|
playback,
|
|
996
1371
|
resolvedSettings.autoPlay,
|
|
997
1372
|
resolvedSettings.enabled,
|
|
1373
|
+
resolvedSettings.format,
|
|
998
1374
|
resolvedSettings.model,
|
|
999
1375
|
session,
|
|
1000
1376
|
sessionId,
|
|
@@ -1012,11 +1388,28 @@ function ReadAloudAction({ sessionId, messageId, useSession, playback, live, set
|
|
|
1012
1388
|
}));
|
|
1013
1389
|
const text = message.text;
|
|
1014
1390
|
const settingsSnapshot = useSettingsSnapshot(settings);
|
|
1391
|
+
const resolvedSettings = resolveTtsSettings(settingsSnapshot.value);
|
|
1015
1392
|
const view = (0, react.useSyncExternalStore)(playback.subscribe, playback.getSnapshot, playback.getSnapshot);
|
|
1393
|
+
const playCompletedReply = (automatic) => {
|
|
1394
|
+
if (resolvedSettings.model === "mimo-v2.5-tts-voicedesign" && resolvedSettings.voiceDesignPlaybackMode === "segmented") {
|
|
1395
|
+
live.cancelSession(sessionId);
|
|
1396
|
+
playback.segmented(sessionId, messageId, text, automatic);
|
|
1397
|
+
return;
|
|
1398
|
+
}
|
|
1399
|
+
if (resolvedSettings.model === "mimo-v2.5-tts" && resolvedSettings.format === "pcm") {
|
|
1400
|
+
playback.cancelPlayback(sessionId);
|
|
1401
|
+
live.playCompleted(sessionId, messageId, text, () => {
|
|
1402
|
+
playback.toggle(sessionId, messageId, text, automatic);
|
|
1403
|
+
});
|
|
1404
|
+
return;
|
|
1405
|
+
}
|
|
1406
|
+
live.cancelSession(sessionId);
|
|
1407
|
+
playback.toggle(sessionId, messageId, text, automatic);
|
|
1408
|
+
};
|
|
1016
1409
|
(0, react.useEffect)(() => {
|
|
1017
1410
|
if (text.length === 0 || settingsSnapshot.value?.enabled !== true || settingsSnapshot.value?.autoPlay !== true || live.hasHandled(sessionId, message.identity) || message.running || message.latestMessageId !== messageId || message.time === null || message.time < playback.autoPlayArmedAt) return;
|
|
1018
1411
|
const cancel = window.setTimeout(() => {
|
|
1019
|
-
if (!live.hasHandled(sessionId, message.identity) && playback.claimAutomaticPlayback(sessionId, messageId))
|
|
1412
|
+
if (!live.hasHandled(sessionId, message.identity) && playback.claimAutomaticPlayback(sessionId, messageId)) playCompletedReply(true);
|
|
1020
1413
|
}, 0);
|
|
1021
1414
|
return () => window.clearTimeout(cancel);
|
|
1022
1415
|
}, [
|
|
@@ -1027,6 +1420,9 @@ function ReadAloudAction({ sessionId, messageId, useSession, playback, live, set
|
|
|
1027
1420
|
message.time,
|
|
1028
1421
|
messageId,
|
|
1029
1422
|
playback,
|
|
1423
|
+
resolvedSettings.format,
|
|
1424
|
+
resolvedSettings.model,
|
|
1425
|
+
resolvedSettings.voiceDesignPlaybackMode,
|
|
1030
1426
|
sessionId,
|
|
1031
1427
|
settingsSnapshot.value?.autoPlay,
|
|
1032
1428
|
settingsSnapshot.value?.enabled,
|
|
@@ -1050,13 +1446,24 @@ function ReadAloudAction({ sessionId, messageId, useSession, playback, live, set
|
|
|
1050
1446
|
"aria-pressed": status === "playing" || liveActive,
|
|
1051
1447
|
disabled: status === "loading" && !liveActive,
|
|
1052
1448
|
onClick: () => {
|
|
1053
|
-
if (mine && source === "live"
|
|
1054
|
-
|
|
1055
|
-
|
|
1449
|
+
if (mine && source === "live") {
|
|
1450
|
+
if (status === "loading") {
|
|
1451
|
+
live.stop(sessionId);
|
|
1452
|
+
playback.cancelPlayback(sessionId);
|
|
1453
|
+
} else if (status === "playing") live.pause(sessionId);
|
|
1454
|
+
else if (status === "paused") live.resume(sessionId);
|
|
1455
|
+
return;
|
|
1456
|
+
}
|
|
1457
|
+
if (mine && source === "complete") {
|
|
1458
|
+
playback.toggle(sessionId, messageId, text, false);
|
|
1459
|
+
return;
|
|
1460
|
+
}
|
|
1461
|
+
if (mine && source === "segmented") {
|
|
1462
|
+
if (status === "playing" || status === "loading") playback.pauseSegmented(sessionId, messageId);
|
|
1463
|
+
else if (status === "paused") playback.segmented(sessionId, messageId, text, false);
|
|
1056
1464
|
return;
|
|
1057
1465
|
}
|
|
1058
|
-
|
|
1059
|
-
playback.toggle(sessionId, messageId, text, false);
|
|
1466
|
+
playCompletedReply(false);
|
|
1060
1467
|
},
|
|
1061
1468
|
children: status === "loading" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__deepseek_ai_dsh_client_ui_primitives.IconLoadingOutline16, { className: "xmimo-tts-spin" }) : status === "playing" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__deepseek_ai_dsh_client_ui_primitives.IconPauseOutline16, {}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__deepseek_ai_dsh_client_ui_primitives.IconPlayOutline16, {})
|
|
1062
1469
|
})
|
|
@@ -1082,9 +1489,9 @@ const zh = {
|
|
|
1082
1489
|
"error.request": "语音生成失败。",
|
|
1083
1490
|
"error.play": "浏览器阻止了自动播放,请点击朗读按钮。",
|
|
1084
1491
|
"settings.title": "语音朗读 (Xiaomi MiMo)",
|
|
1085
|
-
"settings.description": "
|
|
1492
|
+
"settings.description": "在对话中使用 Xiaomi MiMo TTS 生成并播放语音。",
|
|
1086
1493
|
"settings.enabled": "显示朗读按钮",
|
|
1087
|
-
"settings.enabledHint": "
|
|
1494
|
+
"settings.enabledHint": "关闭后不会显示朗读按钮,也不会自动播报。",
|
|
1088
1495
|
"settings.apiKey": "API Key",
|
|
1089
1496
|
"settings.apiKeyStatus": "只有输入新值并保存时才会替换现有密钥。",
|
|
1090
1497
|
"settings.apiKeyConfigured": "已配置",
|
|
@@ -1096,14 +1503,25 @@ const zh = {
|
|
|
1096
1503
|
"settings.model": "TTS 模型",
|
|
1097
1504
|
"settings.presetModel": "预置音色模型 (mimo-v2.5-tts)",
|
|
1098
1505
|
"settings.voiceDesignModel": "自定义音色模型 (mimo-v2.5-tts-voicedesign)",
|
|
1099
|
-
"settings.modelAutoPlayHintPreset": "
|
|
1506
|
+
"settings.modelAutoPlayHintPreset": "预置音色的播放方式由音频格式决定。",
|
|
1100
1507
|
"settings.modelAutoPlayHintVoiceDesign": "自定义音色仅支持在回复完成后自动播放。",
|
|
1101
1508
|
"settings.voice": "内置音色",
|
|
1509
|
+
"settings.format": "音频格式",
|
|
1510
|
+
"settings.formatPcm": "PCM(流式播放)",
|
|
1511
|
+
"settings.formatMp3": "MP3(完整音频)",
|
|
1512
|
+
"settings.formatWav": "WAV(完整音频)",
|
|
1513
|
+
"settings.formatPcmHint": "边生成边播放,支持暂停和继续;首个音频分片前失败时自动回退 MP3。",
|
|
1514
|
+
"settings.formatMp3Hint": "完整生成后播放,文件更小;支持暂停和继续。",
|
|
1515
|
+
"settings.formatWavHint": "完整生成后播放,保留无损音频但文件更大;支持暂停和继续。",
|
|
1102
1516
|
"settings.voiceDesignPrompt": "自定义音色描述",
|
|
1103
1517
|
"settings.customVoiceOption": "自定义",
|
|
1104
1518
|
"settings.customVoiceSummary": "手动编写音色描述",
|
|
1105
1519
|
"settings.voiceDesignPromptHint": "按“年龄段 + 性别、声音质感、语速节奏、情绪底色”描述声音本身;不写场景或动作。",
|
|
1106
|
-
"settings.
|
|
1520
|
+
"settings.voiceDesignPlaybackMode": "朗读方式",
|
|
1521
|
+
"settings.voiceDesignPlaybackComplete": "完整朗读",
|
|
1522
|
+
"settings.voiceDesignPlaybackSegmented": "分片朗读",
|
|
1523
|
+
"settings.voiceDesignPlaybackCompleteHint": "整篇生成后播放,语调连续性更好。长文本会出现模型幻觉。",
|
|
1524
|
+
"settings.voiceDesignPlaybackSegmentedHint": "适合长文本,分段生成、更快播放。但会重新推导音色细节,语调连续性略差。",
|
|
1107
1525
|
"settings.save": "保存",
|
|
1108
1526
|
"settings.saving": "保存中…",
|
|
1109
1527
|
"settings.saved": "已保存",
|
|
@@ -1152,14 +1570,25 @@ const en = {
|
|
|
1152
1570
|
"settings.model": "TTS model",
|
|
1153
1571
|
"settings.presetModel": "Preset voices (mimo-v2.5-tts)",
|
|
1154
1572
|
"settings.voiceDesignModel": "Custom voice design (mimo-v2.5-tts-voicedesign)",
|
|
1155
|
-
"settings.modelAutoPlayHintPreset": "
|
|
1573
|
+
"settings.modelAutoPlayHintPreset": "The selected audio format controls preset-voice playback.",
|
|
1156
1574
|
"settings.modelAutoPlayHintVoiceDesign": "Custom voice design supports automatic playback only after the reply is complete.",
|
|
1157
1575
|
"settings.voice": "Built-in voice",
|
|
1576
|
+
"settings.format": "Audio format",
|
|
1577
|
+
"settings.formatPcm": "PCM (streaming)",
|
|
1578
|
+
"settings.formatMp3": "MP3 (complete audio)",
|
|
1579
|
+
"settings.formatWav": "WAV (complete audio)",
|
|
1580
|
+
"settings.formatPcmHint": "Plays chunks as they arrive for a shorter wait; supports pause and resume. Falls back to MP3 if streaming fails before the first audio chunk.",
|
|
1581
|
+
"settings.formatMp3Hint": "Plays after the complete file is generated. Smaller file size; supports pause and resume.",
|
|
1582
|
+
"settings.formatWavHint": "Plays after the complete lossless file is generated. Larger file size; supports pause and resume.",
|
|
1158
1583
|
"settings.voiceDesignPrompt": "Custom voice description",
|
|
1159
1584
|
"settings.customVoiceOption": "Custom",
|
|
1160
1585
|
"settings.customVoiceSummary": "Write a custom voice description",
|
|
1161
1586
|
"settings.voiceDesignPromptHint": "Describe the voice itself with age/gender, texture, pace, and emotional baseline; avoid scenes or actions.",
|
|
1162
|
-
"settings.
|
|
1587
|
+
"settings.voiceDesignPlaybackMode": "Read-aloud mode",
|
|
1588
|
+
"settings.voiceDesignPlaybackComplete": "Complete",
|
|
1589
|
+
"settings.voiceDesignPlaybackSegmented": "Segmented",
|
|
1590
|
+
"settings.voiceDesignPlaybackCompleteHint": "Generates the entire reply before playback for better continuity.",
|
|
1591
|
+
"settings.voiceDesignPlaybackSegmentedHint": "Generates and plays semantic segments in order; better for long text and faster start.",
|
|
1163
1592
|
"settings.save": "Save",
|
|
1164
1593
|
"settings.saving": "Saving…",
|
|
1165
1594
|
"settings.saved": "Saved",
|
|
@@ -1183,6 +1612,149 @@ const en = {
|
|
|
1183
1612
|
"settings.collapse": "Collapse settings"
|
|
1184
1613
|
};
|
|
1185
1614
|
|
|
1615
|
+
//#endregion
|
|
1616
|
+
//#region src/client/built-in-voice-picker.tsx
|
|
1617
|
+
function VoiceAvatar({ preset }) {
|
|
1618
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("img", {
|
|
1619
|
+
className: "xmimo-tts-builtin-voice-avatar",
|
|
1620
|
+
src: `${TTS_VOICE_ASSET_ROUTE}/${preset.id}.webp`,
|
|
1621
|
+
alt: "",
|
|
1622
|
+
width: 36,
|
|
1623
|
+
height: 36,
|
|
1624
|
+
loading: "lazy",
|
|
1625
|
+
"aria-hidden": "true"
|
|
1626
|
+
});
|
|
1627
|
+
}
|
|
1628
|
+
function SelectedCheck() {
|
|
1629
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("svg", {
|
|
1630
|
+
className: "xmimo-tts-builtin-voice-check",
|
|
1631
|
+
viewBox: "0 0 16 16",
|
|
1632
|
+
"aria-hidden": "true",
|
|
1633
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("circle", {
|
|
1634
|
+
cx: "8",
|
|
1635
|
+
cy: "8",
|
|
1636
|
+
r: "7"
|
|
1637
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", { d: "m4.8 8.1 2 2 4.4-4.5" })]
|
|
1638
|
+
});
|
|
1639
|
+
}
|
|
1640
|
+
function BuiltInVoicePicker({ value, disabled, label, onChange }) {
|
|
1641
|
+
const [open, setOpen] = (0, react.useState)(false);
|
|
1642
|
+
const rootRef = (0, react.useRef)(null);
|
|
1643
|
+
const triggerRef = (0, react.useRef)(null);
|
|
1644
|
+
const optionRefs = (0, react.useRef)([]);
|
|
1645
|
+
const listboxId = (0, react.useId)();
|
|
1646
|
+
const selectedIndex = TTS_VOICE_PRESETS.findIndex((preset) => preset.value === value);
|
|
1647
|
+
const selected = TTS_VOICE_PRESETS[selectedIndex < 0 ? 0 : selectedIndex];
|
|
1648
|
+
(0, react.useEffect)(() => {
|
|
1649
|
+
if (!open) return;
|
|
1650
|
+
const closeOnOutsidePointer = (event) => {
|
|
1651
|
+
if (event.target instanceof Node && !rootRef.current?.contains(event.target)) setOpen(false);
|
|
1652
|
+
};
|
|
1653
|
+
document.addEventListener("pointerdown", closeOnOutsidePointer);
|
|
1654
|
+
return () => document.removeEventListener("pointerdown", closeOnOutsidePointer);
|
|
1655
|
+
}, [open]);
|
|
1656
|
+
(0, react.useEffect)(() => {
|
|
1657
|
+
if (disabled) setOpen(false);
|
|
1658
|
+
}, [disabled]);
|
|
1659
|
+
const focusOption = (index) => {
|
|
1660
|
+
const normalized = (index + TTS_VOICE_PRESETS.length) % TTS_VOICE_PRESETS.length;
|
|
1661
|
+
requestAnimationFrame(() => optionRefs.current[normalized]?.focus());
|
|
1662
|
+
};
|
|
1663
|
+
const choose = (next) => {
|
|
1664
|
+
onChange(next);
|
|
1665
|
+
setOpen(false);
|
|
1666
|
+
requestAnimationFrame(() => triggerRef.current?.focus());
|
|
1667
|
+
};
|
|
1668
|
+
const handleTriggerKeyDown = (event) => {
|
|
1669
|
+
if (event.key === "ArrowDown" || event.key === "ArrowUp") {
|
|
1670
|
+
event.preventDefault();
|
|
1671
|
+
setOpen(true);
|
|
1672
|
+
focusOption(selectedIndex < 0 ? 0 : selectedIndex);
|
|
1673
|
+
} else if (event.key === "Home") {
|
|
1674
|
+
event.preventDefault();
|
|
1675
|
+
setOpen(true);
|
|
1676
|
+
focusOption(0);
|
|
1677
|
+
} else if (event.key === "End") {
|
|
1678
|
+
event.preventDefault();
|
|
1679
|
+
setOpen(true);
|
|
1680
|
+
focusOption(TTS_VOICE_PRESETS.length - 1);
|
|
1681
|
+
}
|
|
1682
|
+
};
|
|
1683
|
+
const handleOptionKeyDown = (event, index) => {
|
|
1684
|
+
if (event.key === "ArrowRight" || event.key === "ArrowDown") {
|
|
1685
|
+
event.preventDefault();
|
|
1686
|
+
focusOption(index + 1);
|
|
1687
|
+
} else if (event.key === "ArrowLeft" || event.key === "ArrowUp") {
|
|
1688
|
+
event.preventDefault();
|
|
1689
|
+
focusOption(index - 1);
|
|
1690
|
+
} else if (event.key === "Home") {
|
|
1691
|
+
event.preventDefault();
|
|
1692
|
+
focusOption(0);
|
|
1693
|
+
} else if (event.key === "End") {
|
|
1694
|
+
event.preventDefault();
|
|
1695
|
+
focusOption(TTS_VOICE_PRESETS.length - 1);
|
|
1696
|
+
} else if (event.key === "Escape") {
|
|
1697
|
+
event.preventDefault();
|
|
1698
|
+
setOpen(false);
|
|
1699
|
+
triggerRef.current?.focus();
|
|
1700
|
+
} else if (event.key === "Tab") setOpen(false);
|
|
1701
|
+
};
|
|
1702
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1703
|
+
className: "xmimo-tts-builtin-voice-picker",
|
|
1704
|
+
ref: rootRef,
|
|
1705
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
1706
|
+
ref: triggerRef,
|
|
1707
|
+
type: "button",
|
|
1708
|
+
className: "xmimo-tts-builtin-voice-trigger",
|
|
1709
|
+
disabled,
|
|
1710
|
+
"aria-label": label,
|
|
1711
|
+
"aria-haspopup": "listbox",
|
|
1712
|
+
"aria-expanded": open,
|
|
1713
|
+
"aria-controls": open ? listboxId : void 0,
|
|
1714
|
+
onClick: () => {
|
|
1715
|
+
setOpen((current) => !current);
|
|
1716
|
+
},
|
|
1717
|
+
onKeyDown: handleTriggerKeyDown,
|
|
1718
|
+
children: [
|
|
1719
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(VoiceAvatar, { preset: selected }),
|
|
1720
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
1721
|
+
className: "xmimo-tts-builtin-voice-copy",
|
|
1722
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("strong", { children: selected.value }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("small", { children: selected.summary })]
|
|
1723
|
+
}),
|
|
1724
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(__deepseek_ai_dsh_client_ui_primitives.IconChevronDownOutline14, { className: open ? "xmimo-tts-voice-picker-chevron xmimo-tts-voice-picker-chevron-open" : "xmimo-tts-voice-picker-chevron" })
|
|
1725
|
+
]
|
|
1726
|
+
}), open ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1727
|
+
id: listboxId,
|
|
1728
|
+
className: "xmimo-tts-builtin-voice-menu",
|
|
1729
|
+
role: "listbox",
|
|
1730
|
+
"aria-label": label,
|
|
1731
|
+
children: TTS_VOICE_PRESETS.map((preset, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
1732
|
+
ref: (node) => {
|
|
1733
|
+
optionRefs.current[index] = node;
|
|
1734
|
+
},
|
|
1735
|
+
type: "button",
|
|
1736
|
+
role: "option",
|
|
1737
|
+
"aria-selected": preset.value === value,
|
|
1738
|
+
className: preset.value === value ? "xmimo-tts-builtin-voice-option xmimo-tts-builtin-voice-option-selected" : "xmimo-tts-builtin-voice-option",
|
|
1739
|
+
onClick: () => {
|
|
1740
|
+
choose(preset.value);
|
|
1741
|
+
},
|
|
1742
|
+
onKeyDown: (event) => {
|
|
1743
|
+
handleOptionKeyDown(event, index);
|
|
1744
|
+
},
|
|
1745
|
+
children: [
|
|
1746
|
+
preset.value === value ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SelectedCheck, {}) : null,
|
|
1747
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(VoiceAvatar, { preset }),
|
|
1748
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
1749
|
+
className: "xmimo-tts-builtin-voice-copy",
|
|
1750
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("strong", { children: preset.value }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("small", { children: preset.summary })]
|
|
1751
|
+
})
|
|
1752
|
+
]
|
|
1753
|
+
}, preset.id))
|
|
1754
|
+
}) : null]
|
|
1755
|
+
});
|
|
1756
|
+
}
|
|
1757
|
+
|
|
1186
1758
|
//#endregion
|
|
1187
1759
|
//#region src/client/voice-design-picker.tsx
|
|
1188
1760
|
const CUSTOM_VOICE_DESIGN_OPTION = "__custom__";
|
|
@@ -1191,7 +1763,7 @@ function isPresetVoiceDesignPrompt(value) {
|
|
|
1191
1763
|
}
|
|
1192
1764
|
function VoicePresetAvatar({ preset }) {
|
|
1193
1765
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("img", {
|
|
1194
|
-
className: "xmimo-tts-voice-avatar",
|
|
1766
|
+
className: "xmimo-tts-builtin-voice-avatar",
|
|
1195
1767
|
src: `${TTS_VOICE_DESIGN_ASSET_ROUTE}/${preset.id}.webp`,
|
|
1196
1768
|
alt: "",
|
|
1197
1769
|
width: 40,
|
|
@@ -1202,7 +1774,7 @@ function VoicePresetAvatar({ preset }) {
|
|
|
1202
1774
|
}
|
|
1203
1775
|
function CustomVoiceAvatar() {
|
|
1204
1776
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1205
|
-
className: "xmimo-tts-voice-avatar xmimo-tts-custom-voice-avatar",
|
|
1777
|
+
className: "xmimo-tts-builtin-voice-avatar xmimo-tts-custom-voice-avatar",
|
|
1206
1778
|
"aria-hidden": "true",
|
|
1207
1779
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("svg", {
|
|
1208
1780
|
viewBox: "0 0 40 40",
|
|
@@ -1219,6 +1791,18 @@ function CustomVoiceAvatar() {
|
|
|
1219
1791
|
})
|
|
1220
1792
|
});
|
|
1221
1793
|
}
|
|
1794
|
+
function VoicePresetCheck() {
|
|
1795
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("svg", {
|
|
1796
|
+
className: "xmimo-tts-builtin-voice-check",
|
|
1797
|
+
viewBox: "0 0 14 14",
|
|
1798
|
+
"aria-hidden": "true",
|
|
1799
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("circle", {
|
|
1800
|
+
cx: "7",
|
|
1801
|
+
cy: "7",
|
|
1802
|
+
r: "7"
|
|
1803
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", { d: "m3.5 7 2.1 2.1 4.9-4.7" })]
|
|
1804
|
+
});
|
|
1805
|
+
}
|
|
1222
1806
|
function VoiceDesignPresetPicker({ value, disabled, label, customLabel, customSummary, onChange }) {
|
|
1223
1807
|
const [open, setOpen] = (0, react.useState)(false);
|
|
1224
1808
|
const rootRef = (0, react.useRef)(null);
|
|
@@ -1288,7 +1872,7 @@ function VoiceDesignPresetPicker({ value, disabled, label, customLabel, customSu
|
|
|
1288
1872
|
} else if (event.key === "Tab") setOpen(false);
|
|
1289
1873
|
};
|
|
1290
1874
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1291
|
-
className: "xmimo-tts-voice-picker",
|
|
1875
|
+
className: "xmimo-tts-voice-picker xmimo-tts-builtin-voice-picker",
|
|
1292
1876
|
ref: rootRef,
|
|
1293
1877
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
1294
1878
|
ref: triggerRef,
|
|
@@ -1313,7 +1897,7 @@ function VoiceDesignPresetPicker({ value, disabled, label, customLabel, customSu
|
|
|
1313
1897
|
]
|
|
1314
1898
|
}), open ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1315
1899
|
id: listboxId,
|
|
1316
|
-
className: "xmimo-tts-voice-picker-menu",
|
|
1900
|
+
className: "xmimo-tts-voice-picker-menu xmimo-tts-builtin-voice-menu",
|
|
1317
1901
|
role: "listbox",
|
|
1318
1902
|
"aria-label": label,
|
|
1319
1903
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
@@ -1323,17 +1907,21 @@ function VoiceDesignPresetPicker({ value, disabled, label, customLabel, customSu
|
|
|
1323
1907
|
type: "button",
|
|
1324
1908
|
role: "option",
|
|
1325
1909
|
"aria-selected": selectedPreset === void 0,
|
|
1326
|
-
className: selectedPreset === void 0 ? "xmimo-tts-voice-option xmimo-tts-voice-option-selected" : "xmimo-tts-voice-option",
|
|
1910
|
+
className: selectedPreset === void 0 ? "xmimo-tts-builtin-voice-option xmimo-tts-builtin-voice-option-selected xmimo-tts-builtin-voice-option-custom" : "xmimo-tts-builtin-voice-option xmimo-tts-builtin-voice-option-custom",
|
|
1327
1911
|
onClick: () => {
|
|
1328
1912
|
choose(CUSTOM_VOICE_DESIGN_OPTION);
|
|
1329
1913
|
},
|
|
1330
1914
|
onKeyDown: (event) => {
|
|
1331
1915
|
handleOptionKeyDown(event, 0);
|
|
1332
1916
|
},
|
|
1333
|
-
children: [
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1917
|
+
children: [
|
|
1918
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(CustomVoiceAvatar, {}),
|
|
1919
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
1920
|
+
className: "xmimo-tts-voice-option-copy",
|
|
1921
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("strong", { children: customLabel }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("small", { children: customSummary })]
|
|
1922
|
+
}),
|
|
1923
|
+
selectedPreset === void 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(VoicePresetCheck, {}) : null
|
|
1924
|
+
]
|
|
1337
1925
|
}), TTS_VOICE_DESIGN_PRESETS.map((preset, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
1338
1926
|
ref: (node) => {
|
|
1339
1927
|
optionRefs.current[index + 1] = node;
|
|
@@ -1341,17 +1929,21 @@ function VoiceDesignPresetPicker({ value, disabled, label, customLabel, customSu
|
|
|
1341
1929
|
type: "button",
|
|
1342
1930
|
role: "option",
|
|
1343
1931
|
"aria-selected": selectedPreset?.id === preset.id,
|
|
1344
|
-
className: selectedPreset?.id === preset.id ? "xmimo-tts-voice-option xmimo-tts-voice-option-selected" : "xmimo-tts-voice-option",
|
|
1932
|
+
className: selectedPreset?.id === preset.id ? "xmimo-tts-builtin-voice-option xmimo-tts-builtin-voice-option-selected" : "xmimo-tts-builtin-voice-option",
|
|
1345
1933
|
onClick: () => {
|
|
1346
1934
|
choose(preset.prompt);
|
|
1347
1935
|
},
|
|
1348
1936
|
onKeyDown: (event) => {
|
|
1349
1937
|
handleOptionKeyDown(event, index + 1);
|
|
1350
1938
|
},
|
|
1351
|
-
children: [
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1939
|
+
children: [
|
|
1940
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(VoicePresetAvatar, { preset }),
|
|
1941
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
1942
|
+
className: "xmimo-tts-voice-option-copy",
|
|
1943
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("strong", { children: preset.label }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("small", { children: preset.summary })]
|
|
1944
|
+
}),
|
|
1945
|
+
selectedPreset?.id === preset.id ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(VoicePresetCheck, {}) : null
|
|
1946
|
+
]
|
|
1355
1947
|
}, preset.id))]
|
|
1356
1948
|
}) : null]
|
|
1357
1949
|
});
|
|
@@ -1366,7 +1958,8 @@ const EDITABLE_SETTING_FIELDS = [
|
|
|
1366
1958
|
"voice",
|
|
1367
1959
|
"voiceDesignPrompt",
|
|
1368
1960
|
"voiceDesignCustomPrompt",
|
|
1369
|
-
"format"
|
|
1961
|
+
"format",
|
|
1962
|
+
"voiceDesignPlaybackMode"
|
|
1370
1963
|
];
|
|
1371
1964
|
const RELEASES_URL = "https://github.com/ppy-web/dsh-plugin-xiaomi-mimo-tts/releases";
|
|
1372
1965
|
function hostRoute(path) {
|
|
@@ -1413,9 +2006,10 @@ function SettingsCard({ scope, t }) {
|
|
|
1413
2006
|
const [autoPlay, setAutoPlay] = (0, react.useState)(initial.autoPlay);
|
|
1414
2007
|
const [model, setModel] = (0, react.useState)(initial.model);
|
|
1415
2008
|
const [voice, setVoice] = (0, react.useState)(initial.voice);
|
|
2009
|
+
const [format, setFormat] = (0, react.useState)(initial.format);
|
|
2010
|
+
const [voiceDesignPlaybackMode, setVoiceDesignPlaybackMode] = (0, react.useState)(initial.voiceDesignPlaybackMode);
|
|
1416
2011
|
const [voiceDesignPrompt, setVoiceDesignPrompt] = (0, react.useState)(initial.voiceDesignPrompt);
|
|
1417
2012
|
const [voiceDesignCustomPrompt, setVoiceDesignCustomPrompt] = (0, react.useState)(initial.voiceDesignCustomPrompt);
|
|
1418
|
-
const [format, setFormat] = (0, react.useState)(initial.format);
|
|
1419
2013
|
const [changes, setChanges] = (0, react.useState)({});
|
|
1420
2014
|
const [state, setState] = (0, react.useState)("idle");
|
|
1421
2015
|
const [uninstallState, setUninstallState] = (0, react.useState)("idle");
|
|
@@ -1431,7 +2025,8 @@ function SettingsCard({ scope, t }) {
|
|
|
1431
2025
|
voice,
|
|
1432
2026
|
voiceDesignPrompt,
|
|
1433
2027
|
voiceDesignCustomPrompt,
|
|
1434
|
-
format
|
|
2028
|
+
format,
|
|
2029
|
+
voiceDesignPlaybackMode
|
|
1435
2030
|
};
|
|
1436
2031
|
const acceptedValue = (field) => {
|
|
1437
2032
|
const raw = value?.[field];
|
|
@@ -1498,9 +2093,10 @@ function SettingsCard({ scope, t }) {
|
|
|
1498
2093
|
setAutoPlay(next.autoPlay);
|
|
1499
2094
|
setModel(next.model);
|
|
1500
2095
|
setVoice(next.voice);
|
|
2096
|
+
setFormat(next.format);
|
|
2097
|
+
setVoiceDesignPlaybackMode(next.voiceDesignPlaybackMode);
|
|
1501
2098
|
setVoiceDesignPrompt(next.voiceDesignPrompt);
|
|
1502
2099
|
setVoiceDesignCustomPrompt(next.voiceDesignCustomPrompt);
|
|
1503
|
-
setFormat(next.format);
|
|
1504
2100
|
setChanges({});
|
|
1505
2101
|
}, [dirty, value]);
|
|
1506
2102
|
if (snapshot.status === "unavailable") return null;
|
|
@@ -1517,9 +2113,10 @@ function SettingsCard({ scope, t }) {
|
|
|
1517
2113
|
if (field === "autoPlay") setAutoPlay(base.autoPlay);
|
|
1518
2114
|
if (field === "model") setModel(base.model);
|
|
1519
2115
|
if (field === "voice") setVoice(base.voice);
|
|
2116
|
+
if (field === "format") setFormat(base.format);
|
|
2117
|
+
if (field === "voiceDesignPlaybackMode") setVoiceDesignPlaybackMode(base.voiceDesignPlaybackMode);
|
|
1520
2118
|
if (field === "voiceDesignPrompt") setVoiceDesignPrompt(base.voiceDesignPrompt);
|
|
1521
2119
|
if (field === "voiceDesignCustomPrompt") setVoiceDesignCustomPrompt(base.voiceDesignCustomPrompt);
|
|
1522
|
-
if (field === "format") setFormat(base.format);
|
|
1523
2120
|
};
|
|
1524
2121
|
const discard = () => {
|
|
1525
2122
|
const next = resolveTtsSettings(scope.getSnapshot().value);
|
|
@@ -1527,9 +2124,10 @@ function SettingsCard({ scope, t }) {
|
|
|
1527
2124
|
setAutoPlay(next.autoPlay);
|
|
1528
2125
|
setModel(next.model);
|
|
1529
2126
|
setVoice(next.voice);
|
|
2127
|
+
setFormat(next.format);
|
|
2128
|
+
setVoiceDesignPlaybackMode(next.voiceDesignPlaybackMode);
|
|
1530
2129
|
setVoiceDesignPrompt(next.voiceDesignPrompt);
|
|
1531
2130
|
setVoiceDesignCustomPrompt(next.voiceDesignCustomPrompt);
|
|
1532
|
-
setFormat(next.format);
|
|
1533
2131
|
setApiKey("");
|
|
1534
2132
|
setChanges({});
|
|
1535
2133
|
setState("idle");
|
|
@@ -1583,16 +2181,9 @@ function SettingsCard({ scope, t }) {
|
|
|
1583
2181
|
children: [
|
|
1584
2182
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
1585
2183
|
className: "xmimo-tts-card-head-text",
|
|
1586
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.
|
|
2184
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1587
2185
|
className: "xmimo-tts-card-title",
|
|
1588
|
-
children:
|
|
1589
|
-
t("settings.title"),
|
|
1590
|
-
" ",
|
|
1591
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("small", {
|
|
1592
|
-
className: "xmimo-tts-version",
|
|
1593
|
-
children: ["v", TTS_VERSION]
|
|
1594
|
-
})
|
|
1595
|
-
]
|
|
2186
|
+
children: t("settings.title")
|
|
1596
2187
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1597
2188
|
className: "xmimo-tts-card-description",
|
|
1598
2189
|
children: t("settings.description")
|
|
@@ -1652,90 +2243,6 @@ function SettingsCard({ scope, t }) {
|
|
|
1652
2243
|
})
|
|
1653
2244
|
]
|
|
1654
2245
|
}),
|
|
1655
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1656
|
-
className: "xmimo-tts-switch-row xmimo-tts-wide",
|
|
1657
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
1658
|
-
className: "xmimo-tts-checkbox-row",
|
|
1659
|
-
children: [
|
|
1660
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1661
|
-
className: "xmimo-tts-switch-copy",
|
|
1662
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SettingFieldHeading, {
|
|
1663
|
-
label: t("settings.enabled"),
|
|
1664
|
-
overriddenLabel: t("settings.overridden"),
|
|
1665
|
-
resetLabel: t("settings.reset"),
|
|
1666
|
-
overridden: false,
|
|
1667
|
-
resettable: false,
|
|
1668
|
-
disabled: !snapshot.writable,
|
|
1669
|
-
onReset: () => {
|
|
1670
|
-
resetField("enabled");
|
|
1671
|
-
}
|
|
1672
|
-
})
|
|
1673
|
-
}),
|
|
1674
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
1675
|
-
type: "checkbox",
|
|
1676
|
-
checked: enabled,
|
|
1677
|
-
disabled: !snapshot.writable,
|
|
1678
|
-
onChange: (event) => {
|
|
1679
|
-
const next = event.target.checked;
|
|
1680
|
-
setEnabled(next);
|
|
1681
|
-
if (!next) {
|
|
1682
|
-
setAutoPlay(false);
|
|
1683
|
-
setChanges((current) => ({
|
|
1684
|
-
...current,
|
|
1685
|
-
enabled: { kind: "set" },
|
|
1686
|
-
autoPlay: { kind: "set" }
|
|
1687
|
-
}));
|
|
1688
|
-
} else markChange("enabled");
|
|
1689
|
-
setState("idle");
|
|
1690
|
-
}
|
|
1691
|
-
}),
|
|
1692
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1693
|
-
className: "xmimo-tts-switch-control",
|
|
1694
|
-
"aria-hidden": "true"
|
|
1695
|
-
})
|
|
1696
|
-
]
|
|
1697
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
1698
|
-
className: "xmimo-tts-checkbox-row",
|
|
1699
|
-
children: [
|
|
1700
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1701
|
-
className: "xmimo-tts-switch-copy",
|
|
1702
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SettingFieldHeading, {
|
|
1703
|
-
label: t("settings.autoPlay"),
|
|
1704
|
-
overriddenLabel: t("settings.overridden"),
|
|
1705
|
-
resetLabel: t("settings.reset"),
|
|
1706
|
-
overridden: false,
|
|
1707
|
-
resettable: false,
|
|
1708
|
-
disabled: !snapshot.writable,
|
|
1709
|
-
onReset: () => {
|
|
1710
|
-
resetField("autoPlay");
|
|
1711
|
-
}
|
|
1712
|
-
})
|
|
1713
|
-
}),
|
|
1714
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
1715
|
-
type: "checkbox",
|
|
1716
|
-
checked: enabled && autoPlay,
|
|
1717
|
-
disabled: !snapshot.writable,
|
|
1718
|
-
onChange: (event) => {
|
|
1719
|
-
const next = event.target.checked;
|
|
1720
|
-
setAutoPlay(next);
|
|
1721
|
-
if (next) {
|
|
1722
|
-
setEnabled(true);
|
|
1723
|
-
setChanges((current) => ({
|
|
1724
|
-
...current,
|
|
1725
|
-
autoPlay: { kind: "set" },
|
|
1726
|
-
enabled: { kind: "set" }
|
|
1727
|
-
}));
|
|
1728
|
-
} else markChange("autoPlay");
|
|
1729
|
-
setState("idle");
|
|
1730
|
-
}
|
|
1731
|
-
}),
|
|
1732
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1733
|
-
className: "xmimo-tts-switch-control",
|
|
1734
|
-
"aria-hidden": "true"
|
|
1735
|
-
})
|
|
1736
|
-
]
|
|
1737
|
-
})]
|
|
1738
|
-
}),
|
|
1739
2246
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1740
2247
|
className: "xmimo-tts-model xmimo-tts-wide",
|
|
1741
2248
|
children: [
|
|
@@ -1810,58 +2317,186 @@ function SettingsCard({ scope, t }) {
|
|
|
1810
2317
|
setState("idle");
|
|
1811
2318
|
}
|
|
1812
2319
|
}),
|
|
1813
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("small", { children: t("settings.voiceDesignPromptHint") })
|
|
2320
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("small", { children: t("settings.voiceDesignPromptHint") }),
|
|
2321
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2322
|
+
className: "xmimo-tts-format xmimo-tts-wide",
|
|
2323
|
+
children: [
|
|
2324
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(SettingFieldHeading, {
|
|
2325
|
+
label: t("settings.voiceDesignPlaybackMode"),
|
|
2326
|
+
overriddenLabel: t("settings.overridden"),
|
|
2327
|
+
resetLabel: t("settings.reset"),
|
|
2328
|
+
overridden: fieldOverridden("voiceDesignPlaybackMode"),
|
|
2329
|
+
resettable: true,
|
|
2330
|
+
disabled: !snapshot.writable,
|
|
2331
|
+
onReset: () => {
|
|
2332
|
+
resetField("voiceDesignPlaybackMode");
|
|
2333
|
+
}
|
|
2334
|
+
}),
|
|
2335
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2336
|
+
className: "xmimo-tts-format-options",
|
|
2337
|
+
role: "radiogroup",
|
|
2338
|
+
"aria-label": t("settings.voiceDesignPlaybackMode"),
|
|
2339
|
+
children: TTS_VOICE_DESIGN_PLAYBACK_MODES.map((item) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
2340
|
+
className: voiceDesignPlaybackMode === item ? "xmimo-tts-format-option xmimo-tts-format-option-selected" : "xmimo-tts-format-option",
|
|
2341
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
2342
|
+
type: "radio",
|
|
2343
|
+
name: "xmimo-tts-voice-design-playback",
|
|
2344
|
+
value: item,
|
|
2345
|
+
checked: voiceDesignPlaybackMode === item,
|
|
2346
|
+
disabled: !snapshot.writable,
|
|
2347
|
+
onChange: () => {
|
|
2348
|
+
setVoiceDesignPlaybackMode(item);
|
|
2349
|
+
markChange("voiceDesignPlaybackMode");
|
|
2350
|
+
}
|
|
2351
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t(item === "complete" ? "settings.voiceDesignPlaybackComplete" : "settings.voiceDesignPlaybackSegmented") })]
|
|
2352
|
+
}, item))
|
|
2353
|
+
}),
|
|
2354
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("small", { children: t(voiceDesignPlaybackMode === "complete" ? "settings.voiceDesignPlaybackCompleteHint" : "settings.voiceDesignPlaybackSegmentedHint") })
|
|
2355
|
+
]
|
|
2356
|
+
})
|
|
1814
2357
|
]
|
|
1815
2358
|
}) : null,
|
|
1816
|
-
model === "mimo-v2.5-tts" ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1817
|
-
className: "xmimo-tts-
|
|
1818
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.
|
|
2359
|
+
model === "mimo-v2.5-tts" ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2360
|
+
className: "xmimo-tts-voice xmimo-tts-wide",
|
|
2361
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(SettingFieldHeading, {
|
|
1819
2362
|
label: t("settings.voice"),
|
|
1820
2363
|
overriddenLabel: t("settings.overridden"),
|
|
1821
2364
|
resetLabel: t("settings.reset"),
|
|
1822
|
-
overridden:
|
|
1823
|
-
resettable:
|
|
2365
|
+
overridden: fieldOverridden("voice"),
|
|
2366
|
+
resettable: true,
|
|
1824
2367
|
disabled: !snapshot.writable,
|
|
1825
2368
|
onReset: () => {
|
|
1826
2369
|
resetField("voice");
|
|
1827
2370
|
}
|
|
1828
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
2371
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(BuiltInVoicePicker, {
|
|
1829
2372
|
value: voice,
|
|
1830
2373
|
disabled: !snapshot.writable,
|
|
1831
|
-
|
|
1832
|
-
|
|
2374
|
+
label: t("settings.voice"),
|
|
2375
|
+
onChange: (next) => {
|
|
2376
|
+
setVoice(next);
|
|
1833
2377
|
markChange("voice");
|
|
1834
|
-
},
|
|
1835
|
-
children: TTS_VOICES.map((item) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
|
|
1836
|
-
value: item,
|
|
1837
|
-
children: item
|
|
1838
|
-
}, item))
|
|
1839
|
-
})] }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(SettingFieldHeading, {
|
|
1840
|
-
label: t("settings.format"),
|
|
1841
|
-
overriddenLabel: t("settings.overridden"),
|
|
1842
|
-
resetLabel: t("settings.reset"),
|
|
1843
|
-
overridden: false,
|
|
1844
|
-
resettable: false,
|
|
1845
|
-
disabled: !snapshot.writable,
|
|
1846
|
-
onReset: () => {
|
|
1847
|
-
resetField("format");
|
|
1848
2378
|
}
|
|
1849
|
-
})
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
2379
|
+
})]
|
|
2380
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2381
|
+
className: "xmimo-tts-format xmimo-tts-wide",
|
|
2382
|
+
children: [
|
|
2383
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(SettingFieldHeading, {
|
|
2384
|
+
label: t("settings.format"),
|
|
2385
|
+
overriddenLabel: t("settings.overridden"),
|
|
2386
|
+
resetLabel: t("settings.reset"),
|
|
2387
|
+
overridden: fieldOverridden("format"),
|
|
2388
|
+
resettable: true,
|
|
2389
|
+
disabled: !snapshot.writable,
|
|
2390
|
+
onReset: () => {
|
|
2391
|
+
resetField("format");
|
|
2392
|
+
}
|
|
2393
|
+
}),
|
|
2394
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2395
|
+
className: "xmimo-tts-format-options",
|
|
2396
|
+
role: "radiogroup",
|
|
2397
|
+
"aria-label": t("settings.format"),
|
|
2398
|
+
children: TTS_FORMATS.map((item) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
2399
|
+
className: format === item ? "xmimo-tts-format-option xmimo-tts-format-option-selected" : "xmimo-tts-format-option",
|
|
2400
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
2401
|
+
type: "radio",
|
|
2402
|
+
name: "xmimo-tts-format",
|
|
2403
|
+
value: item,
|
|
2404
|
+
checked: format === item,
|
|
2405
|
+
disabled: !snapshot.writable,
|
|
2406
|
+
onChange: () => {
|
|
2407
|
+
setFormat(item);
|
|
2408
|
+
markChange("format");
|
|
2409
|
+
}
|
|
2410
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: item.toUpperCase() })]
|
|
2411
|
+
}, item))
|
|
2412
|
+
}),
|
|
2413
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("small", { children: t(format === "pcm" ? "settings.formatPcmHint" : format === "mp3" ? "settings.formatMp3Hint" : "settings.formatWavHint") })
|
|
2414
|
+
]
|
|
2415
|
+
})] }) : null,
|
|
2416
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2417
|
+
className: "xmimo-tts-switch-row xmimo-tts-wide",
|
|
2418
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
2419
|
+
className: "xmimo-tts-checkbox-row",
|
|
2420
|
+
children: [
|
|
2421
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2422
|
+
className: "xmimo-tts-switch-copy",
|
|
2423
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SettingFieldHeading, {
|
|
2424
|
+
label: t("settings.enabled"),
|
|
2425
|
+
overriddenLabel: t("settings.overridden"),
|
|
2426
|
+
resetLabel: t("settings.reset"),
|
|
2427
|
+
overridden: false,
|
|
2428
|
+
resettable: false,
|
|
2429
|
+
disabled: !snapshot.writable,
|
|
2430
|
+
onReset: () => {
|
|
2431
|
+
resetField("enabled");
|
|
2432
|
+
}
|
|
2433
|
+
})
|
|
2434
|
+
}),
|
|
2435
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
2436
|
+
type: "checkbox",
|
|
2437
|
+
checked: enabled,
|
|
2438
|
+
disabled: !snapshot.writable,
|
|
2439
|
+
onChange: (event) => {
|
|
2440
|
+
const next = event.target.checked;
|
|
2441
|
+
setEnabled(next);
|
|
2442
|
+
if (!next) {
|
|
2443
|
+
setAutoPlay(false);
|
|
2444
|
+
setChanges((current) => ({
|
|
2445
|
+
...current,
|
|
2446
|
+
enabled: { kind: "set" },
|
|
2447
|
+
autoPlay: { kind: "set" }
|
|
2448
|
+
}));
|
|
2449
|
+
} else markChange("enabled");
|
|
2450
|
+
setState("idle");
|
|
2451
|
+
}
|
|
2452
|
+
}),
|
|
2453
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2454
|
+
className: "xmimo-tts-switch-control",
|
|
2455
|
+
"aria-hidden": "true"
|
|
2456
|
+
})
|
|
2457
|
+
]
|
|
2458
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
2459
|
+
className: "xmimo-tts-checkbox-row",
|
|
2460
|
+
children: [
|
|
2461
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2462
|
+
className: "xmimo-tts-switch-copy",
|
|
2463
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SettingFieldHeading, {
|
|
2464
|
+
label: t("settings.autoPlay"),
|
|
2465
|
+
overriddenLabel: t("settings.overridden"),
|
|
2466
|
+
resetLabel: t("settings.reset"),
|
|
2467
|
+
overridden: false,
|
|
2468
|
+
resettable: false,
|
|
2469
|
+
disabled: !snapshot.writable,
|
|
2470
|
+
onReset: () => {
|
|
2471
|
+
resetField("autoPlay");
|
|
2472
|
+
}
|
|
2473
|
+
})
|
|
2474
|
+
}),
|
|
2475
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
2476
|
+
type: "checkbox",
|
|
2477
|
+
checked: enabled && autoPlay,
|
|
2478
|
+
disabled: !snapshot.writable,
|
|
2479
|
+
onChange: (event) => {
|
|
2480
|
+
const next = event.target.checked;
|
|
2481
|
+
setAutoPlay(next);
|
|
2482
|
+
if (next) {
|
|
2483
|
+
setEnabled(true);
|
|
2484
|
+
setChanges((current) => ({
|
|
2485
|
+
...current,
|
|
2486
|
+
autoPlay: { kind: "set" },
|
|
2487
|
+
enabled: { kind: "set" }
|
|
2488
|
+
}));
|
|
2489
|
+
} else markChange("autoPlay");
|
|
2490
|
+
setState("idle");
|
|
2491
|
+
}
|
|
2492
|
+
}),
|
|
2493
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2494
|
+
className: "xmimo-tts-switch-control",
|
|
2495
|
+
"aria-hidden": "true"
|
|
2496
|
+
})
|
|
2497
|
+
]
|
|
2498
|
+
})]
|
|
2499
|
+
})
|
|
1865
2500
|
]
|
|
1866
2501
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1867
2502
|
className: "xmimo-tts-card-actions",
|
|
@@ -1954,11 +2589,14 @@ const CLIENT_STYLES = `
|
|
|
1954
2589
|
.xmimo-tts-inline-error{max-width:220px;color:var(--dsw-alias-state-error-primary,#dc2626);font-size:12px}
|
|
1955
2590
|
.xmimo-tts-api-key-warning{color:var(--dsw-alias-state-error-primary,#dc2626)!important}
|
|
1956
2591
|
.xmimo-tts-card{list-style:none;border:1px solid var(--dsw-alias-border-l2,#e5e7eb);border-radius:12px;color:var(--dsw-alias-label-primary,#1f2328);background:var(--dsw-alias-bg-layer-3,#fff);overflow:hidden;transition:border-color 160ms ease,background 160ms ease}.xmimo-tts-card:hover{border-color:var(--dsw-alias-label-dimmed,#c8ccd4)}.xmimo-tts-card-open{background:var(--dsw-alias-bg-layer-2,#f7f8fa);border-color:var(--dsw-alias-label-dimmed,#c8ccd4)}.xmimo-tts-card-header{appearance:none;display:flex;width:100%;align-items:center;justify-content:space-between;gap:12px;padding:14px 16px;border:0;border-radius:12px;color:inherit;text-align:left;background:transparent;font:inherit;cursor:pointer}.xmimo-tts-card-header:focus-visible{outline:2px solid var(--dsw-alias-brand-primary,#4f6ef7);outline-offset:-2px}.xmimo-tts-card-head-text{display:flex;min-width:0;flex:1;flex-direction:column;gap:4px}.xmimo-tts-card-title{font-size:15px;font-weight:600}.xmimo-tts-card-description{color:var(--dsw-alias-label-tertiary,#8b93a1);font-size:13px;line-height:18px}.xmimo-tts-chevron{flex:none;color:var(--dsw-alias-label-tertiary,#8b93a1);transition:transform 160ms ease}.xmimo-tts-chevron-open{transform:rotate(180deg)}.xmimo-tts-pending{flex:none;border-radius:999px;padding:1px 8px;color:var(--dsw-alias-label-secondary,#5f6875);background:var(--dsw-alias-bg-module-platform,#eef0f3);font-size:11px;font-weight:500;line-height:17px}.xmimo-tts-card-body{border-top:1px solid var(--dsw-alias-border-l2,#e5e7eb);margin:0 16px;padding:0 0 16px}
|
|
1957
|
-
.xmimo-tts-grid{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:0;align-items:start}.xmimo-tts-grid>*{box-sizing:border-box;padding:16px 0;border-top:1px solid var(--dsw-alias-border-l2,#e5e7eb)}.xmimo-tts-grid>:first-child{border-top:0}.xmimo-tts-grid label,.xmimo-tts-api-key,.xmimo-tts-model,.xmimo-tts-voice-design-prompt,.xmimo-tts-
|
|
2592
|
+
.xmimo-tts-grid{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:0;align-items:start}.xmimo-tts-grid>*{box-sizing:border-box;padding:16px 0;border-top:1px solid var(--dsw-alias-border-l2,#e5e7eb)}.xmimo-tts-grid>:first-child{border-top:0}.xmimo-tts-grid label,.xmimo-tts-api-key,.xmimo-tts-model,.xmimo-tts-format,.xmimo-tts-voice-design-prompt,.xmimo-tts-voice{display:flex;min-width:0;flex-direction:column;gap:6px;font-size:13px}.xmimo-tts-grid input,.xmimo-tts-grid select,.xmimo-tts-grid textarea{box-sizing:border-box;width:100%;border:1px solid var(--dsw-alias-border-l2,#e5e7eb);border-radius:8px;padding:8px 10px;color:var(--dsw-alias-label-primary,#1f2328);background:var(--dsw-alias-bg-layer-2,#f3f4f6);font:inherit}.xmimo-tts-grid select{color-scheme:light dark}.xmimo-tts-grid select option{color:var(--dsw-alias-label-primary,#1f2328);background:var(--dsw-alias-bg-layer-1,#fff)}.xmimo-tts-grid select:focus-visible{outline:2px solid var(--dsw-alias-brand-primary,#4f6ef7);outline-offset:1px}.xmimo-tts-grid small{color:var(--dsw-alias-label-tertiary,#8b93a1);line-height:17px}.xmimo-tts-field-heading{display:flex;min-width:0;min-height:20px;flex-direction:row!important;align-items:center;justify-content:space-between;gap:8px}.xmimo-tts-field-label{display:inline-flex;min-width:0;align-items:center;gap:8px}.xmimo-tts-api-key-link{color:var(--dsw-alias-brand-primary,#4f6ef7);font-size:12px;text-decoration:none}.xmimo-tts-api-key-link:hover{text-decoration:underline}.xmimo-tts-field-badges{display:flex!important;flex:none;flex-direction:row!important;align-items:center;gap:8px}.xmimo-tts-overridden{border-radius:999px;padding:1px 7px;color:var(--dsw-alias-label-secondary,#5f6875);background:var(--dsw-alias-bg-module-platform,#eef0f3);font-size:11px;line-height:17px}.xmimo-tts-reset{padding:0;border:0;color:var(--dsw-alias-label-secondary,#5f6875);background:transparent;font:inherit;font-size:12px;cursor:pointer}.xmimo-tts-reset:hover:not(:disabled){color:var(--dsw-alias-label-primary,#1f2328)}.xmimo-tts-reset:disabled{cursor:not-allowed;opacity:.45}.xmimo-tts-api-key-hints{display:flex;min-width:0;gap:8px;align-items:center}.xmimo-tts-api-key-hints small{min-width:0;white-space:nowrap}.xmimo-tts-wide{grid-column:1/-1}.xmimo-tts-switch-row{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:0}.xmimo-tts-switch-row>*:first-child{padding-right:14px}.xmimo-tts-switch-row>*+*{padding-left:14px;border-left:1px solid var(--dsw-alias-border-l2,#e5e7eb)}.xmimo-tts-checkbox-row{position:relative;flex-direction:row!important;align-items:center!important;gap:10px!important;cursor:pointer}.xmimo-tts-switch-copy{display:flex;min-width:0;flex-direction:column;gap:4px}.xmimo-tts-checkbox-row>input{position:absolute;width:1px!important;height:1px;margin:0!important;padding:0!important;overflow:hidden;border:0!important;opacity:0;clip-path:inset(50%)}.xmimo-tts-switch-control{box-sizing:border-box;position:relative;display:inline-block!important;width:36px;height:20px;min-width:36px;flex:none;border:1px solid var(--dsw-alias-border-l2,#c8ccd4);border-radius:999px;background:var(--dsw-alias-bg-module-platform,#e5e7eb);transition:border-color 160ms ease,background 160ms ease}.xmimo-tts-switch-control:after{content:"";position:absolute;top:2px;left:2px;width:14px;height:14px;border-radius:50%;background:var(--dsw-alias-bg-layer-1,#fff);box-shadow:0 1px 3px rgba(15,23,42,.24);transition:transform 160ms ease}.xmimo-tts-checkbox-row>input:checked+.xmimo-tts-switch-control{border-color:var(--dsw-alias-brand-primary,#4f6ef7);background:var(--dsw-alias-brand-primary,#4f6ef7)}.xmimo-tts-checkbox-row>input:checked+.xmimo-tts-switch-control:after{transform:translateX(16px)}.xmimo-tts-checkbox-row>input:focus-visible+.xmimo-tts-switch-control{outline:2px solid var(--dsw-alias-brand-primary,#4f6ef7);outline-offset:2px}.xmimo-tts-checkbox-row>input:disabled+.xmimo-tts-switch-control{cursor:not-allowed;opacity:.45}
|
|
1958
2593
|
.xmimo-tts-voice-picker{display:flex;min-width:0;flex-direction:column;gap:6px}.xmimo-tts-voice-picker-trigger,.xmimo-tts-voice-option{box-sizing:border-box;display:flex;width:100%;min-width:0;align-items:center;gap:10px;border:1px solid var(--dsw-alias-border-l2,#e5e7eb);color:var(--dsw-alias-label-primary,#1f2328);background:var(--dsw-alias-bg-layer-2,#f3f4f6);font:inherit;text-align:left;cursor:pointer}.xmimo-tts-voice-picker-trigger{min-height:54px;border-radius:10px;padding:6px 10px}.xmimo-tts-voice-picker-trigger:hover:not(:disabled){border-color:var(--dsw-alias-label-dimmed,#c8ccd4);background:var(--dsw-alias-interactive-bg-hover,#eef0f3)}.xmimo-tts-voice-picker-trigger:focus-visible,.xmimo-tts-voice-option:focus-visible{outline:2px solid var(--dsw-alias-brand-primary,#4f6ef7);outline-offset:1px}.xmimo-tts-voice-picker-trigger:disabled{cursor:not-allowed;opacity:.55}.xmimo-tts-voice-avatar{box-sizing:border-box;display:block;width:40px;height:40px;flex:none;border:1px solid color-mix(in srgb,var(--dsw-alias-border-l2,#e5e7eb) 80%,transparent);border-radius:50%;object-fit:cover;background:var(--dsw-alias-bg-layer-1,#fff)}.xmimo-tts-custom-voice-avatar{display:grid;place-items:center;color:var(--dsw-alias-brand-primary,#4f6ef7);background:color-mix(in srgb,var(--dsw-alias-brand-primary,#4f6ef7) 12%,var(--dsw-alias-bg-layer-1,#fff))}.xmimo-tts-custom-voice-avatar svg{width:30px;height:30px;overflow:visible}.xmimo-tts-custom-voice-avatar circle{fill:currentColor}.xmimo-tts-custom-voice-avatar path{fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}.xmimo-tts-voice-option-copy{display:flex;min-width:0;flex:1;flex-direction:column;gap:1px}.xmimo-tts-voice-option-copy strong{overflow:hidden;font-size:13px;font-weight:600;line-height:18px;text-overflow:ellipsis;white-space:nowrap}.xmimo-tts-voice-option-copy small{overflow:hidden;font-size:12px;text-overflow:ellipsis;white-space:nowrap}.xmimo-tts-voice-picker-chevron{flex:none;color:var(--dsw-alias-label-tertiary,#8b93a1);transition:transform 160ms ease}.xmimo-tts-voice-picker-chevron-open{transform:rotate(180deg)}.xmimo-tts-voice-picker-menu{display:grid;max-height:310px;overflow:auto;overscroll-behavior:contain;border:1px solid var(--dsw-alias-border-l2,#e5e7eb);border-radius:10px;padding:5px;background:var(--dsw-alias-bg-layer-1,#fff);box-shadow:0 10px 28px rgba(15,23,42,.12)}.xmimo-tts-voice-option{min-height:50px;border:0;border-radius:7px;padding:5px 7px;background:transparent}.xmimo-tts-voice-option:hover,.xmimo-tts-voice-option:focus-visible{background:var(--dsw-alias-interactive-bg-hover,#f3f4f6)}.xmimo-tts-voice-option-selected{background:color-mix(in srgb,var(--dsw-alias-brand-primary,#4f6ef7) 10%,transparent)}
|
|
2594
|
+
.xmimo-tts-builtin-voice-picker{display:flex;min-width:0;flex-direction:column;gap:8px}.xmimo-tts-builtin-voice-trigger,.xmimo-tts-builtin-voice-option{box-sizing:border-box;display:flex;width:100%;min-width:0;align-items:center;gap:10px;border:1px solid var(--dsw-alias-border-l2,#e5e7eb);border-radius:9px;color:var(--dsw-alias-label-primary,#1f2328);background:var(--dsw-alias-bg-layer-1,#fff);font:inherit;text-align:left;cursor:pointer}.xmimo-tts-builtin-voice-trigger{min-height:54px;padding:8px 11px}.xmimo-tts-builtin-voice-trigger:hover:not(:disabled),.xmimo-tts-builtin-voice-option:hover{border-color:var(--dsw-alias-label-dimmed,#c8ccd4);background:var(--dsw-alias-interactive-bg-hover,#f7f7f5)}.xmimo-tts-builtin-voice-trigger:focus-visible,.xmimo-tts-builtin-voice-option:focus-visible{outline:2px solid var(--dsw-alias-brand-primary,#4f6ef7);outline-offset:1px}.xmimo-tts-builtin-voice-trigger:disabled{cursor:not-allowed;opacity:.55}.xmimo-tts-builtin-voice-avatar{box-sizing:border-box;display:block;width:36px;height:36px;flex:none;border-radius:50%;object-fit:cover;background:#f4f2ed}.xmimo-tts-builtin-voice-copy{display:flex;min-width:0;flex:1;flex-direction:column;gap:1px}.xmimo-tts-builtin-voice-copy strong{overflow:hidden;font-size:14px;font-weight:600;line-height:18px;text-overflow:ellipsis;white-space:nowrap}.xmimo-tts-builtin-voice-copy small{overflow:hidden;color:var(--dsw-alias-label-tertiary,#77736b);font-size:12px;line-height:15px;text-overflow:ellipsis;white-space:nowrap}.xmimo-tts-builtin-voice-menu{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px;max-height:320px;overflow:auto;overscroll-behavior:contain;border:1px solid var(--dsw-alias-border-l2,#e5e7eb);border-radius:12px;padding:10px;background:var(--dsw-alias-bg-layer-1,#fff);box-shadow:0 10px 28px rgba(15,23,42,.12)}.xmimo-tts-builtin-voice-option{position:relative;min-height:60px;padding:9px 12px}.xmimo-tts-builtin-voice-option-selected{background:color-mix(in srgb,#dedbd2 24%,var(--dsw-alias-bg-layer-1,#fff))}.xmimo-tts-builtin-voice-check{position:absolute;top:6px;right:6px;width:14px;height:14px}.xmimo-tts-builtin-voice-check circle{fill:#383932}.xmimo-tts-builtin-voice-check path{fill:none;stroke:#fff;stroke-width:1.7;stroke-linecap:round;stroke-linejoin:round}
|
|
1959
2595
|
.xmimo-tts-card-actions{display:flex;align-items:center;justify-content:flex-end;gap:10px;padding-top:12px;border-top:1px solid var(--dsw-alias-border-l2,#e5e7eb);font-size:12px;color:var(--dsw-alias-label-tertiary,#8b93a1)}.xmimo-tts-card-actions button{border:1px solid var(--dsw-alias-brand-primary,#4f6ef7);border-radius:8px;padding:5px 14px;color:var(--dsw-alias-bg-layer-1,#fff);background:var(--dsw-alias-brand-primary,#4f6ef7);cursor:pointer;font:inherit}.xmimo-tts-card-actions button:hover:not(:disabled){filter:brightness(1.08)}.xmimo-tts-card-actions button:disabled{cursor:not-allowed;color:var(--dsw-alias-label-dimmed,#9ca3af);background:var(--dsw-alias-bg-layer-2,#f3f4f6);border-color:var(--dsw-alias-border-l2,#e5e7eb);opacity:1}.xmimo-tts-card-actions .xmimo-tts-update{display:inline-flex;align-items:center;border:1px solid var(--dsw-alias-brand-primary,#4f6ef7);border-radius:8px;padding:5px 14px;color:var(--dsw-alias-brand-primary,#4f6ef7);background:transparent;text-decoration:none}.xmimo-tts-card-actions .xmimo-tts-update:hover{filter:brightness(1.08)}.xmimo-tts-card-actions .xmimo-tts-star{border-color:transparent;color:var(--dsw-alias-brand-primary,#4f6ef7);background:transparent;font-weight:500}.xmimo-tts-card-actions .xmimo-tts-star:hover{text-decoration:underline}.xmimo-tts-card-actions .xmimo-tts-uninstall{margin-right:auto;border-color:#F56C6C;color:#F56C6C;background:transparent}.xmimo-tts-card-actions .xmimo-tts-uninstall:hover:not(:disabled){background:color-mix(in srgb,#F56C6C 10%,transparent)}.xmimo-tts-card-actions .xmimo-tts-uninstall:disabled{border-color:#F56C6C;color:#F56C6C;background:transparent;opacity:.55}.xmimo-tts-uninstall-confirmation{display:flex;align-items:center;gap:8px;margin-right:auto;color:#F56C6C}.xmimo-tts-uninstall-choice{display:inline-flex;overflow:hidden;border:1px solid #F56C6C;border-radius:8px}.xmimo-tts-card-actions .xmimo-tts-uninstall-choice button{border:0;border-radius:0;padding:5px 12px;color:#F56C6C;background:transparent}.xmimo-tts-card-actions .xmimo-tts-uninstall-choice button+button{border-left:1px solid #F56C6C}.xmimo-tts-card-actions .xmimo-tts-uninstall-choice button:hover{filter:none;background:color-mix(in srgb,#F56C6C 10%,transparent)}.xmimo-tts-card-actions .xmimo-tts-discard{border-color:var(--dsw-alias-border-l2,#e5e7eb);color:var(--dsw-alias-label-secondary,#5f6875);background:transparent}.xmimo-tts-card-actions .xmimo-tts-discard:hover:not(:disabled){color:var(--dsw-alias-label-primary,#1f2328);border-color:var(--dsw-alias-label-dimmed,#c8ccd4)}.xmimo-tts-failed{color:var(--dsw-alias-state-error-primary,#dc2626)}.xmimo-tts-version{color:var(--dsw-alias-label-tertiary,#8b93a1);font-size:11px;font-weight:400}
|
|
1960
|
-
@media(max-width:720px){.xmimo-tts-grid{grid-template-columns:1fr}.xmimo-tts-wide{grid-column:auto}.xmimo-tts-switch-row{grid-template-columns:1fr}.xmimo-tts-switch-row>*:first-child{padding-right:0;padding-bottom:16px}.xmimo-tts-switch-row>*+*{padding-top:16px;padding-left:0;border-top:1px solid var(--dsw-alias-border-l2,#e5e7eb);border-left:0}.xmimo-tts-
|
|
2596
|
+
@media(max-width:720px){.xmimo-tts-grid{grid-template-columns:1fr}.xmimo-tts-wide{grid-column:auto}.xmimo-tts-switch-row{grid-template-columns:1fr}.xmimo-tts-switch-row>*:first-child{padding-right:0;padding-bottom:16px}.xmimo-tts-switch-row>*+*{padding-top:16px;padding-left:0;border-top:1px solid var(--dsw-alias-border-l2,#e5e7eb);border-left:0}.xmimo-tts-api-key-hints{flex-wrap:wrap}.xmimo-tts-api-key-hints small{white-space:normal}}@media(max-width:480px){.xmimo-tts-builtin-voice-menu{grid-template-columns:1fr}}
|
|
1961
2597
|
.xmimo-tts-card-actions .xmimo-tts-uninstall{margin-right:0}.xmimo-tts-card-actions .xmimo-tts-star{margin-right:auto}.xmimo-tts-uninstall-confirmation{margin-right:0}
|
|
2598
|
+
.xmimo-tts-format-option-selected{z-index:1;border-color:var(--dsw-alias-brand-primary,#4f6ef7)}.xmimo-tts-format-option{text-transform:uppercase}
|
|
2599
|
+
.xmimo-tts-format-options{display:flex;width:100%;gap:0}.xmimo-tts-format-option{position:relative;flex:1;padding:8px 4px;border:1px solid var(--dsw-alias-border-l2,#e5e7eb);text-align:center;cursor:pointer}.xmimo-tts-format-option:first-child{border-radius:8px 0 0 8px}.xmimo-tts-format-option:last-child{border-radius:0 8px 8px 0}.xmimo-tts-format-option+.xmimo-tts-format-option{border-left:0}.xmimo-tts-format-option input{position:absolute;width:1px;height:1px;opacity:0}.xmimo-tts-format-option-selected{color:var(--dsw-alias-brand-primary,#4f6ef7);font-weight:600}.xmimo-tts-format-option:focus-within{outline:2px solid var(--dsw-alias-brand-primary,#4f6ef7);outline-offset:1px}.xmimo-tts-builtin-voice-option-custom{grid-column:1/-1}
|
|
1962
2600
|
`;
|
|
1963
2601
|
|
|
1964
2602
|
//#endregion
|