Skip to content

Tencent silk encoder for Node.js and browser

License

Notifications You must be signed in to change notification settings

OpenMystere/silk-wasm

 
 

Repository files navigation

Silk Wasm

npm

QQ/微信语音编解码

API

interface encodeResult {
    data: Uint8Array
    duration: number
}

interface decodeResult {
    data: Uint8Array
    duration: number
}
// pcm 转 silk。input 为单声道 pcm_s16le 文件,samplingRate 为采样率。 
function encode(input: Uint8Array, sampleRate: number): Promise<encodeResult>

// silk 转 pcm。input 为 silk 文件,samplingRate 为采样率。 
function decode(input: Uint8Array, sampleRate: number): Promise<decodeResult>

// 获取 silk 音频时长,输出单位为毫秒。
function getDuration(silk: Uint8Array, frameMs?: number): number

Example

const { encode } = require('silk-wasm');
const { readFile, writeFile } = require('fs/promises');

(async function () {
    const pcm = await readFile('./test.pcm')
    const silk = await encode(pcm, 24000)
    await writeFile('./test.silk', silk.data)
})()

Build wasm

cd binding
emcmake cmake .
emmake make

About

Tencent silk encoder for Node.js and browser

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C 86.2%
  • Assembly 11.5%
  • Shell 0.7%
  • Batchfile 0.7%
  • CMake 0.6%
  • TypeScript 0.2%
  • Other 0.1%