Commit 1f600c2d by DigHuang Committed by GitHub

fix(service): convert web readable stream to node stream in text2Speech (#6985)

parent 19435e58
import type { NextApiResponse } from 'next';
import { getAIApi } from '../config';
import { getTTSModel } from '../model';
import { Readable } from 'stream';
export async function text2Speech({
res,
......@@ -40,7 +41,11 @@ export async function text2Speech({
: {}
);
const readableStream = response.body as unknown as NodeJS.ReadableStream;
if (!response.body) {
throw new Error('Response body is empty');
}
const readableStream = Readable.fromWeb(response.body as Parameters<typeof Readable.fromWeb>[0]);
readableStream.pipe(res);
const chunks: Uint8Array[] = [];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment