Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request Timing out #35

Open
josephfeleke opened this issue Mar 6, 2023 · 1 comment
Open

Request Timing out #35

josephfeleke opened this issue Mar 6, 2023 · 1 comment

Comments

@josephfeleke
Copy link

I was trying to make a request to the api using nodejs express but it does not return anything and it times out
my code:

mport express from 'express';
import axios from 'axios';
import { TextEncoder } from 'util';
import fs from 'fs';
import path from 'path';


const ENDPOINT = 'https://tiktok-tts.weilnet.workers.dev';
const text = 'hello baby';
const voice = "en_us_ghostface"

axios({
    method: 'post',
    url: `${ENDPOINT}/api/generation`,
    headers: {
      'Content-Type': 'application/json',
    },
    data: {
      text: text,
      voice: voice,
    },
  })
    .then((response) => {
      // Handle successful response
      response.data.pipe(fs.createWriteStream('audio.mp3'));
    })
    .catch((error) => {
      // Handle error
      console.error(error);
    });
@marcelbrilha
Copy link

This example worked:

import axios from "axios";
import fs from "fs";

const ENDPOINT = "https://tiktok-tts.weilnet.workers.dev";
const text = "hello baby";
const voice = "en_us_ghostface";

axios({
  method: "post",
  url: `${ENDPOINT}/api/generation`,
  data: { text, voice },
  headers: {
    "Content-Type": "application/json",
  },
})
  .then((response) => {
    const { data } = response.data;
    const buffer = Buffer.from(data, "base64");
    fs.writeFileSync("./audio.mp3", buffer);
  })
  .catch((error) => {
    console.error(error);
  });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants