https://github.com/synodriver/pysilk
stream encoder/decoder for silk and pcm
https://github.com/synodriver/pysilk
audio cffi cython decoder encoder pcm silk
Last synced: 29 days ago
JSON representation
stream encoder/decoder for silk and pcm
- Host: GitHub
- URL: https://github.com/synodriver/pysilk
- Owner: synodriver
- Created: 2021-02-09T07:14:13.000Z (over 4 years ago)
- Default Branch: v0.2
- Last Pushed: 2024-03-27T00:09:35.000Z (over 1 year ago)
- Last Synced: 2024-10-11T11:26:01.850Z (12 months ago)
- Topics: audio, cffi, cython, decoder, encoder, pcm, silk
- Language: Python
- Homepage:
- Size: 3.13 MB
- Stars: 17
- Watchers: 1
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.markdown
- Changelog: changename.py
Awesome Lists containing this project
README
✨ pysilk ✨
The python binding for silk-v3-decoder
[](https://pypi.org/project/silk-python/)




## 安装
```bash
pip install silk-python
```## 使用
- encode
```python
import pysilkwith open("verybiginput.pcm", "rb") as pcm, open("output.silk", "wb") as silk:
pysilk.encode(pcm, silk, 24000, 24000)
```- decode
```python
import pysilkwith open("verybiginput.silk", "rb") as silk, open("output.pcm", "wb") as pcm:
pysilk.decode(silk, pcm, 24000)
```## 支持功能
- 接受任何二进制的```file-like object```,比如```BytesIO```,可以流式解码大文件
- 包装了silk的全部C接口的参数,当然他们都有合理的默认值
- 基于```Cython```, [关键部位](https://github.com/synodriver/pysilk/blob/stream/pysilk/silk.pxd#L43-L65) 内联C函数,高性能## 公开函数
```python
from typing import BinaryIOdef encode(input: BinaryIO, output: BinaryIO, sample_rate: int, bit_rate: int, max_internal_sample_rate: int = 24000, packet_loss_percentage: int = 0, complexity: int = 2, use_inband_fec: bool = False, use_dtx: bool = False, tencent: bool = True) -> None: ...
def decode(input: BinaryIO, output: BinaryIO, sample_rate: int, frame_size: int = 0, frames_per_packet: int = 1, more_internal_decoder_frames: bool = False, in_band_fec_offset: int = 0, loss: bool = False) -> None: ...
```## 公开异常
```python
class SilkError(Exception):
pass
```### ✨v0.2.0✨
合并了[CFFI](https://github.com/synodriver/pysilk-cffi) 的工作### 本机编译
```
python -m pip install setuptools wheel cython cffi
git clone https://github.com/synodriver/pysilk
cd pysilk
git submodule update --init --recursive
python setup.py bdist_wheel --use-cython --use-cffi
```### 后端选择
默认由py实现决定,在cpython上自动选择cython后端,在pypy上自动选择cffi后端,使用```SILK_USE_CFFI```环境变量可以强制选择cffi