0.2.2 • Published 5 years ago

silk-sdk v0.2.2

Weekly downloads
4
License
MIT
Repository
github
Last release
5 years ago

Silk SDK

This is node-gyp version of Silk SDK library (see https://developer.skype.com/silk for details.)

Installation

To install this package, please run:

npm install silk-sdk

or

yarn add silk-sdk

If you wish to use cli tool, try install globally using:

npm install silk-sdk --global

or

yarn global add silk-sdk

Command Usage

decode

To decode silk format audio, run:

silk-sdk decode [input] [output]

where input is the name of input file and output is the name of output file. You can pass further options after, availables are shown below:

  • -q, --quiet Whether there is any output into console (default: false)
  • --lossProb lossProb Simulated packet loss percentage (0-100) (default: 0)
  • --fsHz fs Sampling rate of output signal in Hz (default: 24000)

encode

To encode audio to silk format, run:

silk-sdk encode [input] [output]

where input is the name of input file and output is the name of output file. You can pass further options after, availables are shown below:

  • -q, --quiet Whether there is any output into console (default: false)
  • --fsHz fs API sampling rate in Hz (default: 24000)
  • --fxMaxInternal fxMaxInternal Maximum internal sampling rate in Hz (default: 0)
  • --packetLength packageLength Packet interval in ms (default: 20)
  • --rate Target bitrate (default: 25000)
  • --loss Uplink loss estimate, in percent (0-100) (default: 0)
  • --complexity Set complexity, 0: low, 1: medium, 2: high (default: 2)
  • --inbandFEC Enable inband FEC usage (default: false)
  • --dtx Enable DTX (default: false)
  • --tencent Add Tencent (Wechat, QQ) header in exported file (default: false)
  • --tencentAmr Add Tencent AMR header in exported file (default: false)

compare

To compare to silk format audio files, run:

silk-sdk compare [ref] [test]

where ref is the name of first file and test is the name of second file. You can pass further options after, availables are shown below:

  • -q, --quiet Whether there is any output into console (default: false)
  • --diff Only determine bit-exactness (default: false)
  • --fs Sampling rate in Hz, max is 48000 (default: 24000)

API Usage

decode

This API will decode silk format audio. It's return value and behavior will change depends on the parameters provided.

Stream.Transform decode(options)

ParameterTypeRequiredDescription
optionsobjectfalseOptional options, see below for details

This API will return a transform stream, which can be used to consume input stream and generate decode stream.

Exmaple usage:

fs.createReadStream('input-path-here')
  .pipe(silk.decode({ quiet: true }))
  .pipe(fs.createWriteStream('output-path-here'));

buffer decode(input, options)

ParameterTypeRequiredDescription
inputstring/buffertrueBitstream input to decoder
optionsobjectfalseOptional options, see below for details

For first parameter input, you can pass in either string or buffer. If string is provided, it will be used as path of file; if buffer is provided, it should be the buffer of input file.

This API will return a decoded buffer that can be either saved in file or used by other APIs.

Example usage:

fs.writeFileSync(silk.decode('input-path-here', { quiet: true }));

void decode(input, output, options)

ParameterTypeRequiredDescription
inputstring/buffertrueBitstream input to decoder
outputstringtrueSpeech output (file path) from decoder
optionsobjectfalseOptional options, see below for details

For first parameter input, you can pass in either string or buffer. If string is provided, it will be used as path of file; if buffer is provided, it should be the buffer of input file.

No return for this API, decode result will be saved to output path directly.

Example usage:

silk.decode('./input.silk', './output.pcm', { quiet: true });

Options

AttributeTypeDefaultDescription
quietbooleantrueWhether there is any output into console
lossProbfloat0Simulated packet loss percentage (0-100)
fsHzint24000Sampling rate of output signal in Hz

encode

This API will encode speech input to silk format. It's return value and behavior will change depends on the parameters provided.

Stream.Transform encode(options)

ParameterTypeRequiredDescription
optionsobjectfalseOptional options, see below for details

This API will return a transform stream, which can be used to consume input stream and generate decode stream.

Exmaple usage:

fs.createReadStream('input-path-here')
  .pipe(silk.encode({ quiet: true }))
  .pipe(fs.createWriteStream('output-path-here'));

buffer encode(input, options)

ParameterTypeRequiredDescription
inputstring/buffertrueSpeech input to encoder
optionsobjectfalseOptional options, see below for details

For first parameter input, you can pass in either string or buffer. If string is provided, it will be used as path of file; if buffer is provided, it should be the buffer of input file.

This API will return a encoded buffer that can be either saved in file or used by other APIs.

Example usage:

fs.writeFileSync(silk.encode('input-path-here', { quiet: true }));

void decode(input, output, options)

ParameterTypeRequiredDescription
inputstring/buffertrueSpeech input to encoder
outputstringtrueBitstream output from encoder
optionsobjectfalseOptional options, see below for details

For first parameter input, you can pass in either string or buffer. If string is provided, it will be used as path of file; if buffer is provided, it should be the buffer of input file.

No return for this API, encode result will be saved to output path directly.

Example usage:

silk.encode('./input.silk', './output.pcm', { quiet: true });

Options

AttributeTypeDefaultDescription
quietbooleantrueWhether there is any output into console
fsHzint24000API sampling rate in Hz
fxMaxInternalint0Maximum internal sampling rate in Hz
packetLengthint20Packet interval in ms
rateint25000Target bitrate
lossint0Uplink loss estimate, in percent (0-100)
complexityint2Set complexity, 0: low, 1: medium, 2: high
inbandFECbooleanfalseEnable inband FEC usage
dtxbooleanfalseEnable DTX
tencentbooleanfalseAdd Tencent (Wechat, QQ) header in exported file
tencentAmrbooleanfalseAdd Tencent AMR header in exported file

compare

bool compare(input, output, stream)

Compare two audio files.

ParameterTypeRequiredDescription
inputAstring/buffertrueReference file
inputBstring/buffertrueFile to be tested, should be of same length as inputA (pcm)
optionsobjectfalseOptional options, see below for details

For both inputA and inputB, you can pass in either string or buffer. If string is provided, it will be used as path of file; if buffer is provided, it should be the buffer of input file.

Below are possible options for compare.

AttributeTypeDefaultDescription
quietbooleantrueWhether there is any output into console
diffbooleanfalseOnly determine bit-exactness
fsint24000Sampling rate in Hz, max is 48000

Example usage:

const silk = require('silk-sdk');
silk.compare('./ref.pcm', './test.pcm', { quiet: true });

License

This wrap of original Silk SDK code is under MIT License. For Silk SDK itself, please check their license for details.

0.2.2

5 years ago

0.2.1

5 years ago

0.2.0

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago

0.12.0

8 years ago

0.0.2-0

8 years ago