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.1.tar.gz (206.3 kB view details)

Uploaded Source

Built Distributions

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

Uploaded CPython 3.10 Windows x86-64

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

Uploaded CPython 3.10 Windows x86

graiax_silkcoder-0.1.1-cp39-cp39-win_amd64.whl (123.4 kB view details)

Uploaded CPython 3.9 Windows x86-64

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

Uploaded CPython 3.9 Windows x86

graiax_silkcoder-0.1.1-cp38-cp38-win_amd64.whl (123.5 kB view details)

Uploaded CPython 3.8 Windows x86-64

graiax_silkcoder-0.1.1-cp38-cp38-win32.whl (105.3 kB view details)

Uploaded CPython 3.8 Windows x86

File details

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

File metadata

  • Download URL: graiax-silkcoder-0.1.1.tar.gz
  • Upload date:
  • Size: 206.3 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.9.9

File hashes

Hashes for graiax-silkcoder-0.1.1.tar.gz
Algorithm Hash digest
SHA256 2928985db87c2ad8543794ae28dfb9e4ece7f4bd7c39b5a15d160796a05a846a
MD5 5b12d6a56dcb9d0e0acfda5e5ef631a8
BLAKE2b-256 38114dd959d0727eeffb019ad8fb64e7951b2d8c0c61fe73520c5a154f620802

See more details on using hashes here.

File details

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

File metadata

  • Download URL: graiax_silkcoder-0.1.1-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.1-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 93cb9746965224236a1b9c0b3300f88598b02170f12ffd76beb6de44be67ddee
MD5 f0cfa8dd62124677773697ef6ec5c18e
BLAKE2b-256 0e4481824bcbf96c1dae389ab4846272429919104339408aa9fa472790a6f346

See more details on using hashes here.

File details

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

File metadata

  • Download URL: graiax_silkcoder-0.1.1-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.1-cp310-cp310-win32.whl
Algorithm Hash digest
SHA256 2201712fcdd10ab185a7e30ed06b50d1e845f225c508dd4ccefb535224d29e76
MD5 3729f3b7f425e32b5e6d3bfb683bd9f8
BLAKE2b-256 0d598c4c2cc83e6dd1a9f9a822a539a018b31f03220965439a73b43564e8e99c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: graiax_silkcoder-0.1.1-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 123.4 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.1-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 f4e056394a61e72b22d93f1cf1fb3af865de7d1f91f53b474cdbd3ddc05b4846
MD5 4cee158d5442c85ce9348ff7e5b2ac77
BLAKE2b-256 f85cf1df25ecbdf7a98602bebe69a33de71094e762ae4d308108c23e1d8a3df1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: graiax_silkcoder-0.1.1-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.1-cp39-cp39-win32.whl
Algorithm Hash digest
SHA256 32f664478407d702cc3ad83319e3655cd379c12c0bdeec8aa3cb8df5ab4e0e83
MD5 aed1ba3baf9d5d4d52223acd88b6496a
BLAKE2b-256 094fca168f0f47d290ab6ab8d9f97e46481548f97e8d03e6f88a76812589e7fc

See more details on using hashes here.

File details

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

File metadata

  • Download URL: graiax_silkcoder-0.1.1-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 123.5 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.1-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 d187ed0f8c1f67cbefcfb8c4575a49a71053adff274e4f3a8ac8aa704ffb8f60
MD5 ad50245288c415c4bd43888231049bec
BLAKE2b-256 3d558eee32a853cbc026d77ea7971b4aa52f541054a805c0ae859b63454e0782

See more details on using hashes here.

File details

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

File metadata

  • Download URL: graiax_silkcoder-0.1.1-cp38-cp38-win32.whl
  • Upload date:
  • Size: 105.3 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.1-cp38-cp38-win32.whl
Algorithm Hash digest
SHA256 dc6345371417312f313113d39127a157fef3f72d5df2e16d16c94066bd88f32f
MD5 aecf344bd0599f7828c78509425d18f9
BLAKE2b-256 e21e155f10cde5a11e7e11a30130a2605e2f3151bc4e832814c8a680a179ea11

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