audio

@audio/encode-gsm0.1.0

Encode PCM audio to GSM 06.10 full rate

Encode PCM audio to GSM 06.10 full rate (libgsm WASM)

Status
pending calibration
Updated
Family
encode, 15 packages under it
Category
codecs
Licence
MIT AND TU-Berlin-2.0
Bundles
libgsm
Dependencies
none
Downloads
3,758 last month
Tests
at least 34 in audiojs/encode's CI, passed at 22bf060,

Encode PCM audio to GSM 06.10 full-rate speech (13 kbit/s, 8 kHz mono), with libgsm 1.0.22 (Jutta Degener and Carsten Bormann, TU Berlin) compiled to WASM.

Install

Usage

import gsm from '@audio/encode-gsm'

let enc = await gsm({ sampleRate: 8000 })
let bytes = enc.encode([samples])   // whole 33-byte frames as 160 samples fill each
let last = enc.flush()              // the last one, zero-padded
enc.free()

The output is raw frames: SoX's .gsm, RTP payload type 3. GSM runs at 8 kHz, mono: resample and pick a channel first. Samples are written as round(x·32768), clipped, as libgsm takes 16-bit PCM.

Tested

Byte for byte what SoX 14.4.2 (its libgsm) writes, whole and in chunks of any length.

License

MIT; libgsm under its own permissive notice (in LICENSE.libgsm).