wavDecoder.ts

electron-speech-to-speech · wav-decoding, audio-decoding, audio-processing, voice

https://github.com/mohayonao/wav-decoder

// Source: https://github.com/Kutalia/electron-speech-to-speech | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works
// Provided via justclaw.it.com; keep this notice with the code.
// https://github.com/mohayonao/wav-decoder

interface Opts {
  symmetric?: boolean
}

interface Format {
  formatId: number
  floatingPoint: boolean
  numberOfChannels: number
  sampleRate: number
  byteRate: number
  blockSize: number
  bitDepth: number
}

const formats = {
  0x0001: 'lpcm',
  0x0003: 'lpcm'
}

function decodeSync(buffer: ArrayBuffer, opts?: Opts): ReturnType<typeof decodeData> {
  opts = opts || {}

  const dataView = new DataView(buffer)
  const reader = createReader(dataView)

  if (reader.string(4) !== 'RIFF') {
    throw new TypeError('Invalid WAV

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

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

Get a free API key