Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

175
Vistas
Convert Buffer from @google-cloud/text-to-speech and send it to Telegram chat as a voice message

I tried to convert a Buffer from @google-cloud/text-to-speech with audio-decode lib, but it's throwing an error (something like Buffer is not valid). So I find lib ffmpeg but I can't understand how to set input from a variable and then save it to the variable again so I could send it as a Telegram voice message.

The current code of request to @google-cloud/text-to-speech looks like this:

const request = {
    input: {
        text: "TEST TEST TEST TEST",
    },
    // Select the language and SSML voice gender (optional)
    voice: { languageCode: "en-US", ssmlGender: "NEUTRAL" },
    // select the type of audio encoding
    audioConfig: { audioEncoding: "OGG_OPUS" },
};

const [response] = await client.synthesizeSpeech(request);

response is a buffer:

{ audioContent: <Buffer 4f 67 67 53 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 43 5e c1 a1 01 13 4f 70 75 73 48 65 61 64 01 01 38 01 c0 5d 00 00 00 00 00 4f 67 67 ... 23270 more bytes> }

If I understood right, telegram voice message should be in OGG format, but I can get only OGG OPUS, WAV, or MP3: https://cloud.google.com/speech-to-text/docs/encoding

My question is: how can I convert that Buffer to OGG and save it to a variable?

Also, I use Telegraf for Telegram API, if it's important.

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda