Edits history of script submission #12998 for ' Get stream (speechify)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Speechify = {
      token: string;
    };
    /**
     * Get stream
     * Gets the stream speech for the given input
     */
    export async function main(
      auth: Speechify,
      Accept: string,
      body: {
        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/stream`);
    
      const response = await fetch(url, {
        method: "POST",
        headers: {
          Accept: Accept,
          "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