yt-chat-components 1.6.8 → 1.7.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yt-chat-components",
3
- "version": "1.6.8",
3
+ "version": "1.7.0",
4
4
  "main": "build/static/js/bundle.min.js",
5
5
  "module": "build/static/js/bundle.min.js",
6
6
  "types": "build/static/js/index.d.ts",
@@ -35,11 +35,11 @@ export class AudioPlayer {
35
35
  }
36
36
 
37
37
  // 工厂方法:用于异步创建实例
38
- static async createInstance(voice: string): Promise<AudioPlayer> {
38
+ static async createInstance(voice: string, hostUrl: string, flowId: string): Promise<AudioPlayer> {
39
39
  const instance = new AudioPlayer(voice);
40
40
  try {
41
41
  // 假设这是你的异步请求
42
- const response = await getAsrToken('http://localhost:7860', '5f48c683-38d8-430e-8479-17730a605821');
42
+ const response = await getAsrToken(hostUrl, flowId);
43
43
  console.log('response = ', response);
44
44
  instance.connect(response?.data?.data?.token); // 连接或其他逻辑
45
45
  return instance;
@@ -43,11 +43,11 @@ export class AudioRecorder {
43
43
  }
44
44
 
45
45
  // 工厂方法:用于异步创建实例
46
- static async createInstance(timeoutSeconds: number): Promise<AudioRecorder> {
46
+ static async createInstance(timeoutSeconds: number, hostUrl: string, flowId: string): Promise<AudioRecorder> {
47
47
  const instance = new AudioRecorder(timeoutSeconds);
48
48
  try {
49
49
  // 假设这是你的异步请求
50
- const response = await getAsrToken('http://localhost:7860', '5f48c683-38d8-430e-8479-17730a605821');
50
+ const response = await getAsrToken(hostUrl, flowId);
51
51
  console.log('response = ', response);
52
52
  instance.token = response?.data?.data?.token;
53
53
  return instance;
@@ -64,7 +64,8 @@ export default function ChatMessage({
64
64
  key,
65
65
  isShowReadIcon,
66
66
  renderInitNode,
67
- voice
67
+ voice,
68
+ flowId,
68
69
  }: ChatMessageType) {
69
70
  const parseFileName = (
70
71
  text: string,
@@ -151,7 +152,7 @@ export default function ChatMessage({
151
152
  window.messageAudioPlayer.stop();
152
153
  window.messageAudioPlayer = null;
153
154
  }
154
- AudioPlayer.createInstance(voice).then(instance => {
155
+ AudioPlayer.createInstance(voice, host_url, flowId).then(instance => {
155
156
  window.messageAudioPlayer = instance;
156
157
  window.messageAudioPlayer.onReady = () => {
157
158
  console.log('已连接到语音合成服务');
@@ -902,7 +902,7 @@ export default function ChatWindow({
902
902
  stopRecord()
903
903
  }else {
904
904
  setRecordState(true)
905
- AudioRecorder.createInstance(5).then(instance => {
905
+ AudioRecorder.createInstance(60, hostUrl, flowId).then(instance => {
906
906
  audioRecorder.current = instance;
907
907
  audioRecorder.current.startRecorder();
908
908
  audioRecorder.current.onTextUpdate = (text: string) => {
@@ -1555,6 +1555,7 @@ export default function ChatWindow({
1555
1555
  isShowReadIcon={isShowReadIcon}
1556
1556
  renderInitNode={message.renderInitNode}
1557
1557
  voice={voice}
1558
+ flowId={flowId}
1558
1559
  />
1559
1560
  ))
1560
1561
  }
@@ -1574,6 +1575,7 @@ export default function ChatWindow({
1574
1575
  handleSendMessage={handleSendMessage}
1575
1576
  isShowReadIcon={isShowReadIcon}
1576
1577
  voice={voice}
1578
+ flowId={flowId}
1577
1579
  /> : <ChatMessagePlaceholder bot_message_style={bot_message_style} aiStatus={aiStatus}/>
1578
1580
  )
1579
1581
  }