0

Experimental stream create

by
Published Apr 8, 2025

Gets the stream speech for the given input

Script speechify Verified

The script

Submitted by hugo697 Bun
Verified 428 days ago
1
//native
2
type Speechify = {
3
  token: string;
4
};
5
/**
6
 * Experimental stream create
7
 * Gets the stream speech for the given input
8
 */
9
export async function main(
10
  auth: Speechify,
11
  body: {
12
    input: string;
13
    language?: string;
14
    model?:
15
      | "simba-base"
16
      | "simba-english"
17
      | "simba-multilingual"
18
      | "simba-turbo";
19
    voice_id: string;
20
  },
21
) {
22
  const url = new URL(
23
    `https://api.sws.speechify.com/experimental/audio/stream`,
24
  );
25

26
  const response = await fetch(url, {
27
    method: "POST",
28
    headers: {
29
      "Content-Type": "application/json",
30
      Authorization: "Bearer " + auth.token,
31
    },
32
    body: JSON.stringify(body),
33
  });
34
  if (!response.ok) {
35
    const text = await response.text();
36
    throw new Error(`${response.status} ${text}`);
37
  }
38
  return await response.text();
39
}
40