//native
type Speechify = {
token: string;
};
/**
* Get speech
* Gets the speech data for the given input
*/
export async function main(
auth: Speechify,
body: {
audio_format?: "wav" | "mp3" | "ogg" | "aac";
input: string;
language?: string;
model?:
| "simba-base"
| "simba-english"
| "simba-multilingual"
| "simba-turbo";
options?: { loudness_normalization?: false | true };
voice_id: string;
},
) {
const url = new URL(`https://api.sws.speechify.com/v1/audio/speech`);
const response = await fetch(url, {
method: "POST",
headers: {
"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.text();
}
Submitted by hugo697 428 days ago