@zeewain/3d-avatar-sdk 1.2.3 → 1.2.4-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.
@@ -1513,6 +1513,20 @@
1513
1513
  * @fileoverview 流式播报服务重构实现模块
1514
1514
  * @description 提供流式播报服务的重构实现,继承Unity基础服务,支持文本转语音和自定义音频播报
1515
1515
  */
1516
+ /**
1517
+ * 播报任务状态枚举
1518
+ */
1519
+ var BroadcastTaskStatus;
1520
+ (function (BroadcastTaskStatus) {
1521
+ /** 请求中 */
1522
+ BroadcastTaskStatus["REQUESTING"] = "requesting";
1523
+ /** 已完成 */
1524
+ BroadcastTaskStatus["COMPLETED"] = "completed";
1525
+ /** 失败 */
1526
+ BroadcastTaskStatus["FAILED"] = "failed";
1527
+ /** 已取消 */
1528
+ BroadcastTaskStatus["CANCELLED"] = "cancelled";
1529
+ })(BroadcastTaskStatus || (BroadcastTaskStatus = {}));
1516
1530
  /**
1517
1531
  * 流式播报服务重构类
1518
1532
  * @class BroadcastServiceRefactored
@@ -1542,12 +1556,20 @@
1542
1556
  super(config);
1543
1557
  /** 事件回调函数集合 */
1544
1558
  this.callbacks = {};
1545
- /** 请求控制器,用于取消请求 */
1546
- this.activeController = null;
1559
+ /** 播报任务队列 */
1560
+ this.taskQueue = [];
1561
+ /** 任务序号计数器 */
1562
+ this.taskSequence = 0;
1563
+ /** 当前发送任务的序号 */
1564
+ this.currentSendingSequence = 0;
1547
1565
  /** 是否正在生成音频 */
1548
1566
  this.isGeneratingAudio = false;
1549
1567
  /** 是否已经收到音频 */
1550
1568
  this.hasReceivedAudio = false;
1569
+ /** 队列处理定时器 */
1570
+ this.queueProcessTimer = null;
1571
+ /** 主请求控制器(兼容性保留) */
1572
+ this.activeController = null;
1551
1573
  this.callbacks = config.callbacks || {};
1552
1574
  this.logger.info('Broadcast service initialized', { config });
1553
1575
  }
@@ -1596,8 +1618,9 @@
1596
1618
  /**
1597
1619
  * 开始播报
1598
1620
  * @param params - 播报参数
1621
+ * @param isAppend - 是否追加播报
1599
1622
  * @returns Promise<void> 播报操作的Promise
1600
- * @description 开始流式播报,支持文本转语音和自定义音频播报
1623
+ * @description 开始流式播报,支持文本转语音和自定义音频播报。使用队列机制确保音频按序播报
1601
1624
  * @throws {SDKError} 当参数验证失败或播报失败时抛出错误
1602
1625
  * @example
1603
1626
  * ```typescript
@@ -1611,130 +1634,54 @@
1611
1634
  * isSubtitle: true
1612
1635
  * });
1613
1636
  *
1614
- * // 自定义音频播报
1637
+ * // 追加播报(会进入队列按序播报)
1615
1638
  * await broadcastService.startBroadcast({
1616
- * type: BroadcastType.AUDIO,
1639
+ * type: BroadcastType.TEXT,
1617
1640
  * humanCode: 'human001',
1618
- * audioUrl: 'https://example.com/audio.mp3',
1641
+ * text: '这是第二段内容',
1642
+ * voiceCode: 'voice001',
1619
1643
  * volume: 0.8,
1620
- * isSubtitle: false
1621
- * });
1644
+ * isSubtitle: true
1645
+ * }, true);
1622
1646
  * ```
1623
1647
  */
