@streamoji/aitwin 0.6.2 → 0.6.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/dist/index.d.ts CHANGED
@@ -49,7 +49,9 @@ export declare type AiTwinHandle = {
49
49
  /** Mute/unmute bot audio output (TTS + voice). */
50
50
  setMuted: (muted: boolean) => void;
51
51
  isMuted: () => boolean;
52
- /** Persona / knowledge context id from getAiTwin (for /avatarReply). */
52
+ /** Brain id from getAiTwin (for /avatarReply and /ws/voice). */
53
+ getBrainId: () => string | null;
54
+ /** @deprecated Use `getBrainId`. */
53
55
  getPersonaId: () => string | null;
54
56
  };
55
57
 
@@ -89,6 +91,11 @@ export declare type AiTwinProps = {
89
91
  * `ttsEngineId:voiceId` (e.g. `visemetts:eve`).
90
92
  */
91
93
  voiceId?: string;
94
+ /**
95
+ * Default TTS language for `speakText()` and voice `connect()`.
96
+ * Uniform code for visemetts and Cartesia (`en`, `es-MX`, `auto`, …).
97
+ */
98
+ language?: TtsLanguage;
92
99
  /** API speakingRate (default: 0.85). */
93
100
  speakingRate?: number;
94
101
  className?: string;
@@ -148,7 +155,9 @@ export declare type AiTwinRecord = {
148
155
  voiceId?: string;
149
156
  /** Bearer JWT for TTS / voice WebSocket (same as `getAuthToken`). */
150
157
  authToken?: string;
151
- /** When set, passed as `personaId` on voice WebSocket connect. */
158
+ /** Redis brain id. Passed as `brainId` on `/ws/voice` and `/avatarReply`. */
159
+ brainId?: string;
160
+ /** @deprecated Use `brainId`. */
152
161
  knowledgeContextId?: string;
153
162
  gender?: string;
154
163
  createdAt?: string;
@@ -205,6 +214,11 @@ export declare type AiTwinWidgetProps = {
205
214
  apiBase?: string;
206
215
  /** TTS voice id override. */
207
216
  voiceId?: string;
217
+ /**
218
+ * Default TTS language for `speakText()` and voice `connect()`.
219
+ * Uniform code for visemetts and Cartesia (`en`, `es-MX`, `auto`, …).
220
+ */
221
+ language?: TtsLanguage;
208
222
  /** API speakingRate (default 0.85). */
209
223
  speakingRate?: number;
210
224
  /**
@@ -218,9 +232,11 @@ export declare type AiTwinWidgetProps = {
218
232
  */
219
233
  float?: boolean;
220
234
  /**
221
- * Persona / knowledge context id for /avatarReply (Text mode).
222
- * When omitted, uses getAiTwin `knowledgeContextId` if available.
235
+ * Brain id for /avatarReply (Text mode).
236
+ * When omitted, uses getAiTwin `brainId` if available.
223
237
  */
238
+ brainId?: string;
239
+ /** @deprecated Use `brainId`. */
224
240
  personaId?: string;
225
241
  /**
226
242
  * Optional poster shown (blurred) on `<AiTwin>` while sil/atlas/idle assets load.
@@ -281,6 +297,11 @@ export declare type AvatarTtsSpeakOptions = {
281
297
  speakingRate?: number;
282
298
  /** Overrides controller default for this request. */
283
299
  ttsEngineId?: TtsEngineId;
300
+ /**
301
+ * Uniform TTS language code (`en`, `es-MX`, `auto`, …).
302
+ * Sent as `language` on `/avatar_ttsWithPoses`.
303
+ */
304
+ language?: TtsLanguage;
284
305
  };
285
306
 
286
307
  /** Pair transitions for playback, including sil→first and last→sil bookends. */
@@ -307,6 +328,8 @@ export declare function createRealtimeVoiceLipsyncController(onStatus: (status:
307
328
 
308
329
  export declare const DEFAULT_TTS_ENGINE_ID: TtsEngineId;
309
330
 
331
+ export declare const DEFAULT_TTS_LANGUAGE: TtsLanguage;
332
+
310
333
  export declare const EMOTION_TO_EYEBROW: Record<ExpressionEmotion, number>;
311
334
 
312
335
  export declare function emotionToEyebrow(emotion: ExpressionEmotion): number;
@@ -329,6 +352,8 @@ export declare type FetchAvatarReplyOptions = {
329
352
  message: string;
330
353
  authToken: string;
331
354
  apiBase?: string;
355
+ brainId?: string;
356
+ /** @deprecated Use `brainId`. */
332
357
  personaId?: string;
333
358
  history?: AvatarReplyMessage[];
334
359
  /** Called as soon as spokenText arrives on the SSE stream. */
@@ -398,6 +423,10 @@ export declare function getAiTwinSourceUrl(faceId: string, cdnBase?: string, ext
398
423
  /** Public CDN thumbnail for custom-faces/{faceId}/ (same id as pipeline avatarId). */
399
424
  export declare function getAiTwinThumbnailUrl(faceId: string, cdnBase?: string): string;
400
425
 
426
+ export declare function isTtsLanguageCode(raw: string): raw is TtsLanguage;
427
+
428
+ export declare function isTtsLanguageSupported(engineId: TtsEngineId, language: string): boolean;
429
+
401
430
  export declare function listSkippedVisemeEntries(queue: VisemeQueueItem[]): SkippedVisemeEntry[];
402
431
 
403
432
  /** Visemes removed by compaction (for debug). */
@@ -410,6 +439,9 @@ export declare function normalizeOculusViseme(symbol: string | null | undefined)
410
439
 
411
440
  export declare function normalizeStreamEmotion(raw: string | undefined | null, fallback?: ExpressionEmotion): ExpressionEmotion;
412
441
 
442
+ /** Trimmed language code, or undefined when empty. */
443
+ export declare function normalizeTtsLanguage(raw?: string | null): TtsLanguage | undefined;
444
+
413
445
  /** Oculus viseme ids for Talking Lady stills and pair transitions (15 standard). */
414
446
  export declare const OCULUS_VISEME_IDS: readonly ["aa", "CH", "DD", "E", "FF", "I", "O", "PP", "RR", "SS", "TH", "U", "kk", "nn", "sil"];
415
447
 
@@ -482,6 +514,9 @@ export declare type RealtimeVoiceOptions = VoiceConnectOptions & {
482
514
  /** Resolve optional `avatarId` / `faceId` props (same R2 custom-faces hex id). */
483
515
  export declare function resolveDirectFaceId(avatarId?: string, faceId?: string): string | undefined;
484
516
 
517
+ /** Canonical `brainId`, then legacy `knowledgeContextId`, then extra fallbacks. */
518
+ export declare function resolveTwinBrainId(source?: TwinBrainFields | string | null, ...fallbacks: Array<string | null | undefined>): string | undefined;
519
+
485
520
  /** Pick the active viseme at playback offset (latest vtime wins on overlap). */
486
521
  export declare function resolveVisemeAtTime(queue: VisemeQueueItem[], elapsedMs: number): string;
487
522
 
@@ -538,8 +573,265 @@ export declare const TTS_ENGINE_INWORLD = "eng_d4e8f3a2";
538
573
  /** streamoji-ai-avatar viseme TTS (`POST /avatar_ttsWithPoses`). */
539
574
  export declare const TTS_ENGINE_VISEMETTS = "visemetts";
540
575
 
576
+ /**
577
+ * Uniform TTS language codes for visemetts and Cartesia (`eng_c9b1e6d4`).
578
+ * Passed as `language` on `/avatar_ttsWithPoses` and `/ws/voice`.
579
+ */
580
+ export declare const TTS_LANGUAGE_CATALOG: readonly [{
581
+ readonly code: "en";
582
+ readonly label: "English";
583
+ readonly visemetts: true;
584
+ readonly cartesia: true;
585
+ }, {
586
+ readonly code: "es";
587
+ readonly label: "Spanish";
588
+ readonly visemetts: true;
589
+ readonly cartesia: true;
590
+ }, {
591
+ readonly code: "es-MX";
592
+ readonly label: "Spanish (Mexico)";
593
+ readonly visemetts: true;
594
+ readonly cartesia: true;
595
+ }, {
596
+ readonly code: "es-ES";
597
+ readonly label: "Spanish (Spain)";
598
+ readonly visemetts: true;
599
+ readonly cartesia: true;
600
+ }, {
601
+ readonly code: "pt";
602
+ readonly label: "Portuguese";
603
+ readonly visemetts: true;
604
+ readonly cartesia: true;
605
+ }, {
606
+ readonly code: "pt-BR";
607
+ readonly label: "Portuguese (Brazil)";
608
+ readonly visemetts: true;
609
+ readonly cartesia: true;
610
+ }, {
611
+ readonly code: "pt-PT";
612
+ readonly label: "Portuguese (Portugal)";
613
+ readonly visemetts: true;
614
+ readonly cartesia: true;
615
+ }, {
616
+ readonly code: "fr";
617
+ readonly label: "French";
618
+ readonly visemetts: true;
619
+ readonly cartesia: true;
620
+ }, {
621
+ readonly code: "de";
622
+ readonly label: "German";
623
+ readonly visemetts: true;
624
+ readonly cartesia: true;
625
+ }, {
626
+ readonly code: "it";
627
+ readonly label: "Italian";
628
+ readonly visemetts: true;
629
+ readonly cartesia: true;
630
+ }, {
631
+ readonly code: "zh";
632
+ readonly label: "Chinese";
633
+ readonly visemetts: true;
634
+ readonly cartesia: true;
635
+ }, {
636
+ readonly code: "ja";
637
+ readonly label: "Japanese";
638
+ readonly visemetts: true;
639
+ readonly cartesia: true;
640
+ }, {
641
+ readonly code: "hi";
642
+ readonly label: "Hindi";
643
+ readonly visemetts: true;
644
+ readonly cartesia: true;
645
+ }, {
646
+ readonly code: "ko";
647
+ readonly label: "Korean";
648
+ readonly visemetts: true;
649
+ readonly cartesia: true;
650
+ }, {
651
+ readonly code: "ru";
652
+ readonly label: "Russian";
653
+ readonly visemetts: true;
654
+ readonly cartesia: true;
655
+ }, {
656
+ readonly code: "tr";
657
+ readonly label: "Turkish";
658
+ readonly visemetts: true;
659
+ readonly cartesia: true;
660
+ }, {
661
+ readonly code: "id";
662
+ readonly label: "Indonesian";
663
+ readonly visemetts: true;
664
+ readonly cartesia: true;
665
+ }, {
666
+ readonly code: "ar";
667
+ readonly label: "Arabic";
668
+ readonly visemetts: true;
669
+ readonly cartesia: true;
670
+ }, {
671
+ readonly code: "ar-EG";
672
+ readonly label: "Arabic (Egypt)";
673
+ readonly visemetts: true;
674
+ readonly cartesia: true;
675
+ }, {
676
+ readonly code: "ar-AE";
677
+ readonly label: "Arabic (UAE)";
678
+ readonly visemetts: true;
679
+ readonly cartesia: true;
680
+ }, {
681
+ readonly code: "vi";
682
+ readonly label: "Vietnamese";
683
+ readonly visemetts: true;
684
+ readonly cartesia: true;
685
+ }, {
686
+ readonly code: "bn";
687
+ readonly label: "Bengali";
688
+ readonly visemetts: true;
689
+ readonly cartesia: true;
690
+ }, {
691
+ readonly code: "auto";
692
+ readonly label: "Auto-detect";
693
+ readonly visemetts: true;
694
+ readonly cartesia: false;
695
+ }, {
696
+ readonly code: "nl";
697
+ readonly label: "Dutch";
698
+ readonly visemetts: false;
699
+ readonly cartesia: true;
700
+ }, {
701
+ readonly code: "pl";
702
+ readonly label: "Polish";
703
+ readonly visemetts: false;
704
+ readonly cartesia: true;
705
+ }, {
706
+ readonly code: "sv";
707
+ readonly label: "Swedish";
708
+ readonly visemetts: false;
709
+ readonly cartesia: true;
710
+ }, {
711
+ readonly code: "tl";
712
+ readonly label: "Tagalog";
713
+ readonly visemetts: false;
714
+ readonly cartesia: true;
715
+ }, {
716
+ readonly code: "bg";
717
+ readonly label: "Bulgarian";
718
+ readonly visemetts: false;
719
+ readonly cartesia: true;
720
+ }, {
721
+ readonly code: "ro";
722
+ readonly label: "Romanian";
723
+ readonly visemetts: false;
724
+ readonly cartesia: true;
725
+ }, {
726
+ readonly code: "cs";
727
+ readonly label: "Czech";
728
+ readonly visemetts: false;
729
+ readonly cartesia: true;
730
+ }, {
731
+ readonly code: "el";
732
+ readonly label: "Greek";
733
+ readonly visemetts: false;
734
+ readonly cartesia: true;
735
+ }, {
736
+ readonly code: "fi";
737
+ readonly label: "Finnish";
738
+ readonly visemetts: false;
739
+ readonly cartesia: true;
740
+ }, {
741
+ readonly code: "hr";
742
+ readonly label: "Croatian";
743
+ readonly visemetts: false;
744
+ readonly cartesia: true;
745
+ }, {
746
+ readonly code: "ms";
747
+ readonly label: "Malay";
748
+ readonly visemetts: false;
749
+ readonly cartesia: true;
750
+ }, {
751
+ readonly code: "sk";
752
+ readonly label: "Slovak";
753
+ readonly visemetts: false;
754
+ readonly cartesia: true;
755
+ }, {
756
+ readonly code: "da";
757
+ readonly label: "Danish";
758
+ readonly visemetts: false;
759
+ readonly cartesia: true;
760
+ }, {
761
+ readonly code: "ta";
762
+ readonly label: "Tamil";
763
+ readonly visemetts: false;
764
+ readonly cartesia: true;
765
+ }, {
766
+ readonly code: "uk";
767
+ readonly label: "Ukrainian";
768
+ readonly visemetts: false;
769
+ readonly cartesia: true;
770
+ }, {
771
+ readonly code: "hu";
772
+ readonly label: "Hungarian";
773
+ readonly visemetts: false;
774
+ readonly cartesia: true;
775
+ }, {
776
+ readonly code: "no";
777
+ readonly label: "Norwegian";
778
+ readonly visemetts: false;
779
+ readonly cartesia: true;
780
+ }, {
781
+ readonly code: "th";
782
+ readonly label: "Thai";
783
+ readonly visemetts: false;
784
+ readonly cartesia: true;
785
+ }, {
786
+ readonly code: "he";
787
+ readonly label: "Hebrew";
788
+ readonly visemetts: false;
789
+ readonly cartesia: true;
790
+ }, {
791
+ readonly code: "ka";
792
+ readonly label: "Georgian";
793
+ readonly visemetts: false;
794
+ readonly cartesia: true;
795
+ }, {
796
+ readonly code: "te";
797
+ readonly label: "Telugu";
798
+ readonly visemetts: false;
799
+ readonly cartesia: true;
800
+ }, {
801
+ readonly code: "gu";
802
+ readonly label: "Gujarati";
803
+ readonly visemetts: false;
804
+ readonly cartesia: true;
805
+ }, {
806
+ readonly code: "kn";
807
+ readonly label: "Kannada";
808
+ readonly visemetts: false;
809
+ readonly cartesia: true;
810
+ }, {
811
+ readonly code: "ml";
812
+ readonly label: "Malayalam";
813
+ readonly visemetts: false;
814
+ readonly cartesia: true;
815
+ }, {
816
+ readonly code: "mr";
817
+ readonly label: "Marathi";
818
+ readonly visemetts: false;
819
+ readonly cartesia: true;
820
+ }, {
821
+ readonly code: "pa";
822
+ readonly label: "Punjabi";
823
+ readonly visemetts: false;
824
+ readonly cartesia: true;
825
+ }];
826
+
827
+ export declare const TTS_LANGUAGE_CODES: readonly TtsLanguage[];
828
+
541
829
  export declare type TtsEngineId = typeof TTS_ENGINE_GOOGLE | typeof TTS_ENGINE_INWORLD | typeof TTS_ENGINE_CARTESIA | typeof TTS_ENGINE_VISEMETTS;
542
830
 
831
+ export declare type TtsLanguage = (typeof TTS_LANGUAGE_CATALOG)[number]["code"];
832
+
833
+ export declare function ttsLanguagesForEngine(engineId: TtsEngineId): TtsLanguage[];
834
+
543
835
  /** Runtime face bundle URLs (R2 custom-faces or local /twins/…). */
544
836
  export declare type TwinAssetUrls = {
545
837
  /** Plain assets: sil.png, idle.mp4, atlas.json */
@@ -549,6 +841,12 @@ export declare type TwinAssetUrls = {
549
841
  encrypted: boolean;
550
842
  };
551
843
 
844
+ declare type TwinBrainFields = {
845
+ brainId?: string | null;
846
+ /** @deprecated Use `brainId`. Older getAiTwin responses still send this. */
847
+ knowledgeContextId?: string | null;
848
+ };
849
+
552
850
  export declare const VISEME_IDS: readonly ["aa", "E", "I", "O", "U", "PP", "FF", "DD", "SS", "TH", "CH", "RR", "kk", "nn"];
553
851
 
554
852
  /** Minimum gap (ms) between consecutive vtimes to keep a skippable viseme. */
@@ -582,7 +880,14 @@ export declare type VoiceConnectOptions = {
582
880
  ttsEngineId?: TtsEngineId;
583
881
  /** Cartesia voice UUID, or visemetts name (e.g. `eve`). */
584
882
  voiceId?: string;
585
- /** Persona / knowledge context id (from getAiTwin `knowledgeContextId`). */
883
+ /**
884
+ * Uniform TTS language code (`en`, `es-MX`, `auto`, …).
885
+ * Sent as `language` on `/ws/voice` and redirected `/avatar_ttsWithPoses` calls.
886
+ */
887
+ language?: TtsLanguage;
888
+ /** Redis brain id (from getAiTwin `brainId`). Sent as `brainId` on `/ws/voice`. */
889
+ brainId?: string;
890
+ /** @deprecated Use `brainId`. */
586
891
  personaId?: string;
587
892
  speakingRate?: number;
588
893
  /** Default true — server streams TTS + avatar messages. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@streamoji/aitwin",
3
- "version": "0.6.2",
3
+ "version": "0.6.4",
4
4
  "description": "Embeddable React AI twin face with TTS lipsync",
5
5
  "type": "module",
6
6
  "main": "./dist/aitwin.cjs",