# @audio/decode-amr

> Decode AMR-NB/WB audio via opencore-amr WASM

Latest version **1.3.1** (published 2026-08-27) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install @audio/decode-amr
pnpm add @audio/decode-amr
yarn add @audio/decode-amr
bun add @audio/decode-amr
```

## Health

**Score 70/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; recently updated; high maintenance score; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 1.3.1 |
| Published | 2026-08-27 |
| First published | 2026-04-04 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=18 |
| Dependencies | 0 |
| Unpacked size | 254.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 208 |
| Author | audiojs |
| Maintainers | jamen, dfcreative, dy |
| Keywords | amr, amr-nb, amr-wb, audio, decode, decoder, wasm, opencore-amr, speech |

## Links

- npm: https://www.npmjs.com/package/@audio/decode-amr
- Repository: https://github.com/audiojs/decode
- Homepage: https://github.com/audiojs/decode/tree/master/packages/decode-amr#readme
- Issues: https://github.com/audiojs/decode/issues
- Funding: https://github.com/sponsors/audiojs
- npm.io page: https://npm.io/package/@audio/decode-amr

## Alternatives

- [flatbuffers](https://npm.io/package/flatbuffers.md) — 6.0M weekly downloads
- [jwt-simple](https://npm.io/package/jwt-simple.md) — 259.5K weekly downloads
- [@exodus/patch-broken-hermes-typed-arrays](https://npm.io/package/@exodus/patch-broken-hermes-typed-arrays.md) — 28.5K weekly downloads
- [@native-to-anchor/buffer-layout](https://npm.io/package/@native-to-anchor/buffer-layout.md) — 12.2K weekly downloads
- [binary-parser-encoder](https://npm.io/package/binary-parser-encoder.md) — 5.3K weekly downloads

## Recent versions

- 1.3.1 (latest) — 2026-08-27
- 1.3.0 — 2026-08-11
- 1.2.3 — 2026-07-14
- 1.2.2 — 2026-07-11
- 1.2.1 — 2026-07-10
- 1.2.0 — 2026-07-10
- 1.1.1 — 2026-04-11
- 1.1.0 — 2026-04-05
- 1.0.0 — 2026-04-04

## README

# @audio/decode-amr

Decode AMR-NB and AMR-WB audio to PCM float samples with [opencore-amr](https://sourceforge.net/projects/opencore-amr/) WASM.

## Install

```
npm i @audio/decode-amr
```

## Usage

```js
import decode from '@audio/decode-amr'

// AMR-NB or AMR-WB; auto-detected from the file header
let { channelData, sampleRate } = await decode(amrBuffer)
// AMR-NB: 8000 Hz mono
// AMR-WB: 16000 Hz mono
```

### Streaming

```js
import { decoder } from '@audio/decode-amr'

let dec = await decoder()
let result = dec.decode(chunk)
dec.free()
```

`decoder()` is asynchronous. Its `decode()` and `flush()` methods are synchronous.

## API

### `decode(src): Promise<AudioData>`

Whole-file decode. Accepts `Uint8Array` or `ArrayBuffer`. Auto-detects AMR-NB (`#!AMR\n`) vs AMR-WB (`#!AMR-WB\n`).

### `decoder(): Promise<AMRDecoder>`

Creates a decoder instance.

- `dec.decode(data)`: decode a `Uint8Array` or `ArrayBuffer` chunk.
- `dec.flush()`: discard buffered partial data and return an empty result.
- `dec.free()`: release WASM memory.

## Formats

- AMR-NB: 8 kHz, modes 0–7 (4.75–12.2 kbps)
- AMR-WB: 16 kHz, modes 0–8 (6.6–23.85 kbps)

## Building WASM

The WASM module is prebuilt in `src/amr.wasm.js`. To rebuild:

```
npm run build
```

This auto-fetches opencore-amr 0.1.6 source and compiles with Emscripten.

## License

[ॐ](https://github.com/krishnized/license/) · [Apache-2.0](./LICENSE) (opencore-amr)

---
_Source: https://npm.io/package/@audio/decode-amr · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
