Skip to main content

transform audio file to silk

Project description

Graiax-silkcoder

现在版本:pypi
这,是一个Python的silk转码器
通过将kn007/silk-v3-decoder通过简单的封装制成

安装

# 如果需要转换非wav的音频文件,则需要自行安装ffmpeg
pip install graiax-silkcoder
# 也可以通过下面的方式使用imageio-ffmpeg中的ffmpeg
pip install graiax-silkcoder[ffmpeg]

注: 假设你是Windows用户,安装时出现了error: Microsoft Visual C++ 14.0 is required: 请安装Microsoft C++ Build Tools

自定义ffmpeg_path

可能有一些用户会想要自定义ffmpeg的路径 你可以使用以下方法解决:

from graiax import silkcoder
silkcoder.set_ffmpeg_path = "./ffmpeg"

使用方法

from pathlib import Path
from graiax import silkcoder

#silk编码
#你可以文件→文件
await silkcoder.encode('a.wav', 'a.silk')
#你可以文件→二进制数据
silk: bytes=await silkcoder.encode('a.wav')
#你可以二进制数据→二进制数据
silk: bytes=await silkcoder.encode(Path('a.wav').read_bytes())
#你可以二进制数据→文件
await silkcoder.encode(Path('a.wav').read_bytes(), audio_format='wav', 'a.silk')
#你可以指定让ffmpeg解码音频,也可以让程序自己选择
#注:只有当音频是wav且ensure_ffmpeg=None时才会不使用ffmpeg处理
await silkcoder.encode('a.wav', 'a.silk', ensure_ffmpeg=True)
#你也可以设置码率(默认状态下将会将尝试将目标语音大小限制在980kb上下)
await silkcoder.encode('a.wav', 'a.silk', rate=70000)
#你甚至可以剪辑音频
await silkcoder.encode('a.wav', 'a.silk', ss=10, t=5)#从第10s开始剪辑5s的音频

#silk解码
#你可以文件→文件
await silkcoder.decode('a.silk', 'a.wav')
#你可以文件→二进制数据
wav: bytes=await silkcoder.decode('a.silk')
#你可以二进制数据→二进制数据(必填audio_format)
mp3: bytes=await silkcoder.decode(Path('a.silk').read_bytes(), audio_format='mp3')
#你可以二进制数据→文件
await silkcoder.decode(Path('a.silk').read_bytes(), 'a.wav')
#你可以指定让ffmpeg解码音频,也可以让程序自己选择
#注:只有当音频是wav且ensure_ffmpeg=None时才会不使用ffmpeg处理
await silkcoder.decode('a.silk', 'a.wav', ensure_ffmpeg=True)
#你也可以直接传入ffmpeg参数来输出
await silkcoder.decode('a.silk', 'a.mp3', ffmpeg_para=['-ab', '320k'])

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

graiax-silkcoder-0.1.0.tar.gz (206.2 kB view details)

Uploaded Source

Built Distributions

graiax_silkcoder-0.1.0-cp310-cp310-win_amd64.whl (123.4 kB view details)

Uploaded CPython 3.10 Windows x86-64

graiax_silkcoder-0.1.0-cp310-cp310-win32.whl (105.3 kB view details)

Uploaded CPython 3.10 Windows x86

graiax_silkcoder-0.1.0-cp39-cp39-win_amd64.whl (123.3 kB view details)

Uploaded CPython 3.9 Windows x86-64

graiax_silkcoder-0.1.0-cp39-cp39-win32.whl (105.3 kB view details)

Uploaded CPython 3.9 Windows x86

graiax_silkcoder-0.1.0-cp38-cp38-win_amd64.whl (123.4 kB view details)

Uploaded CPython 3.8 Windows x86-64

graiax_silkcoder-0.1.0-cp38-cp38-win32.whl (105.2 kB view details)

Uploaded CPython 3.8 Windows x86

File details

Details for the file graiax-silkcoder-0.1.0.tar.gz.

File metadata

  • Download URL: graiax-silkcoder-0.1.0.tar.gz
  • Upload date:
  • Size: 206.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.0 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10

File hashes

