dsh-xiaomi-tts 2.2.1 → 2.3.0

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/lib/client.js CHANGED
@@ -37,6 +37,8 @@ const TTS_SETTINGS_NAMESPACE = "xiaomi-mimo-tts";
37
37
  const TTS_ROUTE = "/plugins/xiaomi-mimo-tts/synthesize";
38
38
  /** Same-origin route that proxies MiMo PCM16 server-sent audio chunks. */
39
39
  const TTS_STREAM_ROUTE = "/plugins/xiaomi-mimo-tts/synthesize-stream";
40
+ /** Same-origin prefix used by the Web client to load voice-design preset icons. */
41
+ const TTS_VOICE_DESIGN_ASSET_ROUTE = "/plugins/xiaomi-mimo-tts/voice-presets";
40
42
  /** Supported built-in Xiaomi MiMo voices. */
41
43
  const TTS_VOICES = [
42
44
  "冰糖",
@@ -53,52 +55,58 @@ const TTS_MODELS = ["mimo-v2.5-tts", "mimo-v2.5-tts-voicedesign"];
53
55
  /** Voice-design descriptions adapted from the reference voice-definition page. */
54
56
  const TTS_VOICE_DESIGN_PRESETS = [
55
57
  {
56
- label: "元气少女",
57
- prompt: "年轻女性,明亮高饱和声线,笑意自然外放,咬字灵巧,语速偏快,语调跳跃有活力,情绪积极爽朗。"
58
+ id: "energetic-girl",
59
+ label: "林小满",
60
+ summary: "女 · 16岁 · 元气少女,明亮高饱和声线",
61
+ prompt: "年轻女性15-20岁,普通话,明亮高饱和声线,笑意自然外放,咬字灵巧跳跃,语速偏快,语调上扬有活力,情绪积极爽朗,活力播报风格"
58
62
  },
59
63
  {
60
- label: "邻家女孩",
61
- prompt: "年轻女性,声线柔润清甜,亲近自然不过分撒娇,吐字清晰,语速中等偏快,语调轻松平缓,带一点温柔的生活感。"
64
+ id: "asmr-whisper",
65
+ label: "沈听澜",
66
+ summary: "女 · 19岁 · ASMR低语,轻柔耳语带微弱气息",
67
+ prompt: "女性18-20岁,轻柔耳语带微弱气息,普通话,声线细腻清晰,私密温柔感,安静平和带轻柔低语,语速缓慢音量很轻,私密低语场景。"
62
68
  },
63
69
  {
64
- label: "新闻播报",
65
- prompt: "专业播音女主持音色,成年女性,端庄知性,中低音区稳定饱满,普通话标准,咬字利落,节奏从容,情绪克制而有权威感。"
70
+ id: "gentle-girlfriend",
71
+ label: "张子莯",
72
+ summary: "女 · 22岁 · 温柔女友,声线柔软细腻",
73
+ prompt: "年轻女性16-22岁,声线柔软细腻,低饱和带微微暖意,标准普通话,温柔亲密的邻家风格,语速偏慢,语调轻柔连贯,气息自然流畅,安静私密陪伴场景。"
66
74
  },
67
75
  {
68
- label: "温柔客服",
69
- prompt: "成年女性,音色温暖明净,亲切耐心,吐字柔和清楚,语速适中,句尾轻微上扬,始终保持可靠、专注的服务感。"
76
+ id: "girl-next-door",
77
+ label: "陈念安",
78
+ summary: "女 · 25岁 · 邻家女孩,柔润清甜带撒娇感",
79
+ prompt: "年轻女性20-25岁,柔润清甜带撒娇感,普通话,清澈明亮的少女音,轻松温柔的亲近感,轻松平缓带温柔,中等偏快语速中等音量,生活分享场景。"
70
80
  },
71
81
  {
72
- label: "温柔女友",
73
- prompt: "年轻女性,声线柔软细腻,低饱和且带微微暖意,气息自然,语速偏慢,语调轻柔连贯,亲密但不黏腻。"
82
+ id: "news-anchor",
83
+ label: "顾知微",
84
+ summary: "女 · 35岁 · 新闻播报,声线中低音区饱满清晰",
85
+ prompt: "专业新闻播音女主持,成年女性30-40岁,普通话标准无口音,声线中低音区饱满清晰,端庄知性沉稳,语气克制权威,语速从容均匀,音量适中稳定,新闻播报与专题解说场景。"
74
86
  },
75
87
  {
76
- label: "ASMR低语",
77
- prompt: "年轻女性,贴耳低语感,音量轻而集中,气息细微可感,辅音柔化,语速缓慢,停顿松弛,营造安静私密感。"
88
+ id: "young-man",
89
+ label: "江予辰",
90
+ summary: "男 · 19岁 · 青年男声,清亮干净的中高音带少年感",
91
+ prompt: "男性青年16-22岁,清亮干净的中高音带少年感,普通话标准无口音,轻快明亮的活力声线,气息轻盈吐字利索,语速偏快语调自然上扬,情绪积极阳光带朝气,广告旁白或轻松解说场景。"
78
92
  },
79
93
  {
80
- label: "少年感男声",
81
- prompt: "年轻男性,清亮干净的中高音,气息轻盈,吐字利索,语速偏快,语调自然上扬,带一点未经世故的朝气。"
94
+ id: "tech-explainer",
95
+ label: "周砚川",
96
+ summary: "男 · 30岁 · 科技解说,清晰利落中音、干净偏冷",
97
+ prompt: "成年男性25-35岁,清晰利落中音、干净偏冷,标准普通话,精准干练的都市精英感,语速中等偏快、语调平稳,理性简洁、逻辑感强,现代资讯播报或商业讲解场景。"
82
98
  },
83
99
  {
84
- label: "纪录片男声",
85
- prompt: "成熟男性,低沉醇厚,胸腔共鸣稳定,气息舒展,语速中等偏慢,停顿有留白,语调沉稳克制,带叙事纵深感。"
100
+ id: "suspense-narrator",
101
+ label: "裴沉舟",
102
+ summary: "男 · 35岁 · 悬疑旁白,低沉沉稳带神秘磁性",
103
+ prompt: "男性中年30-40岁,低沉沉稳带神秘磁性,普通话,压抑克制的叙事风格,语速缓慢均匀,语调低沉平稳,情绪冷静悬疑,旁白解说场景。"
86
104
  },
87
105
  {
88
- label: "古风说书男声",
89
- prompt: "成熟男性,浑厚略带沙感,咬字圆润,行腔从容,语速偏慢,抑扬有致但不戏曲化,带阅历感与从容幽默。"
90
- },
91
- {
92
- label: "科技解说男声",
93
- prompt: "成年男性,清晰利落的中音,音色干净偏冷,吐字精准,语速中等偏快,逻辑感强,情绪理性、简洁而有现代感。"
94
- },
95
- {
96
- label: "电台夜谈男声",
97
- prompt: "成熟男性,温暖低缓,带轻微磁性和松弛气声,语速偏慢,语调贴近耳边但不过度低语,情绪包容安定。"
98
- },
99
- {
100
- label: "悬疑旁白男声",
101
- prompt: "成熟男性,偏低沉的冷感声线,气息收敛,语速缓慢,停顿明确,语调压低并保留细微起伏,带克制的紧张感。"
106
+ id: "documentary-narrator",
107
+ label: "陆远山",
108
+ summary: "男 · 45岁 · 纪录片,低沉醇厚有胸腔共鸣",
109
+ prompt: "男性40-50岁,低沉醇厚有胸腔共鸣,普通话,稳重可靠的叙事者风格,语速中等偏慢,语调沉稳克制带叙事纵深感,气息舒展停顿有留白,纪录片旁白或深度访谈场景。"
102
110
  }
103
111
  ];
104
112
  /** Minimum spoken characters to accumulate before starting one PCM stream request. */
@@ -183,6 +191,11 @@ function parseSseRecords(value) {
183
191
  remainder
184
192
  };
185
193
  }
