chore: audio

This commit is contained in:
jialin
2024-11-25 20:07:17 +08:00
parent 961d420c95
commit 7fcd005f06
13 changed files with 159 additions and 151 deletions
+29
View File
@@ -10,6 +10,10 @@ export const OPENAI_MODELS = '/v1-openai/models';
export const RERANKER_API = '/rerank';
export const AUDIO_TEXT_TO_SPEECH_API = '/v1-openai/audio/speech';
export const AUDIO_SPEECH_TO_TEXT_API = '/v1-openai/audio/transcriptions';
export async function execChatCompletions(params: any) {
return request(`${CHAT_API}`, {
method: 'POST',
@@ -81,3 +85,28 @@ export const createImages = async (
}
return res.json();
};
// ============ audio ============
export const textToSpeech = async (params: any, options?: any) => {
const res = await fetch(AUDIO_TEXT_TO_SPEECH_API, {
method: 'POST',
body: JSON.stringify(params),
signal: params.signal
});
if (!res.ok) {
throw new Error('Network response was not ok');
}
return res.json();
};
export const speechToText = async (params: any, options?: any) => {
const res = await fetch(AUDIO_SPEECH_TO_TEXT_API, {
method: 'POST',
body: JSON.stringify(params),
signal: params.signal
});
if (!res.ok) {
throw new Error('Network response was not ok');
}
return res.json();
};