Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

203
Visualizações
Writing a Text to Speech file as an MP3 - IBM Watson

I'm following the documentation for the Node.JS implementation of the IBM Watson Text-to-Speech API.

I want to output the resultant file into MP3 format. The documentation recommends augmenting the base code but I'm not sure how to do that. My code is rendering unplayable MP3s.

Here is what it says in the documentation:

textToSpeech.synthesize(synthesizeParams)
  .then(response => {

    // The following line is necessary only for
    // wav formats; otherwise, `response.result`
    // can be directly piped to a file.

    return textToSpeech.repairWavHeaderStream(response.result);
  })
  .then(buffer => {
    fs.writeFileSync('hello_world.wav', buffer);
  })
  .catch(err => {
    console.log('error:', err);
  });

As it says, response.result should be directly piped to a file. This is one of my many attempts (that renders an error).

textToSpeech
  .synthesize(synthesizeParams)  
  .then(response => {
    fs.writeFileSync('Hello.mp3', response.result)
  })
  .catch(err => {
    console.log('error:', err)
  })

How can I output the text-to-speech input as an MP3?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Provided your params are requesting an mp3 file, this will be the accept parameter, then your code looks ok. So if the output file isn't being recognised as an audio, then it is most likely a text file containing an error message. This error message will indicate what is wrong, which most likely will be an unauthorised message.

I take it that your catch error block isn't logging anything.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda