Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

164
Views
Convierta Buffer de @google-cloud/text-to-speech y envíelo al chat de Telegram como un mensaje de voz

Intenté convertir un Buffer de @google-cloud/text-to-speech con audio-decode lib, pero arroja un error (algo así como Buffer no es válido). Entonces encontré lib ffmpeg pero no puedo entender cómo configurar la entrada de una variable y luego guardarla en la variable nuevamente para poder enviarla como un mensaje de voz de Telegram.

El código actual de solicitud a @google-cloud/text-to-speech se ve así:

 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);

la response es un búfer:

 { 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> }

Si entendí bien, el mensaje de voz de Telegram debería estar en formato OGG, pero solo puedo obtener OGG OPUS, WAV o MP3: https://cloud.google.com/speech-to-text/docs/encoding

Mi pregunta es: ¿cómo puedo convertir ese Buffer a OGG y guardarlo en una variable?

Además, uso Telegraf para Telegram API, si es importante.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!