webassembly003 whisper.cpp的python绑定实现+Cython+Setuptools

2024-01-25 15:52

本文主要是介绍webassembly003 whisper.cpp的python绑定实现+Cython+Setuptools,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

python绑定项目

  • 官方未提供python的封装绑定,直接调用执行文件
    在这里插入图片描述

  • https://github.com/stlukey/whispercpp.py提供了源码和Cpython结合的绑定

  • https://github.com/zhujun1980/whispercpp_py提供了ctype方式的绑定,需要先make libwhisper.so

  • Pybind11 bindings for Whisper.cpp,有更好的类型安全性和性能

Setuptools

  • setuptools 是 Python 中用于构建和分发软件包的工具,它提供了一种简化和标准化的方式来定义和管理项目的元数据、依赖关系以及构建过程。

安装

pip install setuptools

示例:setup.py 封装python实现的add 模块

  • 项目结构如下:
my_package/
|-- my_package/
|   |-- __init__.py # NULL
|   |-- add.py
|-- setup.py
|-- README.md
  • add.py
# add.py
def add(a, b):return a + b
  • setup.py
# setup.py
from setuptools import setup, find_packagessetup(name="my_package",version="1.0",packages=find_packages(),install_requires=[# Specify your project dependencies here],
)
  • 构建和安装

在项目根目录下运行以下命令:python setup.py build,python setup.py install

其他构建方式:打tar包/tar包安装,打egg包/egg包安装,打whl包/whl包安装

  • 使用
from my_package import addresult = add.add(3, 4)
print(result)  # 输出 7

3. 项目依赖和包管理

setup.py 中,使用 install_requires 列表来指定项目的依赖关系。当用户安装你的包时,这些依赖关系将会自动安装。

5. 使用 setuptools 扩展

如果你的项目包含 C 或 C++ 扩展,你可以使用 setuptools.Extension 来指定这些扩展。以下是一个简单的例子:

from setuptools import setup, Extensionext_module = Extension('your_module',  # 模块名称sources=['your_module.c'],  # 源代码文件
)setup(name="your_package",version="1.0",ext_modules=[ext_module],
)

构建 Cython 扩展

Cython基础

.pxd 文件,.pyx 文件,.pyd 文件

文件类型描述
.pxd 文件由 Cython 编程语言编写的 Python 扩展模块头文件。类似于 C 语言的 .h 头文件。包含模块的声明和代码段。可共享外部 C 语言声明,也能包含 C 编译器内联函数。为 .pyx 文件提供接口,以便其他 Cython 模块可以使用更高效的协议与之通信。可使用 cimport 关键字将 .pxd 文件导入 .pyx 模块文件中。
.pyx 文件由 Cython 编程语言编写的 Python 扩展模块源代码文件。类似于 C 语言的 .c 源代码文件。包含模块的源代码。必须先编译成 .c 文件,再编译成 .pyd(Windows)或 .so(Linux)文件,方可导入和使用。
.pyd 文件由非 Python 编程语言编写并编译生成的 Python 扩展模块。在 Python 中使用时,通过 import 语句导入。实际上,在 .pyd 文件中封装了一个模块。Cython 可以将个人基于 Python 的模块编译成具有 C 语言特性的 .pyd 文件。

常见的 Cython 数据类型:

1. 基本整数类型:

  • int:标准整数类型。
  • long:长整数类型。
  • bint:布尔类型。
cdef int a = 42
cdef long b = 1234567890123456789
cdef bint flag = True

2. 浮点数类型:

  • float:标准浮点数类型。
  • double:双精度浮点数类型。
cdef float x = 3.14
cdef double y = 2.71828

3. 数组和缓冲区类型:

  • list:Python 列表。
  • tuple:Python 元组。
  • array:Cython 提供的数组类型。
cdef list py_list = [1, 2, 3]
cdef tuple py_tuple = (4, 5, 6)
cdef int[:] cython_array = array([7, 8, 9])

4. 字符串类型:

  • str:Python 字符串类型。
  • bytes:字节类型。
cdef str py_string = "Hello"
cdef bytes cython_bytes = b"World"
bytes

在 CPython(即官方的 Python 解释器)中,bytes 对象是不可变的序列,用于存储二进制数据。它与 bytearray 对象的主要区别在于,bytes 对象是不可变的,而 bytearray 对象是可变的。

以下是关于 bytes 对象的一些基本信息:

  1. 不可变性bytes 对象是不可变的,这意味着一旦创建,其内容不能被修改。你不能像列表一样通过索引赋值来改变 bytes 对象中的某个元素。

  2. 字节表示bytes 对象包含一系列字节,每个字节的值范围在 0 到 255 之间。字节以整数表示,并可以使用 b'...' 语法来创建 bytes 字面值。

    # 创建bytes对象
    b = b'Hello, World!'
    
  3. 字节序列的操作bytes 支持与字节序列相关的许多操作,例如索引、切片、长度计算等。

    # 使用索引获取字节值
    print(b[0])  # 输出 72 (ASCII码中 'H' 的值)# 使用切片获取部分字节序列
    print(b[7:])  # 输出 b'World!'# 计算字节序列的长度
    print(len(b))  # 输出 13
    
  4. 不可变性的好处bytes 对象的不可变性使得它适用于表示一些固定不变的二进制数据,例如文件内容、网络数据等。此外,由于不可变性,bytes 对象可以作为字典的键,而 bytearray 对象不能。

    # 不可变性允许bytes对象作为字典键
    data_dict = {b'key': 'value'}
    
  5. 内置方法bytes 类型提供了一些内置方法,如 decode() 用于将字节解码为字符串,hex() 用于获取字节的十六进制表示。

    # 解码为字符串
    string_representation = b.decode('utf-8')# 获取十六进制表示
    hex_representation = b.hex()
    
  • 这将创建一个 Python 字节字符串对象,该对象包含 原始 C 字符串。它可以在 Python 代码中安全地传递,并且 将在对它的最后一个引用结束时进行垃圾回收 范围。重要的是要记住,字符串中的 null 字节会起作用 作为终止符字符,通常从 C 中知道。以上将 因此,仅适用于不包含 null 的 C 字符串 字节。

5. 其他类型:

  • object:Python 对象类型,通常用于处理任意类型的对象。
  • memoryview:内存视图类型,用于处理内存缓冲区。
  • pointer:指针类型,用于与 C 语言中的指针进行交互。
cdef object generic_object = some_function()
cdef memoryview buffer_view = memoryview(some_buffer)
cdef int* ptr = <int*>some_pointer

6. 并行迭代类型:

  • prange:并行迭代类型,用于在循环中实现并行迭代。
from cython.parallel import prangecdef int i
for i in prange(10):# 在此进行并行迭代的操作

这些类型提供了在 Cython 中进行类型声明和优化的灵活性。选择适当的类型取决于你的算法和数据的特性,以及在 Cython 中进行性能优化的目标。

Cpython的强制类型转换

在 Cython 中,与 C 类型相关的强制类型转换通常是通过 C 的类型声明和类型转换函数来实现的。以下是一些常见的 Cython 中的类型转换示例:

1. C 的类型声明

在 Cython 中,可以使用 C 的类型声明来明确变量的类型。例如,对于整数、浮点数和字符类型:

cdef int x = 42
cdef double y = 3.14
cdef char c = 'A'

2. Python 对象到 C 类型的转换

使用 (<C类型>) 语法将 Python 对象强制转换为 C 类型。例如,将 Python 中的整数对象转换为 C 中的整数:

cdef int py_int = 42
cdef int c_int = <int>py_int

3. C 类型到 Python 对象的转换

使用 (<Python类型>) 语法将 C 类型强制转换为 Python 对象。例如,将 C 中的整数转换为 Python 中的整数对象:

cdef int c_int = 42
cdef object py_int = <object>c_int

4. 使用 cast() 函数

Cython 还提供了 cast() 函数,用于进行更复杂的类型转换。这对于在不同的 C 类型之间进行转换非常有用:

from cython cimport castcdef int c_int = 42
cdef double c_double = cast(double, c_int)

5. 使用 numpy 中的类型转换

如果涉及到 NumPy 数组,可以使用 numpy 模块提供的一些函数进行类型转换:

import numpy as np
cimport numpy as npcdef np.ndarray[np.int32_t, ndim=1] int_array = np.array([1, 2, 3], dtype=np.int32)
cdef np.ndarray[np.float64_t, ndim=1] float_array = int_array.astype(np.float64)

这些是 Cython 中一些常见的类型转换方法。根据具体的应用场景,你可能需要使用不同的方式进行类型转换。在进行类型转换时,请确保转换是安全的,以避免潜在的错误和问题。

cythonize和pyx

cythonize 是 Cython 提供的一个用于编译 Cython 源文件的命令。它将 Cython 源文件(.pyx)转换为 C 代码,然后编译为共享库(.so 文件或相应平台的文件)。如果使用了 Cython 编写 C 扩展,可以使用 setuptools 配合 Cython.Build.cythonize 来构建,然后,可以使用以下命令构建并安装:python setup.py build_ext --inplace

基本用法:

setup.py 文件中使用 cythonize 来构建和编译 Cython 源文件。通常,cythonize 接受一个包含 .pyx 文件路径的列表,然后返回一个用于设置的 Extension 对象列表。

# setup.py
from setuptools import setup
from Cython.Build import cythonizesetup(ext_modules=cythonize("your_module.pyx"),# ext_modules=cythonize(["module1.pyx", "module2.pyx"]), # 处理多个文件:# ext_modules=cythonize("your_module.pyx", compiler_directives={'boundscheck': False}), # 额外的编译选项
)
使用 annotate 生成 HTML 文件:

annotate 选项用于生成包含注释的 HTML 文件,以便查看 C 代码中哪些部分是由 Cython 自动生成的。这有助于理解性能瓶颈和进行调试。

# setup.py
from setuptools import setup
from Cython.Build import cythonizesetup(ext_modules=cythonize("your_module.pyx", annotate=True),
)

Cython+setup.py 封装add 模块

  • 正确编译的.so文件在python当中就是module
    cython(.pyx, .pxi)-> c/c++ -> so

项目结构:

my_package/
|-- add/
|   |-- add.c
|   |-- add.h
|-- my_package/
|   |-- __init__.py
|   |-- add_wrapper.pyx
|-- setup.py
|-- README.md

代码

// add.c
int add(int a, int b) {return a + b;
}
// add.h
int add(int a, int b);
# add_wrapper.pyx
cdef extern from "add.h":int add(int a, int b)def add_py(int a, int b):return add(a, b)
# setup.py
from setuptools import setup, Extension
from Cython.Build import cythonize# Extension module
ext_module = Extension("my_package.add_wrapper",  # Python模块名称sources=["my_package/add_wrapper.pyx",  # Cython源文件"add/add.c",  # C源文件],include_dirs=["add/"],  # 包含的头文件目录
)setup(name="my_package",version="1.0",packages=["my_package"],ext_modules=cythonize([ext_module]),zip_safe=False,
)

构建和安装

python setup.py build_ext --inplace
from my_package import add_wrapperresult = add_wrapper.add_py(3, 4)
print(result)  # 输出 7

whispercpp.py的setup.py

# 从distutils和Cython导入必要的模块
from distutils.core import setup
from distutils.extension import Extension
from Cython.Build import cythonize# 导入用于平台检测的额外模块
import numpy, os, sys# 根据平台检测设置相应的环境变量
if sys.platform == 'darwin':  # macOSos.environ['CFLAGS']   = '-DGGML_USE_ACCELERATE -O3 -std=gnu11'os.environ['CXXFLAGS'] = '-DGGML_USE_ACCELERATE -O3 -std=c++11'os.environ['LDFLAGS']  = '-framework Accelerate'
else:  # 其他平台(假定为类Linux)os.environ['CFLAGS']   = '-mavx -mavx2 -mfma -mf16c -O3 -std=gnu11'os.environ['CXXFLAGS'] = '-mavx -mavx2 -mfma -mf16c -O3 -std=c++11'# 定义Cython扩展模块
ext_modules = [Extension(name="whispercpp",sources=["whispercpp.pyx", "whisper.cpp/whisper.cpp"],language="c++",extra_compile_args=["-std=c++11"],)
]# 使用cythonize函数编译Cython扩展模块
ext_modules = cythonize(ext_modules)# 定义whisper.cpp的C库
whisper_clib = ('whisper_clib', {'sources': ['whisper.cpp/ggml.c']})# 使用setup函数配置Python包
setup(name='whispercpp',version='1.0',description='whisper.cpp的Python绑定',author='Luke Southam',author_email='luke@devthe.com',libraries=[whisper_clib],  # 指定C库ext_modules=cythonize("whispercpp.pyx"),  # 包含Cython扩展模块include_dirs=['./whisper.cpp/', numpy.get_include()],  # 编译时包含的目录install_requires=['numpy','ffmpeg-python','requests'],  # 指定依赖项
)

whispercpp.pxd

cdef nogil:# 使用 'nogil' 语句告诉Cython编译器在以下代码段中不需要GIL (Global Interpreter Lock),多线程并行int WHISPER_SAMPLE_RATE = 16000  # 采样率int WHISPER_N_FFT = 400  # FFT点数int WHISPER_N_MEL = 80  # 梅尔滤波器数量int WHISPER_HOP_LENGTH = 160  # 帧移int WHISPER_CHUNK_SIZE = 30  # 音频块大小int SAMPLE_RATE = 16000  # 采样率char* TEST_FILE = b'test.wav'  # 测试文件名char* DEFAULT_MODEL = b'ggml-tiny.bin'  # 默认模型文件名char* LANGUAGE = b'fr'  # 语言# 定义一个C语言结构体,用于存储音频数据的相关信息。ctypedef struct audio_data:float* frames;  # 指向浮点数数组的指针,存储音频帧int n_frames;  # 音频帧的数量
cdef extern from "whisper.h" nogil:# 使用 'extern from' 语句声明与外部C语言头文件 "whisper.h" 相关的一些元素# 定义枚举类型 whisper_sampling_strategyenum whisper_sampling_strategy:WHISPER_SAMPLING_GREEDY = 0,WHISPER_SAMPLING_BEAM_SEARCH,ctypedef bint _Bool# 定义一个函数指针类型 whisper_new_segment_callback,该函数用于接收新的语音片段的回调。ctypedef void (*whisper_new_segment_callback)(whisper_context*, int, void*)# 定义一个函数指针类型 whisper_encoder_begin_callback,该函数用于编码器开始的回调。ctypedef _Bool whisper_encoder_begin_callback(whisper_context*, void*)ctypedef int whisper_token# 定义结构体 whisper_token_datactypedef struct whisper_token_data:whisper_token idwhisper_token tidfloat pfloat ptfloat ptsumint64_t t0int64_t t1float vlen

whispercpp.pyx

# 导入需要的模块和类型
cimport numpy as cnp
import ffmpeg
import numpy as np# 声明 load_audio 函数,接受一个字节数组 file 和一个可选的采样率参数 sr
cdef cnp.ndarray[cnp.float32_t, ndim=1, mode="c"] load_audio(bytes file, int sr = SAMPLE_RATE):try:# 使用 ffmpeg 库读取音频文件out = (ffmpeg.input(file, threads=0).output("-", format="s16le",acodec="pcm_s16le",ac=1, ar=sr).run(cmd=["ffmpeg", "-nostdin"],capture_stdout=True,capture_stderr=True))[0]except:# 处理异常,如果文件不存在则抛出 RuntimeErrorraise RuntimeError(f"File '{file}' not found")# 将二进制音频数据转换为 NumPy 数组cdef cnp.ndarray[cnp.float32_t, ndim=1, mode="c"] frames = (np.frombuffer(out, np.int16)  # 将二进制数据解析为 int16 的 NumPy 数组.flatten()  # 展平数组.astype(np.float32)  # 转换元素类型为 float32) / pow(2, 15)  # 归一化到 [-1, 1] 范围# 返回处理后的音频数据return frames
def transcribe(self, filename=TEST_FILE):# 打印加载数据的提示信息print("Loading data..")# 检查传入的文件名是否是NumPy数组if (type(filename) == np.ndarray):temp = filename# 如果传入的是字符串文件名,使用load_audio函数加载音频数据elif (type(filename) == str):temp = load_audio(<bytes>filename)  # 如果没有提供文件名,使用默认的TEST_FILEelse:temp = load_audio(<bytes>TEST_FILE) # 将加载的音频数据转换为Cython的NumPy数组类型# 声明一个一维的 NumPy 数组 frames,元素类型为 float32,使用 "c"(连续存储)模式cdef cnp.ndarray[cnp.float32_t, ndim=1, mode="c"] frames = temp# 打印转录的提示信息print("Transcribing..")# 调用Cython扩展中的whisper_full函数进行音频转录,传递上下文、参数和音频数据的指针return whisper_full(self.ctx, self.params, &frames[0], len(frames))
    def extract_text(self, int res):print("Extracting text...")if res != 0:raise RuntimeErrorcdef int n_segments = whisper_full_n_segments(self.ctx)return [whisper_full_get_segment_text(self.ctx, i).decode() for i in range(n_segments)]

test.py

from whispercpp import Whisperw = Whisper('large',model_path= "/home/pdd/myassets/ggml-medium.bin")
result = w.transcribe("/home/pdd/le/pywhisper/output.wav") # result = w.transcribe("myfile.mp3")
text = w.extract_text(result)
print(text)
# git clone --recurse-submodules https://github.com/stlukey/whispercpp.py.git
cdef class Whisper:cdef whisper_context * ctxcdef whisper_full_params paramsdef __init__(self, model=DEFAULT_MODEL,model_path= None ,pb=None, buf=None):model_fullname = f'ggml-{model}.bin'download_model(model_fullname)if model_path==None:model_path= Path(MODELS_DIR).joinpath(model_fullname) cdef bytes model_b = str(model_path).encode('utf8')if buf is not None:self.ctx = whisper_init_from_buffer(buf, buf.size)else:self.ctx = whisper_init_from_file(model_b)self.params = default_params()whisper_print_system_info()
$ pip install numpy
$ python setup.py build
$ python setup.py install
/home/pdd/anaconda3/envs/mwi/lib/python3.10/site-packages/setuptools/_distutils/cmd.py:66: SetuptoolsDeprecationWarning: setup.py install is deprecated.
!!********************************************************************************Please avoid running ``setup.py`` directly.Instead, use pypa/build, pypa/installer or otherstandards-based tools.See https://blog.ganssle.io/articles/2021/10/setup-py-deprecated.html for details.********************************************************************************!!self.initialize_options()
/home/pdd/anaconda3/envs/mwi/lib/python3.10/site-packages/setuptools/_distutils/cmd.py:66: EasyInstallDeprecationWarning: easy_install command is deprecated.
!!********************************************************************************Please avoid running ``setup.py`` and ``easy_install``.Instead, use pypa/build, pypa/installer or otherstandards-based tools.See https://github.com/pypa/setuptools/issues/917 for details.********************************************************************************!!self.initialize_options()
zip_safe flag not set; analyzing archive contents...
__pycache__.whispercpp.cpython-310: module references __file__
/home/pdd/anaconda3/envs/mwi/lib/python3.10/site-packages/setuptools/config/setupcfg.py:293: _DeprecatedConfig: Deprecated config in `setup.cfg`
!!********************************************************************************The license_file parameter is deprecated, use license_files instead.This deprecation is overdue, please update your project and remove deprecatedcalls to avoid build errors in the future.See https://setuptools.pypa.io/en/latest/userguide/declarative_config.html for details.********************************************************************************!!parsed = self.parsers.get(option_name, lambda x: x)(value)
warning: no files found matching '*.au' under directory 'tests'
warning: no files found matching '*.gif' under directory 'tests'
warning: no files found matching '*.txt' under directory 'tests'
/home/pdd/anaconda3/envs/mwi/lib/python3.10/site-packages/setuptools/_distutils/cmd.py:66: SetuptoolsDeprecationWarning: setup.py install is deprecated.
!!********************************************************************************Please avoid running ``setup.py`` directly.Instead, use pypa/build, pypa/installer or otherstandards-based tools.See https://blog.ganssle.io/articles/2021/10/setup-py-deprecated.html for details.********************************************************************************!!self.initialize_options()
zip_safe flag not set; analyzing archive contents...
future.backports.test.__pycache__.ssl_servers.cpython-310: module references __file__
future.backports.test.__pycache__.support.cpython-310: module references __file__
future.standard_library.__pycache__.__init__.cpython-310: module references __file__
future.standard_library.__pycache__.__init__.cpython-310: module references __path__
future.utils.__pycache__.__init__.cpython-310: module MAY be using inspect.stack
past.builtins.__pycache__.misc.cpython-310: module MAY be using inspect.stack
past.translation.__pycache__.__init__.cpython-310: module references __file__
past.translation.__pycache__.__init__.cpython-310: module references __path__
Adding future 0.18.3 to easy-install.pth file
detected new path './charset_normalizer-3.3.2-py3.10-linux-x86_64.egg'
Installing futurize script to /home/pdd/anaconda3/envs/mwi/bin
Installing pasteurize script to /home/pdd/anaconda3/envs/mwi/binInstalled /home/pdd/anaconda3/envs/mwi/lib/python3.10/site-packages/future-0.18.3-py3.10.egg
Searching for numpy==1.26.3
Best match: numpy 1.26.3
Adding numpy 1.26.3 to easy-install.pth file
detected new path './future-0.18.3-py3.10.egg'
Installing f2py script to /home/pdd/anaconda3/envs/mwi/binUsing /home/pdd/anaconda3/envs/mwi/lib/python3.10/site-packages
Finished processing dependencies for whispercpp==1.0

CG

  • Python 的 .py 与 Cython 的 .pxd .pyx .pyd 文件格式之间的主要区别

  • pip install git+https://github.com/stlukey/whispercpp.py

$ pip install git+https://github.com/stlukey/whispercpp.py
Looking in indexes: https://pypi.org/simple, https://pypi.ngc.nvidia.com
Collecting git+https://github.com/stlukey/whispercpp.pyCloning https://github.com/stlukey/whispercpp.py to /tmp/pip-req-build-a3w_pl8yRunning command git clone --filter=blob:none --quiet https://github.com/stlukey/whispercpp.py /tmp/pip-req-build-a3w_pl8yResolved https://github.com/stlukey/whispercpp.py to commit 7af678159c29edb3bc2a51a72665073d58f2352fRunning command git submodule update --init --recursive -qInstalling build dependencies ... doneGetting requirements to build wheel ... donePreparing metadata (pyproject.toml) ... done
Collecting numpy (from whispercpp==1.0)Downloading numpy-1.26.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (61 kB)━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 61.2/61.2 kB 455.1 kB/s eta 0:00:00
Collecting ffmpeg-python (from whispercpp==1.0)Downloading ffmpeg_python-0.2.0-py3-none-any.whl (25 kB)
Collecting requests (from whispercpp==1.0)Downloading requests-2.31.0-py3-none-any.whl.metadata (4.6 kB)
Collecting future (from ffmpeg-python->whispercpp==1.0)Downloading future-0.18.3.tar.gz (840 kB)━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 840.9/840.9 kB 766.4 kB/s eta 0:00:00Preparing metadata (setup.py) ... done
Collecting charset-normalizer<4,>=2 (from requests->whispercpp==1.0)Downloading charset_normalizer-3.3.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (33 kB)
Collecting idna<4,>=2.5 (from requests->whispercpp==1.0)Downloading idna-3.6-py3-none-any.whl.metadata (9.9 kB)
Collecting urllib3<3,>=1.21.1 (from requests->whispercpp==1.0)Downloading urllib3-2.1.0-py3-none-any.whl.metadata (6.4 kB)
Collecting certifi>=2017.4.17 (from requests->whispercpp==1.0)Downloading certifi-2023.11.17-py3-none-any.whl.metadata (2.2 kB)
Downloading numpy-1.26.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (18.2 MB)━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 18.2/18.2 MB 1.2 MB/s eta 0:00:00
Downloading requests-2.31.0-py3-none-any.whl (62 kB)━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 62.6/62.6 kB 1.3 MB/s eta 0:00:00
Downloading certifi-2023.11.17-py3-none-any.whl (162 kB)━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 162.5/162.5 kB 1.2 MB/s eta 0:00:00
Downloading charset_normalizer-3.3.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (142 kB)━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 142.1/142.1 kB 1.2 MB/s eta 0:00:00
Downloading idna-3.6-py3-none-any.whl (61 kB)━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 61.6/61.6 kB 1.4 MB/s eta 0:00:00
Downloading urllib3-2.1.0-py3-none-any.whl (104 kB)━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 104.6/104.6 kB 1.1 MB/s eta 0:00:00
Building wheels for collected packages: whispercpp, futureBuilding wheel for whispercpp (pyproject.toml) ... doneCreated wheel for whispercpp: filename=whispercpp-1.0-cp310-cp310-linux_x86_64.whl size=282976 sha256=4d3d98884e99b8b884435550b64ef03f5b47bac9348b90c75b45f350fb24f82cStored in directory: /tmp/pip-ephem-wheel-cache-k94yja86/wheels/66/a1/a8/e5b342b3d6d1b65b787546ee9d5a1d948c8ab3db3c879d7df1Building wheel for future (setup.py) ... doneCreated wheel for future: filename=future-0.18.3-py3-none-any.whl size=492024 sha256=672e398dc922fcc5cc49da626a356ed3c27f184cc2811e11438c9e51d0a7f60dStored in directory: /tmp/pip-ephem-wheel-cache-k94yja86/wheels/5e/a9/47/f118e66afd12240e4662752cc22cefae5d97275623aa8ef57d
Successfully built whispercpp future
Installing collected packages: urllib3, numpy, idna, future, charset-normalizer, certifi, requests, ffmpeg-python, whispercpp
Successfully installed certifi-2023.11.17 charset-normalizer-3.3.2 ffmpeg-python-0.2.0 future-0.18.3 idna-3.6 numpy-1.26.3 requests-2.31.0 urllib3-2.1.0 whispercpp-1.0

这篇关于webassembly003 whisper.cpp的python绑定实现+Cython+Setuptools的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/643778

相关文章

C++对象布局及多态实现探索之内存布局(整理的很多链接)

本文通过观察对象的内存布局,跟踪函数调用的汇编代码。分析了C++对象内存的布局情况,虚函数的执行方式,以及虚继承,等等 文章链接:http://dev.yesky.com/254/2191254.shtml      论C/C++函数间动态内存的传递 (2005-07-30)   当你涉及到C/C++的核心编程的时候,你会无止境地与内存管理打交道。 文章链接:http://dev.yesky

通过SSH隧道实现通过远程服务器上外网

搭建隧道 autossh -M 0 -f -D 1080 -C -N user1@remotehost##验证隧道是否生效,查看1080端口是否启动netstat -tuln | grep 1080## 测试ssh 隧道是否生效curl -x socks5h://127.0.0.1:1080 -I http://www.github.com 将autossh 设置为服务,隧道开机启动

Python 字符串占位

在Python中,可以使用字符串的格式化方法来实现字符串的占位。常见的方法有百分号操作符 % 以及 str.format() 方法 百分号操作符 % name = "张三"age = 20message = "我叫%s,今年%d岁。" % (name, age)print(message) # 我叫张三,今年20岁。 str.format() 方法 name = "张三"age

时序预测 | MATLAB实现LSTM时间序列未来多步预测-递归预测

时序预测 | MATLAB实现LSTM时间序列未来多步预测-递归预测 目录 时序预测 | MATLAB实现LSTM时间序列未来多步预测-递归预测基本介绍程序设计参考资料 基本介绍 MATLAB实现LSTM时间序列未来多步预测-递归预测。LSTM是一种含有LSTM区块(blocks)或其他的一种类神经网络,文献或其他资料中LSTM区块可能被描述成智能网络单元,因为

vue项目集成CanvasEditor实现Word在线编辑器

CanvasEditor实现Word在线编辑器 官网文档:https://hufe.club/canvas-editor-docs/guide/schema.html 源码地址:https://github.com/Hufe921/canvas-editor 前提声明: 由于CanvasEditor目前不支持vue、react 等框架开箱即用版,所以需要我们去Git下载源码,拿到其中两个主

android一键分享功能部分实现

为什么叫做部分实现呢,其实是我只实现一部分的分享。如新浪微博,那还有没去实现的是微信分享。还有一部分奇怪的问题:我QQ分享跟QQ空间的分享功能,我都没配置key那些都是原本集成就有的key也可以实现分享,谁清楚的麻烦详解下。 实现分享功能我们可以去www.mob.com这个网站集成。免费的,而且还有短信验证功能。等这分享研究完后就研究下短信验证功能。 开始实现步骤(新浪分享,以下是本人自己实现

基于Springboot + vue 的抗疫物质管理系统的设计与实现

目录 📚 前言 📑摘要 📑系统流程 📚 系统架构设计 📚 数据库设计 📚 系统功能的具体实现    💬 系统登录注册 系统登录 登录界面   用户添加  💬 抗疫列表展示模块     区域信息管理 添加物资详情 抗疫物资列表展示 抗疫物资申请 抗疫物资审核 ✒️ 源码实现 💖 源码获取 😁 联系方式 📚 前言 📑博客主页:

探索蓝牙协议的奥秘:用ESP32实现高质量蓝牙音频传输

蓝牙(Bluetooth)是一种短距离无线通信技术,广泛应用于各种电子设备之间的数据传输。自1994年由爱立信公司首次提出以来,蓝牙技术已经经历了多个版本的更新和改进。本文将详细介绍蓝牙协议,并通过一个具体的项目——使用ESP32实现蓝牙音频传输,来展示蓝牙协议的实际应用及其优点。 蓝牙协议概述 蓝牙协议栈 蓝牙协议栈是蓝牙技术的核心,定义了蓝牙设备之间如何进行通信。蓝牙协议

一道经典Python程序样例带你飞速掌握Python的字典和列表

Python中的列表(list)和字典(dict)是两种常用的数据结构,它们在数据组织和存储方面有很大的不同。 列表(List) 列表是Python中的一种有序集合,可以随时添加和删除其中的元素。列表中的元素可以是任何数据类型,包括数字、字符串、其他列表等。列表使用方括号[]表示,元素之间用逗号,分隔。 定义和使用 # 定义一个列表 fruits = ['apple', 'banana

Python应用开发——30天学习Streamlit Python包进行APP的构建(9)

st.area_chart 显示区域图。 这是围绕 st.altair_chart 的语法糖。主要区别在于该命令使用数据自身的列和指数来计算图表的 Altair 规格。因此,在许多 "只需绘制此图 "的情况下,该命令更易于使用,但可定制性较差。 如果 st.area_chart 无法正确猜测数据规格,请尝试使用 st.altair_chart 指定所需的图表。 Function signa