//native
type Deepinfra = {
token: string;
};
/**
* Openai Audio Speech
*
*/
export async function main(
auth: Deepinfra,
x_deepinfra_source: string,
body: {
model: string;
input: string;
voice?:
| "luna"
| "aura"
| "quartz"
| "af"
| "af_bella"
| "af_sarah"
| "am_adam"
| "am_michael"
| "bf_emma"
| "bf_isabella"
| "bm_george"
| "bm_lewis"
| "af_nicole"
| "af_sky";
response_format?: "wav";
speed?: number;
},
) {
const url = new URL(`https://api.deepinfra.com/v1/openai/audio/speech`);
const response = await fetch(url, {
method: "POST",
headers: {
"x-deepinfra-source": x_deepinfra_source,
"Content-Type": "application/json",
Authorization: "Bearer " + auth.token,
},
body: JSON.stringify(body),
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 235 days ago