Skip to content

Commit 59d889e

Browse files
jackshen310shenxiaojie.316
andauthored
fix(websocket): Fix No ScriptProcessor was register with this name (#281)
Co-authored-by: shenxiaojie.316 <shenxiaojie.316@bytedance.com>
1 parent 591dce2 commit 59d889e

4 files changed

Lines changed: 30 additions & 6 deletions

File tree

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"changes": [
3+
{
4+
"packageName": "@coze/api",
5+
"comment": "Fix No ScriptProcessor was register with this name",
6+
"type": "patch"
7+
}
8+
],
9+
"packageName": "@coze/api",
10+
"email": "shenxiaojie.316@bytedance.com"
11+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"changes": [
3+
{
4+
"packageName": "@coze/api",
5+
"comment": "Fix No ScriptProcessor was register with this name",
6+
"type": "patch"
7+
}
8+
],
9+
"packageName": "@coze/api",
10+
"email": "shenxiaojie.316@bytedance.com"
11+
}

examples/realtime-websocket/src/pages/chat/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ function Chat() {
340340
}, 1000);
341341
} catch (error: any) {
342342
message.error(`开始录音错误: ${error.message || '未知错误'}`);
343-
console.error('开始录音错误:', error);
343+
console.trace('开始录音错误:', error);
344344
// Clean up timer if it was set
345345
if (recordTimer.current) {
346346
clearInterval(recordTimer.current);

packages/coze-js/src/ws-tools/chat/index.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ class WsChatClient extends BaseWsChatClient {
7171
this.wavStreamPlayer?.setMediaStream(rawMediaStream);
7272

7373
// init stream player
74-
await this.wavStreamPlayer?.add16BitPCM(new ArrayBuffer(0), this.trackId);
74+
// await this.wavStreamPlayer?.add16BitPCM(new ArrayBuffer(0), this.trackId);
7575

7676
// 2. recording
7777
await this.recorder.record({
@@ -140,8 +140,6 @@ class WsChatClient extends BaseWsChatClient {
140140
const ws = await this.init();
141141
this.ws = ws;
142142

143-
const sampleRate = await this.recorder?.getSampleRate();
144-
145143
const event: ChatUpdateEvent = {
146144
id: chatUpdate?.id || uuid(),
147145
event_type: WebsocketsEventType.CHAT_UPDATE,
@@ -167,8 +165,12 @@ class WsChatClient extends BaseWsChatClient {
167165
if (this.config.voiceId) {
168166
setValueByPath(event, 'data.output_audio.voice_id', this.config.voiceId);
169167
}
170-
// 强制设置输入音频的采样率为系统默认的采样率
171-
setValueByPath(event, 'data.input_audio.sample_rate', sampleRate);
168+
169+
setValueByPath(
170+
event,
171+
'data.input_audio.sample_rate',
172+
event.data?.input_audio?.sample_rate || 48000,
173+
);
172174

173175
this.inputAudioCodec = event.data?.input_audio?.codec || 'pcm';
174176
this.outputAudioCodec = event.data?.output_audio?.codec || 'pcm';

0 commit comments

Comments
 (0)