Gemini Audio Converter (JS)

Converte áudio Base64 (PCM s16le 24kHz Mono) da API Gemini TTS para MP3 usando lamejs (pure JS). Mais lento que FFmpeg.

Gemini Audio Converter (JS)

AI-generated

Overview

This node converts Base64-encoded PCM audio data (16-bit signed little-endian, 24kHz, mono or stereo) from the Gemini TTS API into an MP3 audio file using the pure JavaScript library lamejs. It is useful for workflows that need to transform raw PCM audio data into a compressed MP3 format for easier storage, playback, or transmission. For example, it can be used to convert TTS output from Gemini into MP3 files for podcasts, voice messages, or audio archives.

Use Case Examples

  1. Convert Base64 PCM audio from Gemini TTS API response to MP3 for playback in a web app.
  2. Transform raw PCM audio data into MP3 to reduce file size before uploading to cloud storage.
  3. Generate MP3 audio files from TTS output for use in automated phone systems or voice assistants.

Properties

Name Meaning
Input Base64 Data Field The JSON path to the Base64-encoded PCM audio data field or the Base64 string itself.
Output Property Name The name of the binary property where the resulting MP3 file will be stored.
MP3 Bitrate (kbps) The bitrate for MP3 encoding, controlling audio quality and file size (e.g., 128, 192, 256 kbps).
Sample Rate (Hz) The sample rate of the input PCM audio, typically 24000 Hz for Gemini TTS.
Channels The number of audio channels in the input PCM data (1 for mono, 2 for stereo).

Output

Binary

The node outputs an MP3 audio file as binary data under the specified output property name.

JSON

  • json - The original JSON input data for the item.
    binary - The binary MP3 audio file generated from the Base64 PCM input.

Dependencies

  • lamejs (JavaScript MP3 encoder)
  • uuid (for generating unique filenames)

Troubleshooting

  • Ensure the input Base64 string is correctly specified and valid; errors occur if the string is missing or invalid Base64.
  • Check that the input PCM audio buffer length is even; an odd length may indicate incomplete audio samples and cause warnings.
  • Verify the sample rate and channels parameters match the input audio data; incorrect settings can result in empty or corrupted MP3 output.
  • If encoding results in empty MP3 data, review audio parameters and input data integrity.

Links

Discussion