Skip to content

Commit e0c4c14

Browse files
authored
Merge pull request #1312 from y4my4my4m/patch-1
fix: Update speech.ts
2 parents 4117448 + 5e342fb commit e0c4c14

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

packages/plugin-node/src/services/speech.ts

+15-10
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
import { PassThrough, Readable } from "stream";
1+
import { PassThrough } from "stream";
2+
import { Readable } from "node:stream";
3+
import { ReadableStream } from "node:stream/web";
24
import { IAgentRuntime, ISpeechService, ServiceType } from "@elizaos/core";
35
import { getWavHeader } from "./audioUtils.ts";
46
import { Service } from "@elizaos/core";
@@ -123,17 +125,20 @@ async function textToSpeech(runtime: IAgentRuntime, text: string) {
123125
}
124126

125127
if (response) {
126-
const reader = response.body?.getReader();
128+
const webStream = ReadableStream.from(
129+
response.body as ReadableStream
130+
);
131+
const reader = webStream.getReader();
132+
127133
const readable = new Readable({
128134
read() {
129-
reader && // eslint-disable-line
130-
reader.read().then(({ done, value }) => {
131-
if (done) {
132-
this.push(null);
133-
} else {
134-
this.push(value);
135-
}
136-
});
135+
reader.read().then(({ done, value }) => {
136+
if (done) {
137+
this.push(null);
138+
} else {
139+
this.push(value);
140+
}
141+
});
137142
},
138143
});
139144

0 commit comments

Comments
 (0)