model perf (#3657)

* fix: model

* dataset quote

* perf: model config

* model tag

* doubao model config

* perf: config model

* feat: model test
This commit is contained in:
Archer
2025-01-24 14:10:14 +08:00
committed by GitHub
parent 99ce976b06
commit 60c72d05d1
171 changed files with 1902 additions and 3126 deletions

View File

@@ -1,5 +1,6 @@
import type { NextApiResponse } from 'next';
import { getAIApi } from '../config';
import { getTTSModel } from '../model';
export async function text2Speech({
res,
@@ -18,15 +19,26 @@ export async function text2Speech({
voice: string;
speed?: number;
}) {
const modelData = getTTSModel(model)!;
const ai = getAIApi();
const response = await ai.audio.speech.create({
model,
// @ts-ignore
voice,
input,
response_format: 'mp3',
speed
});
const response = await ai.audio.speech.create(
{
model,
// @ts-ignore
voice,
input,
response_format: 'mp3',
speed
},
modelData.requestUrl && modelData.requestAuth
? {
path: modelData.requestUrl,
headers: {
Authorization: `Bearer ${modelData.requestAuth}`
}
}
: {}
);
const readableStream = response.body as unknown as NodeJS.ReadableStream;
readableStream.pipe(res);