1624
- startBroadcast(params) {
1648
+ startBroadcast(params, isAppend) {
1625
1649
  return __awaiter(this, void 0, void 0, function* () {
1626
1650
  var _a, _b;
1627
- this.logger.info(`Starting broadcast: ${params.type}`, { humanCode: params.humanCode });
1651
+ this.logger.info(`Starting broadcast: ${params.type}`, {
1652
+ humanCode: params.humanCode,
1653
+ isAppend,
1654
+ queueLength: this.taskQueue.length
1655
+ });
1628
1656
  // 验证参数
1629
1657
  this.validateBroadcastParams(params);
1630
- // 先停止当前播报
1631
- yield this.stopBroadcast();
1632
- // 创建新的请求控制器
1633
- this.activeController = new AbortController();
1634
- // 监听中断信号
1635
- this.activeController.signal.addEventListener('abort', () => {
1636
- var _a, _b;
1637
- console.warn('abort');
1638
- // 如果正在生成音频,触发中断回调
1639
- if (this.isGeneratingAudio) {
1640
- (_b = (_a = this.callbacks).onAbort) === null || _b === void 0 ? void 0 : _b.call(_a);
1641
- }
1642
- // 重置状态
1643
- this.isGeneratingAudio = false;
1644
- this.hasReceivedAudio = false;
1645
- this.activeController = null;
1646
- });
1647
- // 通知Unity开始新任务(清空队列)
1648
- this.sendMessage('StartBroadcast', {
1649
- callbackFun: this.uniqueCallbackName,
1650
- operationType: exports.BroadcastOperationType.START_BROADCAST,
1651
- motionList: params.motionList,
1652
- motionPlayMode: params.motionPlayMode
1653
- });
1654
- try {
1655
- const apiUrl = `${ConfigManager.getInstance().getApiBaseUrl(true)}${this.getBroadcastApiPath(params.type)}`;
1656
- const requestBody = {
1657
- humanCode: params.humanCode,
1658
- speed: params.speed,
1659
- volume: params.volume >= 0 ? params.volume * 100 : undefined, // 转换为百分比
1660
- isSubtitle: params.isSubtitle
1661
- };
1662
- // 根据播报类型设置特定参数
1663
- if (params.type === exports.BroadcastType.TEXT) {
1664
- requestBody.text = params.text;
1665
- requestBody.voiceCode = params.voiceCode;
1666
- }
1667
- else if (params.type === exports.BroadcastType.AUDIO) {
1668
- requestBody.text = params.text;
1669
- requestBody.audioUrl = params.audioUrl;
1670
- }
1671
- this.logger.debug('Sending broadcast request', { apiUrl, requestBody });
1658
+ // 非追加模式下需要初始化播报
1659
+ if (!isAppend) {
1660
+ // 先停止当前播报并清空队列
1661
+ yield this.stopBroadcast();
1662
+ // 重置序号计数器
1663
+ this.taskSequence = 0;
1664
+ this.currentSendingSequence = 0;
1665
+ // 通知Unity开始新任务(清空队列)
1666
+ this.sendMessage('StartBroadcast', {
1667
+ callbackFun: this.uniqueCallbackName,
1668
+ operationType: exports.BroadcastOperationType.START_BROADCAST,
1669
+ motionList: params.motionList,
1670
+ motionPlayMode: params.motionPlayMode
1671
+ });
1672
1672
  // 触发开始回调
1673
1673
  (_b = (_a = this.callbacks).onStart) === null || _b === void 0 ? void 0 : _b.call(_a);
1674
1674
  this.isGeneratingAudio = true;
1675
- // 发起流式播报请求
1676
- yield fetchEventSource(apiUrl, {
1677
- method: 'POST',
1678
- headers: {
1679
- 'Content-Type': 'application/json',
1680
- 'x_auth_token': ConfigManager.getInstance().getToken()
1681
- },
1682
- body: JSON.stringify(requestBody),
1683
- signal: this.activeController.signal,
1684
- openWhenHidden: true,
1685
- onmessage: (event) => {
1686
- const response = JSON.parse(event.data);
1687
- // 错误处理
1688
- if (response.code !== 0) {
1689
- this.handleBroadcastError(response.code);
1690
- return;
1691
- }
1692
- // 流式播报
1693
- if (response.data) {
1694
- // 未完成播报时,更新任务ID
1695
- if (!response.data.done) {
1696
- this.hasReceivedAudio = true;
1697
- }
1698
- // 自定义音频播报时,如果服务器未返回音频URL,使用传入的audioUrl
1699
- if (params.type === exports.BroadcastType.AUDIO && params.audioUrl && !response.data.voiceUrl) {
1700
- response.data.voiceUrl = params.audioUrl;
1701
- }
1702
- // 如果有音频URL,发送到Unity
1703
- if (response.data.voiceUrl) {
1704
- this.sendMessage('AppendBroadcast', {
1705
- response,
1706
- callbackFun: this.uniqueCallbackName,
1707
- operationType: exports.BroadcastOperationType.APPEND_BROADCAST
1708
- });
1709
- }
1710
- if (response.data.done) {
1711
- this.isGeneratingAudio = false;
1712
- this.hasReceivedAudio = false;
1713
- this.activeController = null;
1714
- }
1715
- }
1716
- },
1717
- onclose: () => {
1718
- var _a;
1719
- // 如果不是由abort触发的关闭,需要处理
1720
- if (this.isGeneratingAudio) {
1721
- (_a = this.activeController) === null || _a === void 0 ? void 0 : _a.abort();
1722
- }
1723
- // 流结束时调用完成回调
1724
- this.logger.debug('Broadcast stream closed');
1725
- },
1726
- onerror: (error) => {
1727
- this.logger.error('Broadcast stream error', error);
1728
- const sdkError = new SDKError(exports.OperationErrorCode.OPERATION_FAILED, '服务出错了', error);
1729
- this.handleError(sdkError);
1730
- // 必须抛出错误,否则会循环重试请求
1731
- throw new Error(`服务出错了${sdkError.message}`);
1732
- }
1733
- });
1734
- }
1735
- catch (error) {
1736
- this.handleError(error);
1737
1675
  }
1676
+ // 创建新的播报任务
1677
+ const task = this.createBroadcastTask(params);
1678
+ // 添加任务到队列
1679
+ this.addTaskToQueue(task);
1680
+ this.logger.debug('Broadcast task created and queued', {
1681
+ taskId: task.id,
1682
+ sequence: task.sequence,
1683
+ isAppend
1684
+ });
1738
1685
  });
1739
1686
  }
1740
1687
  /**
@@ -1795,12 +1742,12 @@
1795
1742
  */
1796
1743
  stopBroadcast() {
1797
1744
  return __awaiter(this, void 0, void 0, function* () {
1798
- this.logger.info('Stopping broadcast');
1799
- // 取消流式请求
1800
- if (this.activeController) {
1801
- this.activeController.abort();
1802
- this.activeController = null;
1803
- }
1745
+ this.logger.info('Stopping broadcast and clearing queue', { queueLength: this.taskQueue.length });
1746
+ // 取消所有队列中的任务
1747
+ this.cancelAllTasks();
1748
+ // 重置状态
1749
+ this.isGeneratingAudio = false;
1750
+ this.hasReceivedAudio = false;
1804
1751
  try {
1805
1752
  yield this.sendAsyncMessage('StopBroadcast', exports.BroadcastOperationType.STOP_BROADCAST, {});
1806
1753
  this.logger.info('Broadcast stopped successfully');
@@ -1823,15 +1770,23 @@
1823
1770
  /**
1824
1771
  * 获取播报状态
1825
1772
  * @returns 播报状态信息
1826
- * @description 获取当前播报服务的状态信息
1773
+ * @description 获取当前播报服务的状态信息,包括队列状态
1827
1774
  */
1828
1775
  getStatus() {
1829
1776
  return {
1830
- isActive: this.activeController !== null,
1777
+ isActive: this.taskQueue.length > 0 || this.isGeneratingAudio,
1831
1778
  isGeneratingAudio: this.isGeneratingAudio,
1832
1779
  hasReceivedAudio: this.hasReceivedAudio,
1833
1780
  pendingCallbacks: this.getPendingCallbackCount(),
1834
- hasController: this.activeController !== null
1781
+ hasController: this.activeController !== null,
1782
+ queueInfo: {
1783
+ totalTasks: this.taskQueue.length,
1784
+ requestingTasks: this.taskQueue.filter((t) => t.status === BroadcastTaskStatus.REQUESTING).length,
1785
+ completedTasks: this.taskQueue.filter((t) => t.status === BroadcastTaskStatus.COMPLETED).length,
1786
+ failedTasks: this.taskQueue.filter((t) => t.status === BroadcastTaskStatus.FAILED).length,
1787
+ totalPendingResponses: this.taskQueue.reduce((sum, t) => sum + t.pendingResponses.length, 0),
1788
+ currentSendingSequence: this.currentSendingSequence
1789
+ }
1835
1790
  };
1836
1791
  }
1837
1792
  /**
@@ -1839,15 +1794,268 @@
1839
1794
  * @description 清理所有资源和回调
1840
1795
  */
1841
1796
  destroy() {
1842
- // 停止当前播报
1843
- if (this.activeController) {
1844
- this.activeController.abort();
1845
- this.activeController = null;
1797
+ // 清理队列处理定时器
1798
+ if (this.queueProcessTimer) {
1799
+ clearInterval(this.queueProcessTimer);
1800
+ this.queueProcessTimer = null;
1846
1801
  }
1802
+ // 取消所有任务
1803
+ this.cancelAllTasks();
1847
1804
  // 调用基类销毁方法
1848
1805
  super.destroy();
1849
1806
  this.logger.info('Broadcast service destroyed');
1850
1807
  }
1808
+ /**
1809
+ * 创建播报任务
1810
+ * @param params - 播报参数
1811
+ * @returns IBroadcastTask 播报任务对象
1812
+ * @description 创建新的播报任务并分配唯一ID和序号
1813
+ * @private
1814
+ */
1815
+ createBroadcastTask(params) {
1816
+ const task = {
1817
+ id: `broadcast_${Date.now()}_${Math.random().toString(36).substring(2, 9)}`,
1818
+ sequence: ++this.taskSequence,
1819
+ params,
1820
+ status: BroadcastTaskStatus.REQUESTING,
1821
+ controller: new AbortController(),
1822
+ pendingResponses: [],
1823
+ isGenerationComplete: false,
1824
+ createdAt: new Date()
1825
+ };
1826
+ this.logger.debug('Created broadcast task', { taskId: task.id, sequence: task.sequence });
1827
+ return task;
1828
+ }
1829
+ /**
1830
+ * 添加任务到队列
1831
+ * @param task - 播报任务
1832
+ * @description 将任务添加到队列并立即开始请求
1833
+ * @private
1834
+ */
1835
+ addTaskToQueue(task) {
1836
+ this.taskQueue.push(task);
1837
+ this.logger.debug('Task added to queue', { taskId: task.id, queueLength: this.taskQueue.length });
1838
+ // 立即开始该任务的请求
1839
+ this.startTaskRequest(task);
1840
+ // 开始处理队列
1841
+ this.processQueue();
1842
+ }
1843
+ /**
1844
+ * 处理队列
1845
+ * @description 处理队列中的任务,发起请求生成音频
1846
+ * @private
1847
+ */
1848
+ processQueue() {
1849
+ // 启动队列处理定时器(如果尚未启动)
1850
+ if (!this.queueProcessTimer) {
1851
+ this.queueProcessTimer = setInterval(() => {
1852
+ this.processQueueStep();
1853
+ }, 100); // 每100ms检查一次队列状态
1854
+ }
1855
+ // 立即处理一次
1856
+ this.processQueueStep();
1857
+ }
1858
+ /**
1859
+ * 队列处理步骤
1860
+ * @description 处理队列中的单个步骤,包括发起请求和发送音频
1861
+ * @private
1862
+ */
1863
+ processQueueStep() {
1864
+ // 按序号找到下一个要处理的任务
1865
+ const nextTask = this.taskQueue.find((task) => task.sequence === this.currentSendingSequence + 1
1866
+ && task.pendingResponses.length > 0);
1867
+ if (nextTask) {
1868
+ this.sendNextResponse(nextTask);
1869
+ }
1870
+ // 清理已完成的任务
1871
+ this.cleanupCompletedTasks();
1872
+ // 如果队列为空,停止定时器
1873
+ if (this.taskQueue.length === 0 && this.queueProcessTimer) {
1874
+ clearInterval(this.queueProcessTimer);
1875
+ this.queueProcessTimer = null;
1876
+ }
1877
+ }
1878
+ /**
1879
+ * 开始任务请求
1880
+ * @param task - 播报任务
1881
+ * @description 为任务发起流式请求生成音频
1882
+ * @private
1883
+ */
1884
+ startTaskRequest(task) {
1885
+ return __awaiter(this, void 0, void 0, function* () {
1886
+ task.status = BroadcastTaskStatus.REQUESTING;
1887
+ this.logger.debug('Starting task request', { taskId: task.id });
1888
+ try {
1889
+ const apiUrl = `${ConfigManager.getInstance().getApiBaseUrl(true)}${this.getBroadcastApiPath(task.params.type)}`;
1890
+ const requestBody = {
1891
+ humanCode: task.params.humanCode,
1892
+ speed: task.params.speed,
1893
+ volume: task.params.volume >= 0 ? task.params.volume * 100 : undefined,
1894
+ isSubtitle: task.params.isSubtitle
1895
+ };
1896
+ // 根据播报类型设置特定参数
1897
+ if (task.params.type === exports.BroadcastType.TEXT) {
1898
+ requestBody.text = task.params.text;
1899
+ requestBody.voiceCode = task.params.voiceCode;
1900
+ }
1901
+ else if (task.params.type === exports.BroadcastType.AUDIO) {
1902
+ requestBody.text = task.params.text;
1903
+ requestBody.audioUrl = task.params.audioUrl;
1904
+ }
1905
+ // 发起流式请求
1906
+ fetchEventSource(apiUrl, {
1907
+ method: 'POST',
1908
+ headers: {
1909
+ 'Content-Type': 'application/json',
1910
+ 'x_auth_token': ConfigManager.getInstance().getToken()
1911
+ },
1912
+ body: JSON.stringify(requestBody),
1913
+ signal: task.controller.signal,
1914
+ openWhenHidden: true,
1915
+ onmessage: (event) => {
1916
+ this.handleTaskResponse(task, event.data);
1917
+ },
1918
+ onclose: () => {
1919
+ this.handleTaskClose(task);
1920
+ },
1921
+ onerror: (error) => {
1922
+ this.handleTaskError(task, error);
1923
+ throw new Error(`Task ${task.id} request failed: ${error}`);
1924
+ }
1925
+ });
1926
+ }
1927
+ catch (error) {
1928
+ this.handleTaskError(task, error);
1929
+ }
1930
+ });
1931
+ }
1932
+ /**
1933
+ * 处理任务响应
1934
+ * @param task - 播报任务
1935
+ * @param data - 响应数据
1936
+ * @description 处理任务的流式响应数据
1937
+ * @private
1938
+ */
1939
+ handleTaskResponse(task, data) {
1940
+ try {
1941
+ const response = JSON.parse(data);
1942
+ // 错误处理
1943
+ if (response.code !== 0) {
1944
+ this.handleBroadcastError(response.code);
1945
+ return;
1946
+ }
1947
+ // 处理音频数据
1948
+ if (response.data && response.data.voiceUrl) {
1949
+ // 自定义音频播报时,如果服务器未返回音频URL,使用传入的audioUrl
1950
+ if (task.params.type === exports.BroadcastType.AUDIO && task.params.audioUrl && !response.data.voiceUrl) {
1951
+ response.data.voiceUrl = task.params.audioUrl;
1952
+ }
1953
+ // 添加处理后的响应对象到待发送队列
1954
+ task.pendingResponses.push(response);
1955
+ this.logger.debug('Response added to task', { taskId: task.id, pendingCount: task.pendingResponses.length });
1956
+ }
1957
+ // 检查是否完成
1958
+ if (response.data && response.data.done) {
1959
+ task.isGenerationComplete = true;
1960
+ this.logger.debug('Task generation completed', { taskId: task.id, totalResponses: task.pendingResponses.length });
1961
+ // 任务完成生成,保持REQUESTING状态直到所有响应发送完毕
1962
+ }
1963
+ }
1964
+ catch (error) {
1965
+ this.handleTaskError(task, error);
1966
+ }
1967
+ }
1968
+ /**
1969
+ * 发送下一个响应
1970
+ * @param task - 播报任务
1971
+ * @description 发送任务中的第一个待发送响应到Unity,发送后立即删除
1972
+ * @private
1973
+ */
1974
+ sendNextResponse(task) {
1975
+ var _a;
1976
+ if (task.pendingResponses.length === 0) {
1977
+ return;
1978
+ }
1979
+ // 取出第一个待发送的响应
1980
+ const response = task.pendingResponses.shift();
1981
+ this.logger.debug('Sending response to Unity', {
1982
+ taskId: task.id,
1983
+ remainingResponses: task.pendingResponses.length,
1984
+ voiceUrl: (_a = response.data) === null || _a === void 0 ? void 0 : _a.voiceUrl
1985
+ });
1986
+ // 发送响应到Unity
1987
+ this.sendMessage('AppendBroadcast', {
1988
+ response,
1989
+ callbackFun: this.uniqueCallbackName,
1990
+ operationType: exports.BroadcastOperationType.APPEND_BROADCAST
1991
+ });
1992
+ // 如果任务已完成且没有更多待发送响应,标记任务完成并推进序号
1993
+ if (task.isGenerationComplete && task.pendingResponses.length === 0) {
1994
+ task.status = BroadcastTaskStatus.COMPLETED;
1995
+ this.currentSendingSequence = task.sequence;
1996
+ this.logger.debug('Task completed', { taskId: task.id });
1997
+ }
1998
+ }
1999
+ /**
2000
+ * 处理任务关闭
2001
+ * @param task - 播报任务
2002
+ * @description 处理任务的流式连接关闭
2003
+ * @private
2004
+ */
2005
+ handleTaskClose(task) {
2006
+ this.logger.debug('Task stream closed', { taskId: task.id });
2007
+ // 如果还没有标记为完成,则标记为完成
2008
+ if (!task.isGenerationComplete && task.status === BroadcastTaskStatus.REQUESTING) {
2009
+ task.isGenerationComplete = true;
2010
+ }
2011
+ }
2012
+ /**
2013
+ * 处理任务错误
2014
+ * @param task - 播报任务
2015
+ * @param error - 错误对象
2016
+ * @description 处理任务执行过程中的错误
2017
+ * @private
2018
+ */
2019
+ handleTaskError(task, error) {
2020
+ var _a, _b;
2021
+ task.status = BroadcastTaskStatus.FAILED;
2022
+ task.error = error;
2023
+ this.logger.error(`Task failed - ${task.id}`, error);
2024
+ // 触发错误回调
2025
+ (_b = (_a = this.callbacks).onError) === null || _b === void 0 ? void 0 : _b.call(_a, error);
2026
+ }
2027
+ /**
2028
+ * 清理已完成的任务
2029
+ * @description 从队列中移除已完成、失败或取消的任务
2030
+ * @private
2031
+ */
2032
+ cleanupCompletedTasks() {
2033
+ const beforeLength = this.taskQueue.length;
2034
+ this.taskQueue = this.taskQueue.filter(task => task.status !== BroadcastTaskStatus.COMPLETED
2035
+ && task.status !== BroadcastTaskStatus.FAILED
2036
+ && task.status !== BroadcastTaskStatus.CANCELLED);
2037
+ const removedCount = beforeLength - this.taskQueue.length;
2038
+ if (removedCount > 0) {
2039
+ this.logger.debug('Cleaned up completed tasks', { removedCount, remainingTasks: this.taskQueue.length });
2040
+ }
2041
+ }
2042
+ /**
2043
+ * 取消所有任务
2044
+ * @description 取消队列中的所有任务
2045
+ * @private
2046
+ */
2047
+ cancelAllTasks() {
2048
+ for (const task of this.taskQueue) {
2049
+ if (task.status !== BroadcastTaskStatus.COMPLETED && task.status !== BroadcastTaskStatus.FAILED) {
2050
+ task.controller.abort();
2051
+ task.status = BroadcastTaskStatus.CANCELLED;
2052
+ }
2053
+ }
2054
+ this.taskQueue = [];
2055
+ this.taskSequence = 0;
2056
+ this.currentSendingSequence = 0;
2057
+ this.logger.debug('All tasks cancelled and queue cleared');
2058
+ }
1851
2059
  /** 全局回调函数名称 */
1852
2060
  get callbackFunctionName() {
1853
2061
  return 'uniBroadcastCallback';
@@ -2136,13 +2344,15 @@
2136
2344
  // 4. 创建带有唯一标识符的Avatar服务
2137
2345
  this.avatarService = new AvatarService({
2138
2346
  unityInstance: this.unityInstance,
2139
- instanceId: this.instanceId
2347
+ instanceId: this.instanceId,
2348
+ enableDebugLog: this.config.enableDebugLog
2140
2349
  });
2141
2350
  // 5. 创建带有唯一标识符的播报服务
2142
2351
  this.broadcastService = new BroadcastService({
2143
2352
  unityInstance: this.unityInstance,
2144
2353
  instanceId: this.instanceId,
2145
- callbacks: this.config.broadcastCallbacks
2354
+ callbacks: this.config.broadcastCallbacks,
2355
+ enableDebugLog: this.config.enableDebugLog
2146
2356
  });
2147
2357
  // 6. 初始化数字人
2148
2358
  const result = yield this.avatarService.initializeAvatar(avatarCode, cameraType);
@@ -2230,12 +2440,13 @@
2230
2440
  /**
2231
2441
  * 开始播报
2232
2442
  * @param params 播报参数
2443
+ * @param isAppend 是否追加播报
2233
2444
  * @returns Promise<void> 播报操作的Promise
2234
2445
  */
2235
- startBroadcast(params) {
2446
+ startBroadcast(params, isAppend) {
2236
2447
  return __awaiter(this, void 0, void 0, function* () {
2237
2448
  this.ensureInitialized();
2238
- return yield this.broadcastService.startBroadcast(params);
2449
+ return yield this.broadcastService.startBroadcast(params, isAppend);
2239
2450
  });
2240
2451
  }
2241
2452
  /**
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@zeewain/3d-avatar-sdk",
3
3
  "type": "module",
4
- "version": "1.2.3",
4
+ "version": "1.2.4-0",
5
5
  "description": "SDK for ZEE Avatar WebGL integration",
6
6
  "author": "ZEEWain",
7
7
  "license": "MIT",