-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
170 changed files
with
30,586 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
root = true | ||
|
||
[*.{py,c,cpp,h,rst,md,yml}] | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
indent_style = space | ||
|
||
[*.{py,c,cpp,h}] | ||
indent_size = 4 | ||
|
||
[*.yml] | ||
indent_size = 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
cmake_minimum_required(VERSION 3.21) | ||
project(silk_voice VERSION 1.0.0) | ||
|
||
# 设置编译类型,也可在CLION设置中设置 | ||
# set(CMAKE_BUILD_TYPE Release) | ||
|
||
set(CMAKE_C_STANDARD 99) | ||
set(CMAKE_C_STANDARD_REQUIRED True) | ||
|
||
# Python相关 | ||
set(PYTHON_HOME "C:/Users/foyou/AppData/Local/Programs/Python/Python310") | ||
include_directories(${PYTHON_HOME}/include) | ||
link_directories(${PYTHON_HOME}/libs) | ||
|
||
# silk | ||
include_directories(src/interface) | ||
include_directories(src/SKP_SILK_SRC) | ||
|
||
add_library(pilk SHARED src/pilkmodule.c) | ||
|
||
add_subdirectory(src/SKP_SILK_SRC) | ||
|
||
target_link_libraries(pilk PUBLIC SKP_Silk_SDK) | ||
|
||
# 设置动态库属性 | ||
SET_TARGET_PROPERTIES( | ||
pilk PROPERTIES | ||
RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/dev | ||
PREFIX "" | ||
OUTPUT_NAME "_pilk_d" | ||
SUFFIX ".pyd" | ||
) | ||
|
||
if (CMAKE_BUILD_TYPE MATCHES Debug) | ||
message(" ") | ||
message("CMAKE IN DEBUG MODE") | ||
message(" ") | ||
elseif (CMAKE_BUILD_TYPE MATCHES Release) | ||
message(" ") | ||
message("CMAKE IN RELEASE MODE") | ||
message(" ") | ||
endif () |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
include src/interface/*.h | ||
include src/SKP_SILK_SRC/*.h |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from ._pilk import * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
def encode( | ||
pcm: str, | ||
silk: str = None, | ||
pcm_rate: int = 24000, | ||
silk_rate: int = None, | ||
tencent: bool = False, | ||
max_rate: int = 24000, | ||
complexity: int = 2, | ||
packet_size: int = 20, | ||
packet_loss: int = 0, | ||
use_in_band_fec: bool = False, | ||
use_dtx: bool = False | ||
) -> tuple[str, int]: | ||
"""silk 编码 | ||
:param pcm: str: pcm 格式文件路径 | ||
:param silk: str[可选]: 编码完成的 silk 文件路径, 默认为 `pcm`参数 + '.silk' | ||
:param pcm_rate: int(hz)[可选]: 输入 pcm 文件的 rate, 默认: 24000. 可选值为 [8000, 12000, 16000, 24000, 32000, 44100, 48000] | ||
:param silk_rate: int(8000~48000 hz)[可选]: 默认: 与 pcm_rate 一致,输出 silk 文件的 rate | ||
:param tencent: bool[可选]: 默认: False, 是否兼容腾讯系语音 | ||
:param max_rate: int[可选]: 默认: 24000, 最大内部采样率, 可选值为 [8000, 12000, 16000, 24000] | ||
:param complexity: int[可选]: Set complexity, 0: low, 1: medium, 2: high; default: 2 | ||
:param packet_size: Packet interval in ms, default: 20 | ||
:param packet_loss: Uplink loss estimate, in percent (0-100); default: 0 | ||
:param use_in_band_fec: Enable inband FEC usage (0/1); default: 0 | ||
:param use_dtx: Enable DTX (0/1); default: 0 | ||
:return: (<silk文件路径>, <silk文件持续时间>) | ||
""" | ||
|
||
|
||
def decode( | ||
silk: str, | ||
pcm: str = None, | ||
pcm_rate: int = 24000, | ||
packet_loss: int = 0 | ||
) -> tuple[str, int]: | ||
"""silk 解码 | ||
:param silk: str: silk 输入文件路径 | ||
:param pcm: str[可选]: pcm 输出文件路径, 未提供则使用 `silk` 参数 + '.pcm' | ||
:param pcm_rate: int(hz)[可选]: 输入 pcm 文件的 rate, 默认: 24000. 可选值为 [8000, 12000, 16000, 24000, 32000, 44100, 48000] | ||
:param packet_loss: Uplink loss estimate, in percent (0-100); default: 0 | ||
:return: (<pcm 文件路径>, <pcm 文件时间>) | ||
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[build-system] | ||
requires = ["setuptools>=42", "wheel"] | ||
build-backend = "setuptools.build_meta" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
from glob import glob | ||
|
||
from setuptools import setup, Extension | ||
|
||
SKP_SILK_SRC = 'src/SKP_SILK_SRC/' | ||
sources = glob(SKP_SILK_SRC + '*.c') | ||
sources.append('src/pilkmodule.c') | ||
|
||
pilk = Extension( | ||
name='pilk._pilk', | ||
sources=sources, | ||
include_dirs=[SKP_SILK_SRC, 'src/interface'] | ||
) | ||
|
||
with open('README.md', encoding='utf8') as f: | ||
long_description = f.read() | ||
|
||
setup( | ||
name='pilk', | ||
version='1.0.0', | ||
description='python silk voice library', | ||
long_description=long_description, | ||
author='foyou', | ||
author_email='[email protected]', | ||
maintainer='foyou', | ||
maintainer_email='[email protected]', | ||
url='https://github.com/foyoux/pilk', | ||
download_url='https://github.com/foyoux/pilk/releases', | ||
license_files=['LICENSE'], | ||
keywords=['silk', 'voice', 'python', 'extension', 'wechat', 'qq', 'tencent', 'xposed', 'c/c++'], | ||
python_requires='>=3.6', | ||
ext_modules=[pilk], | ||
zip_safe=False, | ||
packages=['pilk'], | ||
package_data={ | ||
'pilk': ['_pilk.pyi'] | ||
}, | ||
classifiers=[ | ||
'Development Status :: 4 - Beta', | ||
'License :: OSI Approved :: GNU General Public License v3 (GPLv3)', | ||
'Intended Audience :: End Users/Desktop', | ||
'Natural Language :: Chinese (Simplified)', | ||
'Operating System :: Microsoft :: Windows', | ||
'Operating System :: POSIX', | ||
'Programming Language :: C', | ||
'Programming Language :: Python', | ||
'Programming Language :: Python :: 3', | ||
'Programming Language :: Python :: 3.6', | ||
'Programming Language :: Python :: 3.7', | ||
'Programming Language :: Python :: 3.8', | ||
'Programming Language :: Python :: 3.9', | ||
'Programming Language :: Python :: 3.10', | ||
'Programming Language :: Python :: 3.11', | ||
'Topic :: Multimedia :: Sound/Audio' | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
include_directories(../interface) | ||
aux_source_directory(. SKP_Silk_SDK) | ||
add_library(SKP_Silk_SDK ${SKP_Silk_SDK}) |
Oops, something went wrong.