yt-chat-components 1.6.2 → 1.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yt-chat-components",
3
- "version": "1.6.2",
3
+ "version": "1.6.4",
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",
@@ -24,7 +24,7 @@ export class AudioPlayer {
24
24
  // this.token = 'd20cf27fac634fee88d5d54a12cc36a6';
25
25
 
26
26
  this.appkey = 'DhyCL7mwzachpGjL';
27
- this.token = 'e3e3d121a15f41b198117a35ad1f33de';
27
+ this.token = '980bc0c1a3fe4fa093ae7cbb470c086f';
28
28
 
29
29
  this.taskId = uuidv4().replaceAll('-', '');
30
30
  if (voice){
@@ -41,7 +41,7 @@ export class AudioRecorder {
41
41
  }
42
42
 
43
43
  this.appkey = 'DhyCL7mwzachpGjL';
44
- this.token = 'e3e3d121a15f41b198117a35ad1f33de';
44
+ this.token = '980bc0c1a3fe4fa093ae7cbb470c086f';
45
45
 
46
46
  this.bindEventHandlers();
47
47
  console.log('AudioRecorder init')
@@ -1,3 +1,4 @@
1
+ // @ts-ignore
1
2
  import React, {useEffect, useRef, useState} from 'react';
2
3
  import {Avatar, Button, message} from 'antd';
3
4
  import './index.module.css';
@@ -63,7 +64,6 @@ const CallInterface: React.FC<CallInterfaceProps> = ({
63
64
  const vadProcessorRef = useRef<ScriptProcessorNode | null>(null);
64
65
  const audioContextRef = useRef<AudioContext | null>(null);
65
66
  const [isSpeakingNow,setIsSpeakingNow] = useState(false);
66
- const audioPlayerInstance = new StreamAudioPlayer();
67
67
 
68
68
  // 添加统一的WebSocket消息发送方法
69
69
  const sendWebSocketMessage = (type: string, data: any) => {
@@ -123,13 +123,15 @@ const CallInterface: React.FC<CallInterfaceProps> = ({
123
123
  const handleAudioChunkData = async (audioData: string) => {
124
124
  try {
125
125
  // 添加音频片段到播放器
126
- audioPlayerInstance.enqueueAudioChunk(audioData);
126
+ // @ts-ignore
127
+ window.audioPlayerInstance.enqueueAudioChunk(audioData);
127
128
 
128
129
  // 设置状态为“正在回复”
129
130
  setWorkStatus('正在回复');
130
131
 
131
132
  // 开始播放,并在所有音频完成后恢复状态
132
- audioPlayerInstance.play(() => {
133
+ // @ts-ignore
134
+ window.audioPlayerInstance.play(() => {
133
135
  console.log("全部音频播放完成!");
134
136
  setWorkStatus('正在聆听');
135
137
  });
@@ -316,7 +318,8 @@ const CallInterface: React.FC<CallInterfaceProps> = ({
316
318
  msgId: msgIdRef.current,
317
319
  });
318
320
  // 暂停当前正在播放的内容
319
- audioPlayerInstance.stop()
321
+ // @ts-ignore
322
+ window.audioPlayerInstance.stop()
320
323
  console.log('发送完毕');
321
324
 
322
325
  // 添加用户消息到聊天记录
@@ -398,7 +401,8 @@ const CallInterface: React.FC<CallInterfaceProps> = ({
398
401
  console.log("user-audio-text")
399
402
  console.log(message.textResponse)
400
403
  // 清理当前正在回复的内容
401
- audioPlayerInstance.stop()
404
+ // @ts-ignore
405
+ window.audioPlayerInstance.stop()
402
406
  // 插入语音到聊天记录
403
407
  addMessage({
404
408
  messageItemList: [
@@ -499,6 +503,8 @@ const CallInterface: React.FC<CallInterfaceProps> = ({
499
503
  // 初始化WebRTC连接
500
504
  useEffect(() => {
501
505
  initWebRTC().then();
506
+ // @ts-ignore
507
+ window.audioPlayerInstance = new StreamAudioPlayer();
502
508
  // 清理函数
503
509
  return clear
504
510
  }, []);
@@ -566,7 +572,8 @@ const CallInterface: React.FC<CallInterfaceProps> = ({
566
572
  localStreamRef.current.getTracks().forEach(track => track.stop());
567
573
  }
568
574
  // 关闭音频播放
569
- audioPlayerInstance.destroy();
575
+ // @ts-ignore
576
+ window.audioPlayerInstance.destroy();
570
577
  onHangup();
571
578
  };
572
579