getAudioFileInfo (TextToSpeech/audioFormat.js)

anything-llm · server/utils/TextToSpeech/audioFormat.js · javascript · MIT
voice

Module exposing: getAudioFileInfo

// Source: https://github.com/Mintplex-Labs/anything-llm | License: MIT | Copyright Mintplex Labs Inc
// Provided via justclaw.it.com; keep this notice with the code.
const AUDIO_FORMATS = {
  flac: { mime: "audio/flac", extension: ".flac" },
  m4a: { mime: "audio/mp4", extension: ".m4a" },
  mp3: { mime: "audio/mpeg", extension: ".mp3" },
  ogg: { mime: "audio/ogg", extension: ".ogg" },
  wav: { mime: "audio/wav", extension: ".wav" },
  webm: { mime: "audio/webm", extension: ".webm" },
};

/**
 * Detect the container of an audio buffer from its file signature.
 * Defaults to MP3 to preserve the existing behavior for unknown data.
 * @param {Buffer} buffer
 * @returns {{mime: string, extension: string}}
 */
function getAudioFileInfo(buffer) {
  if (!Buffer.isBuffer(buffer)) return AUDIO_FO

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key