194
+ /** Decide whether a live assistant update extends one message, advances within a turn, or starts a new turn. */
195
+ function classifyLiveSpeechTransition(current, next) {
196
+ if (current === null || current.sessionId !== next.sessionId || current.turn !== next.turn) return "new-turn";
197
+ return current.step === next.step ? "same-step" : "same-turn";
198
+ }
186
199
  /** Serializes sentence requests and makes cancellation independent from the playback backend. */
187
200
  var AbortableSentenceQueue = class {
188
201
  pending = [];
@@ -227,10 +240,10 @@ const DEFAULT_TTS_SETTINGS = {
227
240
  voice: "冰糖",
228
241
  voiceDesignPrompt: "青年女性,声线清亮、亲切自然,吐字清楚,语速适中,情绪温柔克制。",
229
242
  voiceDesignCustomPrompt: "青年女性,声线清亮、亲切自然,吐字清楚,语速适中,情绪温柔克制。",
230
- presetStylePrompt: "使用清晰自然的普通话朗读,可带轻微湖南语感,但不影响清晰度。整体声线清冷、克制,略带距离感;发声收敛,气息自然,语速中等偏快,句间停顿干脆。仅在情绪关键词处轻微延长尾音,避免夸张、戏剧化或过度气声。",
243
+ presetStylePrompt: "使用清晰、自然、准确的声音朗读,语速适中,停顿自然,语气平和克制,避免夸张表达。",
231
244
  format: "mp3",
232
245
  autoPlay: true,
233
- instruction: "咬字清楚,普通话里能听出一点湖南口音,轻音和翘舌会稍微有点自己的味道。说话时喉咙有点紧,气息不算特别足,所以听起来会有一点“冷”和“端着”的感觉,中等偏快,句子断得干脆,偶尔会拖长音。情绪底色偏理性、克制,像隔着一层玻璃说话。",
246
+ instruction: "请忠实朗读原文,根据文本语气自然表达,不添加或改写内容。",
234
247
  maxTextLength: 12e3,
235
248
  requestTimeoutMs: 12e4
236
249
  };
@@ -280,12 +293,14 @@ const zh = {
280
293
  "settings.autoPlay": "开启自动播报",
281
294
  "settings.autoPlayHint": "开启时会同步显示朗读按钮;浏览器也可能拒绝自动播放。",
282
295
  "settings.model": "TTS 模型",
283
- "settings.presetModel": "预置音色模型",
284
- "settings.voiceDesignModel": "自定义音色模型",
296
+ "settings.presetModel": "预置音色模型 (mimo-v2.5-tts)",
297
+ "settings.voiceDesignModel": "自定义音色模型 (mimo-v2.5-tts-voicedesign)",
285
298
  "settings.modelAutoPlayHintPreset": "预置音色模型支持实时流式播放。",
286
299
  "settings.modelAutoPlayHintVoiceDesign": "自定义音色仅支持在回复完成后自动播放。",
287
300
  "settings.voice": "内置音色",
288
301
  "settings.voiceDesignPrompt": "自定义音色描述",
302
+ "settings.customVoiceOption": "自定义",
303
+ "settings.customVoiceSummary": "手动编写音色描述",
289
304
  "settings.voiceDesignPromptHint": "按“年龄段 + 性别、声音质感、语速节奏、情绪底色”描述声音本身;不写场景或动作。",
290
305
  "settings.format": "音频格式",
291
306
  "settings.save": "保存",
@@ -322,12 +337,14 @@ const en = {
322
337
  "settings.autoPlay": "Enable automatic read-aloud",
323
338
  "settings.autoPlayHint": "Enabling it also shows the read-aloud button; the browser may reject autoplay.",
324
339
  "settings.model": "TTS model",
325
- "settings.presetModel": "Preset voices",
326
- "settings.voiceDesignModel": "Custom voice design",
340
+ "settings.presetModel": "Preset voices (mimo-v2.5-tts)",
341
+ "settings.voiceDesignModel": "Custom voice design (mimo-v2.5-tts-voicedesign)",
327
342
  "settings.modelAutoPlayHintPreset": "Preset voices support realtime streaming playback.",
328
343
  "settings.modelAutoPlayHintVoiceDesign": "Custom voice design supports automatic playback only after the reply is complete.",
329
344
  "settings.voice": "Built-in voice",
330
345
  "settings.voiceDesignPrompt": "Custom voice description",
346
+ "settings.customVoiceOption": "Custom",
347
+ "settings.customVoiceSummary": "Write a custom voice description",
331
348
  "settings.voiceDesignPromptHint": "Describe the voice itself with age/gender, texture, pace, and emotional baseline; avoid scenes or actions.",
332
349
  "settings.format": "Audio format",
333
350
  "settings.save": "Save",
@@ -516,19 +533,37 @@ var LiveSpeechController = class {
516
533
  handled = /* @__PURE__ */ new Set();
517
534
  messageId = null;
518
535
  status = "idle";
536
+ sessionId = null;
519
537
  onStateChange = null;
520
538
  setStateChangeListener(listener) {
521
539
  this.onStateChange = listener;
522
540
  }
541
+ activateSession(sessionId) {
542
+ if (this.sessionId === sessionId) return;
543
+ this.cancel();
544
+ this.sessionId = sessionId;
545
+ }
546
+ deactivateSession(sessionId) {
547
+ if (this.sessionId !== sessionId) return;
548
+ this.cancel();
549
+ this.sessionId = null;
550
+ }
523
551
  observe(sessionId, turn, step, text) {
524
- const key = `${sessionId}:${turn}:${step}`;
525
- if (this.active !== key || !text.startsWith(this.observed)) this.reset(key);
552
+ if (this.sessionId !== sessionId) return;
553
+ const next = {
554
+ sessionId,
555
+ turn,
556
+ step
557
+ };
558
+ const transition = classifyLiveSpeechTransition(this.active, next);
559
+ if (transition === "new-turn" || transition === "same-step" && !text.startsWith(this.observed)) this.reset(next);
560
+ else if (transition === "same-turn") this.advanceSegment(next);
526
561
  this.observed = text;
527
562
  this.drain(false);
528
563
  }
529
564
  finish(sessionId, final) {
530
565
  const key = `${sessionId}:${final.turn}:${final.step}`;
531
- if (this.active !== key) return;
566
+ if (this.sessionId !== sessionId || this.active === null || this.cursorKey(this.active) !== key) return;
532
567
  if (final.interrupted) {
533
568
  this.cancelSession(sessionId);
534
569
  return;
@@ -539,7 +574,8 @@ var LiveSpeechController = class {
539
574
  this.drain(true);
540
575
  this.handled.add(key);
541
576
  }
542
- toggle(messageId) {
577
+ toggle(sessionId, messageId) {
578
+ if (this.sessionId !== sessionId) return false;
543
579
  if (this.messageId !== messageId || this.status !== "playing" && this.status !== "paused") return false;
544
580
  if (this.status === "playing") this.audio.pause();
545
581
  else this.audio.resume();
@@ -549,7 +585,7 @@ var LiveSpeechController = class {
549
585
  return identity !== null && this.handled.has(`${sessionId}:${identity.turn}:${identity.step}`);
550
586
  }
551
587
  cancelSession(sessionId) {
552
- if (this.active?.startsWith(`${sessionId}:`) === true) this.cancel();
588
+ if (this.active?.sessionId === sessionId) this.cancel();
553
589
  }
554
590
  cancel() {
555
591
  this.replaceQueue();
@@ -566,15 +602,25 @@ var LiveSpeechController = class {
566
602
  this.handled.clear();
567
603
  await this.audio.dispose();
568
604
  }
569
- reset(key) {
605
+ reset(next) {
570
606
  this.replaceQueue();
571
607
  this.audio.stop();
572
- this.active = key;
608
+ this.beginSegment(next);
609
+ this.status = "idle";
610
+ }
611
+ advanceSegment(next) {
612
+ this.drain(true);
613
+ this.beginSegment(next);
614
+ }
615
+ beginSegment(next) {
616
+ this.active = next;
573
617
  this.observed = "";
574
618
  this.consumed = 0;
575
619
  this.pendingText = "";
576
620
  this.messageId = null;
577
- this.status = "idle";
621
+ }
622
+ cursorKey(cursor) {
623
+ return `${cursor.sessionId}:${cursor.turn}:${cursor.step}`;
578
624
  }
579
625
  drain(flush) {
580
626
  const { sentences, remainder } = splitCompletedTtsSentences(this.observed.slice(this.consumed));
@@ -648,12 +694,13 @@ var LiveSpeechController = class {
648
694
  this.reportStatus();
649
695
  }
650
696
  reportStatus() {
651
- if (this.messageId !== null) this.onStateChange?.(this.messageId, this.status);
697
+ if (this.sessionId !== null && this.messageId !== null) this.onStateChange?.(this.sessionId, this.messageId, this.status);
652
698
  }
653
699
  };
654
700
  var PlaybackController = class {
655
701
  autoPlayArmedAt = Date.now();
656
702
  view = {
703
+ sessionId: null,
657
704
  messageId: null,
658
705
  status: "idle",
659
706
  error: null
@@ -666,12 +713,55 @@ var PlaybackController = class {
666
713
  current = null;
667
714
  request = null;
668
715
  generation = 0;
716
+ activeSessionId = null;
669
717
  getSnapshot = () => this.view;
670
718
  subscribe = (listener) => {
671
719
  this.listeners.add(listener);
672
720
  return () => this.listeners.delete(listener);
673
721
  };
722
+ activateSession(sessionId) {
723
+ if (this.activeSessionId === sessionId) return;
724
+ this.generation += 1;
725
+ this.stopCurrent();
726
+ this.liveSessions.clear();
727
+ this.completedSessions.clear();
728
+ this.completedMessages.clear();
729
+ this.activeSessionId = sessionId;
730
+ this.publish({
731
+ sessionId: null,
732
+ messageId: null,
733
+ status: "idle",
734
+ error: null
735
+ });
736
+ }
737
+ cancelPlayback(sessionId) {
738
+ if (this.activeSessionId !== sessionId) return;
739
+ this.generation += 1;
740
+ this.stopCurrent();
741
+ this.publish({
742
+ sessionId: null,
743
+ messageId: null,
744
+ status: "idle",
745
+ error: null
746
+ });
747
+ }
748
+ deactivateSession(sessionId) {
749
+ if (this.activeSessionId !== sessionId) return;
750
+ this.generation += 1;
751
+ this.stopCurrent();
752
+ this.liveSessions.clear();
753
+ this.completedSessions.clear();
754
+ this.completedMessages.clear();
755
+ this.activeSessionId = null;
756
+ this.publish({
757
+ sessionId: null,
758
+ messageId: null,
759
+ status: "idle",
760
+ error: null
761
+ });
762
+ }
674
763
  observeSession(sessionId, running, latestMessageId) {
764
+ if (this.activeSessionId !== sessionId) return;
675
765
  if (running) {
676
766
  this.liveSessions.add(sessionId);
677
767
  this.completedSessions.delete(sessionId);
@@ -682,6 +772,7 @@ var PlaybackController = class {
682
772
  if (this.completedSessions.has(sessionId) && latestMessageId !== null) this.completedMessages.set(sessionId, latestMessageId);
683
773
  }
684
774
  claimAutomaticPlayback(sessionId, messageId) {
775
+ if (this.activeSessionId !== sessionId) return false;
685
776
  const key = `${sessionId}:${messageId}`;
686
777
  if (this.completedMessages.get(sessionId) !== messageId) return false;
687
778
  if (this.automaticallyPlayed.has(key)) return false;
@@ -690,32 +781,42 @@ var PlaybackController = class {
690
781
  this.completedMessages.delete(sessionId);
691
782
  return true;
692
783
  }
693
- updateLivePlayback(messageId, status) {
784
+ updateLivePlayback(sessionId, messageId, status) {
785
+ if (this.activeSessionId !== sessionId) return;
694
786
  if (this.view.messageId === messageId || status !== "idle") this.publish({
787
+ sessionId,
695
788
  messageId,
696
789
  status,
697
790
  error: status === "error" ? "play-failed" : null
698
791
  });
699
792
  }
700
- async toggle(messageId, text, automatic) {
701
- if (this.view.messageId === messageId && this.current !== null) {
702
- if (this.current.audio.paused) try {
703
- await this.current.audio.play();
793
+ async toggle(sessionId, messageId, text, automatic) {
794
+ if (this.activeSessionId !== sessionId) return;
795
+ if (this.view.sessionId === sessionId && this.view.messageId === messageId && this.current !== null) {
796
+ const audio = this.current.audio;
797
+ const generation$1 = this.generation;
798
+ if (audio.paused) try {
799
+ await audio.play();
800
+ if (generation$1 !== this.generation || this.activeSessionId !== sessionId || this.current?.audio !== audio) return;
704
801
  this.publish({
802
+ sessionId,
705
803
  messageId,
706
804
  status: "playing",
707
805
  error: null
708
806
  });
709
807
  } catch {
808
+ if (generation$1 !== this.generation || this.activeSessionId !== sessionId || this.current?.audio !== audio) return;
710
809
  this.publish({
810
+ sessionId,
711
811
  messageId,
712
812
  status: "paused",
713
813
  error: automatic ? "autoplay-blocked" : "play-failed"
714
814
  });
715
815
  }
716
816
  else {
717
- this.current.audio.pause();
817
+ audio.pause();
718
818
  this.publish({
819
+ sessionId,
719
820
  messageId,
720
821
  status: "paused",
721
822
  error: null
@@ -725,6 +826,7 @@ var PlaybackController = class {
725
826
  }
726
827
  if (text.length === 0) {
727
828
  this.publish({
829
+ sessionId,
728
830
  messageId,
729
831
  status: "error",
730
832
  error: "no-text"
@@ -736,6 +838,7 @@ var PlaybackController = class {
736
838
  const controller = new AbortController();
737
839
  this.request = controller;
738
840
  this.publish({
841
+ sessionId,
739
842
  messageId,
740
843
  status: "loading",
741
844
  error: null
@@ -757,7 +860,7 @@ var PlaybackController = class {
757
860
  throw new Error(message);
758
861
  }
759
862
  const blob = await response.blob();
760
- if (generation !== this.generation) return;
863
+ if (generation !== this.generation || this.activeSessionId !== sessionId) return;
761
864
  const url = URL.createObjectURL(blob);
762
865
  const audio = new Audio(url);
763
866
  this.current = {
@@ -766,14 +869,16 @@ var PlaybackController = class {
766
869
  };
767
870
  this.request = null;
768
871
  audio.addEventListener("ended", () => {
769
- if (this.current?.audio === audio) this.publish({
872
+ if (this.activeSessionId === sessionId && this.current?.audio === audio) this.publish({
873
+ sessionId,
770
874
  messageId,
771
875
  status: "idle",
772
876
  error: null
773
877
  });
774
878
  });
775
879
  audio.addEventListener("error", () => {
776
- if (this.current?.audio === audio) this.publish({
880
+ if (this.activeSessionId === sessionId && this.current?.audio === audio) this.publish({
881
+ sessionId,
777
882
  messageId,
778
883
  status: "error",
779
884
  error: "play-failed"
@@ -781,22 +886,27 @@ var PlaybackController = class {
781
886
  });
782
887
  try {
783
888
  await audio.play();
889
+ if (generation !== this.generation || this.activeSessionId !== sessionId || this.current?.audio !== audio) return;
784
890
  this.publish({
891
+ sessionId,
785
892
  messageId,
786
893
  status: "playing",
787
894
  error: null
788
895
  });
789
896
  } catch {
897
+ if (generation !== this.generation || this.activeSessionId !== sessionId || this.current?.audio !== audio) return;
790
898
  this.publish({
899
+ sessionId,
791
900
  messageId,
792
901
  status: "paused",
793
902
  error: automatic ? "autoplay-blocked" : "play-failed"
794
903
  });
795
904
  }
796
905
  } catch (error) {
797
- if (controller.signal.aborted || generation !== this.generation) return;
906
+ if (controller.signal.aborted || generation !== this.generation || this.activeSessionId !== sessionId) return;
798
907
  this.request = null;
799
908
  this.publish({
909
+ sessionId,
800
910
  messageId,
801
911
  status: "error",
802
912
  error: error instanceof Error ? error.message : String(error)
@@ -809,6 +919,7 @@ var PlaybackController = class {
809
919
  this.liveSessions.clear();
810
920
  this.completedSessions.clear();
811
921
  this.completedMessages.clear();
922
+ this.activeSessionId = null;
812
923
  this.listeners.clear();
813
924
  }
814
925
  stopCurrent() {
@@ -826,39 +937,54 @@ var PlaybackController = class {
826
937
  for (const listener of this.listeners) listener();
827
938
  }
828
939
  };
829
- /** Track live turn completion separately from finalized-message rendering. */
830
- function AutoPlayRunObserver({ sessionId, session, playback }) {
940
+ /** Own the active-session boundary and feed its partial assistant output into realtime speech. */
941
+ function SessionPlaybackObserver({ sessionId, session, playback, live, settings }) {
942
+ const resolvedSettings = resolveTtsSettings(useSettingsSnapshot(settings).value);
943
+ const active = (0, react.useRef)(null);
944
+ const wasRunning = (0, react.useRef)(session.running);
945
+ const runArmed = (0, react.useRef)(!session.running);
831
946
  const latestMessageId = latestAssistantMessageId(session);
947
+ const partial = session.partial;
948
+ const partialText = partial === null ? "" : assistantText(partial.blocks);
832
949
  (0, react.useEffect)(() => {
833
- playback.observeSession(sessionId, session.running, latestMessageId);
950
+ active.current = null;
951
+ wasRunning.current = session.running;
952
+ runArmed.current = !session.running;
953
+ playback.activateSession(sessionId);
954
+ live.activateSession(sessionId);
955
+ return () => {
956
+ active.current = null;
957
+ live.deactivateSession(sessionId);
958
+ playback.deactivateSession(sessionId);
959
+ };
834
960
  }, [
835
- latestMessageId,
961
+ live,
836
962
  playback,
837
- session.running,
838
963
  sessionId
839
964
  ]);
840
- return null;
841
- }
842
- /** Feed the public `ConversationSnapshot.partial` projection into sentence-level realtime speech. */
843
- function LiveSpeechObserver({ sessionId, session, live, settings }) {
844
- const resolvedSettings = resolveTtsSettings(useSettingsSnapshot(settings).value);
845
- const active = (0, react.useRef)(null);
846
- const wasRunning = (0, react.useRef)(session.running);
847
- const partial = session.partial;
848
- const partialText = partial === null ? "" : assistantText(partial.blocks);
849
965
  (0, react.useEffect)(() => {
850
966
  const beganRun = session.running && !wasRunning.current;
851
967
  wasRunning.current = session.running;
852
- if (!resolvedSettings.enabled || !resolvedSettings.autoPlay || resolvedSettings.model !== "mimo-v2.5-tts") {
968
+ if (!session.running) runArmed.current = true;
969
+ else if (beganRun) {
970
+ runArmed.current = true;
853
971
  live.cancelSession(sessionId);
972
+ playback.cancelPlayback(sessionId);
854
973
  active.current = null;
855
- return;
856
974
  }
857
- if (beganRun) {
975
+ playback.observeSession(sessionId, session.running && runArmed.current, latestMessageId);
976
+ if (!resolvedSettings.enabled || !resolvedSettings.autoPlay || resolvedSettings.model !== "mimo-v2.5-tts") {
858
977
  live.cancelSession(sessionId);
859
978
  active.current = null;
979
+ if (session.running) runArmed.current = false;
980
+ return;
860
981
  }
982
+ if (!runArmed.current) return;
861
983
  if (partial !== null) {
984
+ if (active.current !== null && (active.current.turn !== partial.turn || active.current.step !== partial.step)) {
985
+ const previous = finalLiveMessage(session, active.current.turn, active.current.step);
986
+ if (previous !== null) live.finish(sessionId, previous);
987
+ }
862
988
  active.current = {
863
989
  turn: partial.turn,
864
990
  step: partial.step
@@ -873,9 +999,11 @@ function LiveSpeechObserver({ sessionId, session, live, settings }) {
873
999
  active.current = null;
874
1000
  }
875
1001
  }, [
1002
+ latestMessageId,
876
1003
  live,
877
1004
  partial,
878
1005
  partialText,
1006
+ playback,
879
1007
  resolvedSettings.autoPlay,
880
1008
  resolvedSettings.enabled,
881
1009
  resolvedSettings.model,
@@ -883,7 +1011,6 @@ function LiveSpeechObserver({ sessionId, session, live, settings }) {
883
1011
  sessionId,
884
1012
  session.running
885
1013
  ]);
886
- (0, react.useEffect)(() => () => live.cancelSession(sessionId), [live, sessionId]);
887
1014
  return null;
888
1015
  }
889
1016
  function ReadAloudAction({ sessionId, messageId, useSession, playback, live, settings, t }) {
@@ -900,7 +1027,7 @@ function ReadAloudAction({ sessionId, messageId, useSession, playback, live, set
900
1027
  (0, react.useEffect)(() => {
901
1028
  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;
902
1029
  const cancel = window.setTimeout(() => {
903
- if (!live.hasHandled(sessionId, message.identity) && playback.claimAutomaticPlayback(sessionId, messageId)) playback.toggle(messageId, text, true);
1030
+ if (!live.hasHandled(sessionId, message.identity) && playback.claimAutomaticPlayback(sessionId, messageId)) playback.toggle(sessionId, messageId, text, true);
904
1031
  }, 0);
905
1032
  return () => window.clearTimeout(cancel);
906
1033
  }, [
@@ -917,7 +1044,7 @@ function ReadAloudAction({ sessionId, messageId, useSession, playback, live, set
917
1044
  text
918
1045
  ]);
919
1046
  if (settingsSnapshot.value?.enabled !== true || text.length === 0) return null;
920
- const mine = view.messageId === messageId;
1047
+ const mine = view.sessionId === sessionId && view.messageId === messageId;
921
1048
  const status = mine ? view.status : "idle";
922
1049
  const label = status === "loading" ? t("action.loading") : status === "playing" ? t("action.pause") : status === "paused" ? t("action.resume") : status === "error" ? t("action.retry") : t("action.play");
923
1050
  const error = mine ? view.error : null;
@@ -932,9 +1059,9 @@ function ReadAloudAction({ sessionId, messageId, useSession, playback, live, set
932
1059
  "aria-pressed": status === "playing",
933
1060
  disabled: status === "loading",
934
1061
  onClick: () => {
935
- if (!live.toggle(messageId)) {
1062
+ if (!live.toggle(sessionId, messageId)) {
936
1063
  live.cancel();
937
- playback.toggle(messageId, text, false);
1064
+ playback.toggle(sessionId, messageId, text, false);
938
1065
  }
939
1066
  },
940
1067
  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, {})
@@ -958,6 +1085,173 @@ const CUSTOM_VOICE_DESIGN_OPTION = "__custom__";
958
1085
  function isPresetVoiceDesignPrompt(value) {
959
1086
  return TTS_VOICE_DESIGN_PRESETS.some((item) => item.prompt === value);
960
1087
  }
1088
+ function VoicePresetAvatar({ preset }) {
1089
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("img", {
1090
+ className: "xmimo-tts-voice-avatar",
1091
+ src: `${TTS_VOICE_DESIGN_ASSET_ROUTE}/${preset.id}.webp`,
1092
+ alt: "",
1093
+ width: 40,
1094
+ height: 40,
1095
+ loading: "lazy",
1096
+ "aria-hidden": "true"
1097
+ });
1098
+ }
1099
+ function CustomVoiceAvatar() {
1100
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1101
+ className: "xmimo-tts-voice-avatar xmimo-tts-custom-voice-avatar",
1102
+ "aria-hidden": "true",
1103
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("svg", {
1104
+ viewBox: "0 0 40 40",
1105
+ focusable: "false",
1106
+ children: [
1107
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("circle", {
1108
+ cx: "20",
1109
+ cy: "14",
1110
+ r: "6"
1111
+ }),
1112
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", { d: "M9.5 31.5c1.7-6.2 5.2-9.3 10.5-9.3s8.8 3.1 10.5 9.3" }),
1113
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", { d: "M31 8v8M27 12h8" })
1114
+ ]
1115
+ })
1116
+ });
1117
+ }
1118
+ function VoiceDesignPresetPicker({ value, disabled, label, customLabel, customSummary, onChange }) {
1119
+ const [open, setOpen] = (0, react.useState)(false);
1120
+ const rootRef = (0, react.useRef)(null);
1121
+ const triggerRef = (0, react.useRef)(null);
1122
+ const optionRefs = (0, react.useRef)([]);
1123
+ const listboxId = (0, react.useId)();
1124
+ const selectedPresetIndex = TTS_VOICE_DESIGN_PRESETS.findIndex((item) => item.prompt === value);
1125
+ const selectedPreset = selectedPresetIndex < 0 ? void 0 : TTS_VOICE_DESIGN_PRESETS[selectedPresetIndex];
1126
+ const selectedOptionIndex = selectedPresetIndex + 1;
1127
+ const optionCount = TTS_VOICE_DESIGN_PRESETS.length + 1;
1128
+ (0, react.useEffect)(() => {
1129
+ if (!open) return;
1130
+ const closeOnOutsidePointer = (event) => {
1131
+ if (event.target instanceof Node && !rootRef.current?.contains(event.target)) setOpen(false);
1132
+ };
1133
+ document.addEventListener("pointerdown", closeOnOutsidePointer);
1134
+ return () => document.removeEventListener("pointerdown", closeOnOutsidePointer);
1135
+ }, [open]);
1136
+ (0, react.useEffect)(() => {
1137
+ if (disabled) setOpen(false);
1138
+ }, [disabled]);
1139
+ const focusOption = (index) => {
1140
+ const normalized = (index + optionCount) % optionCount;
1141
+ requestAnimationFrame(() => optionRefs.current[normalized]?.focus());
1142
+ };
1143
+ const openAndFocus = (index) => {
1144
+ setOpen(true);
1145
+ focusOption(index);
1146
+ };
1147
+ const choose = (next) => {
1148
+ onChange(next);
1149
+ setOpen(false);
1150
+ requestAnimationFrame(() => triggerRef.current?.focus());
1151
+ };
1152
+ const handleTriggerKeyDown = (event) => {
1153
+ if (event.key === "ArrowDown") {
1154
+ event.preventDefault();
1155
+ openAndFocus(selectedOptionIndex);
1156
+ } else if (event.key === "ArrowUp") {
1157
+ event.preventDefault();
1158
+ openAndFocus(selectedOptionIndex === 0 ? optionCount - 1 : selectedOptionIndex);
1159
+ } else if (event.key === "Home") {
1160
+ event.preventDefault();
1161
+ openAndFocus(0);
1162
+ } else if (event.key === "End") {
1163
+ event.preventDefault();
1164
+ openAndFocus(optionCount - 1);
1165
+ }
1166
+ };
1167
+ const handleOptionKeyDown = (event, index) => {
1168
+ if (event.key === "ArrowDown") {
1169
+ event.preventDefault();
1170
+ focusOption(index + 1);
1171
+ } else if (event.key === "ArrowUp") {
1172
+ event.preventDefault();
1173
+ focusOption(index - 1);
1174
+ } else if (event.key === "Home") {
1175
+ event.preventDefault();
1176
+ focusOption(0);
1177
+ } else if (event.key === "End") {
1178
+ event.preventDefault();
1179
+ focusOption(optionCount - 1);
1180
+ } else if (event.key === "Escape") {
1181
+ event.preventDefault();
1182
+ setOpen(false);
1183
+ triggerRef.current?.focus();
1184
+ } else if (event.key === "Tab") setOpen(false);
1185
+ };
1186
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1187
+ className: "xmimo-tts-voice-picker",
1188
+ ref: rootRef,
1189
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
1190
+ ref: triggerRef,
1191
+ type: "button",
1192
+ className: "xmimo-tts-voice-picker-trigger",
1193
+ disabled,
1194
+ "aria-label": label,
1195
+ "aria-haspopup": "listbox",
1196
+ "aria-expanded": open,
1197
+ "aria-controls": open ? listboxId : void 0,
1198
+ onClick: () => {
1199
+ setOpen((current) => !current);
1200
+ },
1201
+ onKeyDown: handleTriggerKeyDown,
1202
+ children: [
1203
+ selectedPreset === void 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CustomVoiceAvatar, {}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(VoicePresetAvatar, { preset: selectedPreset }),
1204
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
1205
+ className: "xmimo-tts-voice-option-copy",
1206
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("strong", { children: selectedPreset?.label ?? customLabel }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("small", { children: selectedPreset?.summary ?? customSummary })]
1207
+ }),
1208
+ /* @__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" })
1209
+ ]
1210
+ }), open ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1211
+ id: listboxId,
1212
+ className: "xmimo-tts-voice-picker-menu",
1213
+ role: "listbox",
1214
+ "aria-label": label,
1215
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
1216
+ ref: (node) => {
1217
+ optionRefs.current[0] = node;
1218
+ },
1219
+ type: "button",
1220
+ role: "option",
1221
+ "aria-selected": selectedPreset === void 0,
1222
+ className: selectedPreset === void 0 ? "xmimo-tts-voice-option xmimo-tts-voice-option-selected" : "xmimo-tts-voice-option",
1223
+ onClick: () => {
1224
+ choose(CUSTOM_VOICE_DESIGN_OPTION);
1225
+ },
1226
+ onKeyDown: (event) => {
1227
+ handleOptionKeyDown(event, 0);
1228
+ },
1229
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(CustomVoiceAvatar, {}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
1230
+ className: "xmimo-tts-voice-option-copy",
1231
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("strong", { children: customLabel }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("small", { children: customSummary })]
1232
+ })]
1233
+ }), TTS_VOICE_DESIGN_PRESETS.map((preset, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
1234
+ ref: (node) => {
1235
+ optionRefs.current[index + 1] = node;
1236
+ },
1237
+ type: "button",
1238
+ role: "option",
1239
+ "aria-selected": selectedPreset?.id === preset.id,
1240
+ className: selectedPreset?.id === preset.id ? "xmimo-tts-voice-option xmimo-tts-voice-option-selected" : "xmimo-tts-voice-option",
1241
+ onClick: () => {
1242
+ choose(preset.prompt);
1243
+ },
1244
+ onKeyDown: (event) => {
1245
+ handleOptionKeyDown(event, index + 1);
1246
+ },
1247
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(VoicePresetAvatar, { preset }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
1248
+ className: "xmimo-tts-voice-option-copy",
1249
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("strong", { children: preset.label }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("small", { children: preset.summary })]
1250
+ })]
1251
+ }, preset.id))]
1252
+ }) : null]
1253
+ });
1254
+ }
961
1255
  function layerSettings(value) {
962
1256
  return isRecord(value) ? value : void 0;
963
1257
  }
@@ -1282,21 +1576,16 @@ function SettingsCard({ scope, t }) {
1282
1576
  resetField("voiceDesignPrompt");
1283
1577
  }
1284
1578
  }),
1285
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("select", {
1579
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(VoiceDesignPresetPicker, {
1286
1580
  value: isPresetVoiceDesignPrompt(voiceDesignPrompt) ? voiceDesignPrompt : CUSTOM_VOICE_DESIGN_OPTION,
1287
1581
  disabled: !snapshot.writable,
1288
- "aria-label": t("settings.voiceDesignPrompt"),
1289
- onChange: (event) => {
1290
- setVoiceDesignPrompt(event.target.value === CUSTOM_VOICE_DESIGN_OPTION ? voiceDesignCustomPrompt : event.target.value);
1582
+ label: t("settings.voiceDesignPrompt"),
1583
+ customLabel: t("settings.customVoiceOption"),
1584
+ customSummary: t("settings.customVoiceSummary"),
1585
+ onChange: (value$1) => {
1586
+ setVoiceDesignPrompt(value$1 === CUSTOM_VOICE_DESIGN_OPTION ? voiceDesignCustomPrompt : value$1);
1291
1587
  markChange("voiceDesignPrompt");
1292
- },
1293
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
1294
- value: CUSTOM_VOICE_DESIGN_OPTION,
1295
- children: "自定义"
1296
- }), TTS_VOICE_DESIGN_PRESETS.map((item) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
1297
- value: item.prompt,
1298
- children: item.label
1299
- }, item.label))]
1588
+ }
1300
1589
  }),
1301
1590
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("textarea", {
1302
1591
  value: voiceDesignPrompt,
@@ -1415,7 +1704,7 @@ function apply(ctx) {
1415
1704
  });
1416
1705
  const playback = new PlaybackController();
1417
1706
  const live = new LiveSpeechController();
1418
- live.setStateChangeListener((messageId, status) => playback.updateLivePlayback(messageId, status));
1707
+ live.setStateChangeListener((sessionId, messageId, status) => playback.updateLivePlayback(sessionId, messageId, status));
1419
1708
  ctx.effect(() => () => playback.dispose(), "xiaomi-mimo-tts: playback");
1420
1709
  ctx.effect(() => () => {
1421
1710
  live.dispose();
@@ -1428,6 +1717,7 @@ function apply(ctx) {
1428
1717
  .xmimo-tts-inline-error{max-width:220px;color:var(--dsw-alias-state-error-primary,#dc2626);font-size:12px}
1429
1718
  .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}
1430
1719
  .xmimo-tts-grid{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:16px 14px;margin-top:16px;align-items:start}.xmimo-tts-grid label,.xmimo-tts-api-key,.xmimo-tts-model,.xmimo-tts-voice-design-prompt,.xmimo-tts-select-column>div{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:14px}.xmimo-tts-checkbox-row{flex-direction:row!important;align-items:flex-start!important}.xmimo-tts-checkbox-row input{width:auto!important;flex:none;margin-top:3px}.xmimo-tts-checkbox-row span{display:flex;min-width:0;flex-direction:column;gap:4px}.xmimo-tts-select-column{display:flex;min-width:0;flex-direction:row;gap:16px}.xmimo-tts-select-column>div{flex:1}
1720
+ .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)}
1431
1721
  .xmimo-tts-card-actions{display:flex;align-items:center;justify-content:flex-end;gap:10px;margin-top:16px;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-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)}
1432
1722
  @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-select-column{grid-column:auto;flex-direction:column}.xmimo-tts-api-key-hints{flex-wrap:wrap}.xmimo-tts-api-key-hints small{white-space:normal}}
1433
1723
  `;
@@ -1436,19 +1726,14 @@ function apply(ctx) {
1436
1726
  }, "xiaomi-mimo-tts: styles");
1437
1727
  registerSlotContribution(ctx, "conversation.input.dock", () => ctx.slots.register({
1438
1728
  name: "conversation.input.dock",
1439
- id: "xiaomi-mimo-tts-autoplay-observer",
1440
- order: 999,
1441
- inject: () => ({ playback })
1442
- }, AutoPlayRunObserver));
1443
- registerSlotContribution(ctx, "conversation.input.dock", () => ctx.slots.register({
1444
- name: "conversation.input.dock",
1445
- id: "xiaomi-mimo-tts-live-observer",
1729
+ id: "xiaomi-mimo-tts-session-playback-observer",
1446
1730
  order: 998,
1447
1731
  inject: () => ({
1732
+ playback,
1448
1733
  live,
1449
1734
  settings: scope
1450
1735
  })
1451
- }, LiveSpeechObserver));
1736
+ }, SessionPlaybackObserver));
1452
1737
  registerSlotContribution(ctx, "conversation.chat.assistant-actions", () => ctx.slots.register({
1453
1738
  name: "conversation.chat.assistant-actions",
1454
1739
  id: "xiaomi-mimo-tts",