Hashes for graiax-silkcoder-0.1.0.tar.gz
Algorithm Hash digest
SHA256 6c001b49786f5efcbc9459fbe5b44bf6e50babdeb19d621320d2c0a788573f7b
MD5 9e1957daa29a1442ac47ab12ab626faa
BLAKE2b-256 33545a7b750b67acef9e6d10dc8c3fd4a5007c17031c3a06fe3abcd425c98b41

See more details on using hashes here.

File details

Details for the file graiax_silkcoder-0.1.0-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: graiax_silkcoder-0.1.0-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 123.4 kB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.0 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.0

File hashes

Hashes for graiax_silkcoder-0.1.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 9967ac66839924b9397dc44255cf3ec2c69f493647e5b097f57f2ee4b324b8a3
MD5 f770a94d4cba273f4cf012f117e5e7e7
BLAKE2b-256 4ca2e9bbafd5dace04abc0728f8451caa36e6bad190a06eeb36cd5a943de8a84

See more details on using hashes here.

File details

Details for the file graiax_silkcoder-0.1.0-cp310-cp310-win32.whl.

File metadata

  • Download URL: graiax_silkcoder-0.1.0-cp310-cp310-win32.whl
  • Upload date:
  • Size: 105.3 kB
  • Tags: CPython 3.10, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.0 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.0

File hashes

Hashes for graiax_silkcoder-0.1.0-cp310-cp310-win32.whl
Algorithm Hash digest
SHA256 c09b20bcdcc9da31ec1646ed231a907ded4aa8bcddeaaac8764388edf8430fab
MD5 43541c5909d65425229d98cc1542b4ed
BLAKE2b-256 6d5cb498e2dcd009267d4eac9cd6db35b7d3fbcec16c4301d7bd360280ad8ca2

See more details on using hashes here.

File details

Details for the file graiax_silkcoder-0.1.0-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: graiax_silkcoder-0.1.0-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 123.3 kB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.0 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

File hashes

Hashes for graiax_silkcoder-0.1.0-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 0f57e70b6156060ecb887b190f80da82920f85c08c4828e35c027029e4b2d4ef
MD5 b1716b66cec30b4cdd472fe93f1b2fb3
BLAKE2b-256 64457ed7c71262996b5b5857064b0c43a9d8003285954ccec9a4affcfcd78fa7

See more details on using hashes here.

File details

Details for the file graiax_silkcoder-0.1.0-cp39-cp39-win32.whl.

File metadata

  • Download URL: graiax_silkcoder-0.1.0-cp39-cp39-win32.whl
  • Upload date:
  • Size: 105.3 kB
  • Tags: CPython 3.9, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.0 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

File hashes

Hashes for graiax_silkcoder-0.1.0-cp39-cp39-win32.whl
Algorithm Hash digest
SHA256 5874f4de9abcb6b4b13f2df35274390cceb395a820b4d065b23cab10f10d0c7e
MD5 1b261e4f337a1ce95dad8dc492711aae
BLAKE2b-256 62719314a82c517ee1dc69377ff1f77740302f9e9ad2d03076e6d85fcc18e848

See more details on using hashes here.

File details

Details for the file graiax_silkcoder-0.1.0-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: graiax_silkcoder-0.1.0-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 123.4 kB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.0 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10

File hashes

Hashes for graiax_silkcoder-0.1.0-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 35f0f44d131da8264924aa17b274c7f3bd48f1f346f5cf3d99e736cbd5a42dde
MD5 64ae0608a3cfcdfc0920d4bd78e31853
BLAKE2b-256 c08837a4d8c092533cbc5c6dd009996bb7b24f28767b3560c8f79b3877bd1e96

See more details on using hashes here.

File details

Details for the file graiax_silkcoder-0.1.0-cp38-cp38-win32.whl.

File metadata

  • Download URL: graiax_silkcoder-0.1.0-cp38-cp38-win32.whl
  • Upload date:
  • Size: 105.2 kB
  • Tags: CPython 3.8, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.0 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10

File hashes

Hashes for graiax_silkcoder-0.1.0-cp38-cp38-win32.whl
Algorithm Hash digest
SHA256 ed60f8d6329eb92dbb7f00340d19bcf04117f614ecac51a6ae82b611783cf738
MD5 d7d04d9966f307e03e4a7a42a031c915
BLAKE2b-256 75978f7d579b3b3c2bf42d494593a34ad7b5ef0823527fbe7ee8af30bb3acc5b

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page