Download mobile/modules/engine/src/utils/pcmToBase64.ts from Anirudh1950/MentraOS: direct link, hf CLI and curl.
- Browser
- Download file 370 Bytes
-
https://huggingface.co/Anirudh1950/MentraOS/resolve/main/mobile/modules/engine/src/utils/pcmToBase64.ts
- Command line
-
hf download hf://Anirudh1950/MentraOS/mobile/modules/engine/src/utils/pcmToBase64.ts
-
curl -L -o pcmToBase64.ts https://huggingface.co/Anirudh1950/MentraOS/resolve/main/mobile/modules/engine/src/utils/pcmToBase64.ts
370 Bytes
| /** Encode decoded LC3 PCM for native sinks. Hermes has btoa, but no Node Buffer. */ | |
| export function pcmToBase64(pcm: ArrayBuffer): string { | |
| const bytes = new Uint8Array(pcm) | |
| let binary = "" | |
| const step = 0x8000 | |
| for (let i = 0; i < bytes.length; i += step) { | |
| binary += String.fromCharCode(...bytes.subarray(i, i + step)) | |
| } | |
| return btoa(binary) | |
| } | |