File tree 1 file changed +15
-10
lines changed
packages/plugin-node/src/services
1 file changed +15
-10
lines changed Original file line number Diff line number Diff line change 1
- import { PassThrough , Readable } from "stream" ;
1
+ import { PassThrough } from "stream" ;
2
+ import { Readable } from "node:stream" ;
3
+ import { ReadableStream } from "node:stream/web" ;
2
4
import { IAgentRuntime , ISpeechService , ServiceType } from "@elizaos/core" ;
3
5
import { getWavHeader } from "./audioUtils.ts" ;
4
6
import { Service } from "@elizaos/core" ;
@@ -123,17 +125,20 @@ async function textToSpeech(runtime: IAgentRuntime, text: string) {
123
125
}
124
126
125
127
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
+
127
133
const readable = new Readable ( {
128
134
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
+ } ) ;
137
142
} ,
138
143
} ) ;
139
144
You can’t perform that action at this time.
0 commit comments