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

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/644738.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

spring Cloud Stream 实战应用深度讲解

springCloudStream 简介 Spring Cloud Stream是一个框架&#xff0c;用于构建与共享消息传递系统连接的高度可扩展的事件驱动微服务。 该框架提供了一个灵活的编程模型&#xff0c;该模型建立在已经建立和熟悉的 Spring 习惯用语和最佳实践之上&#xff0c;包括对持久发布/订…

算法基础学习|双指针算法

双指针算法 代码模板 for (int i 0, j 0; i < n; i ){while (j < i && check(i, j)) j ;// 具体问题的逻辑 } 常见问题分类&#xff1a;(1) 对于一个序列&#xff0c;用两个指针维护一段区间(2) 对于两个序列&#xff0c;维护某种次序&#xff0c;比如归并…

Transformer and Pretrain Language Models3-1

content transformer attention mechanism transformer structure​​​​​​​ pretrained language models language modeling pre-trained langue models(PLMs&#xff09; fine-tuning approaches PLMs after BERT applications of masked LM frontiers of PLMs …

RocketMQ的一万字全面总结,带你快速入门消息队列

前言 近日偶然聊起消息队列&#xff0c;发现知识模糊又破碎&#xff0c;遂广泛查询资料&#xff0c;做了这么一篇非常浅显的总结&#xff0c;聊以充作入门参考资料吧。 下面几个问题&#xff0c;如果不能回答地很好&#xff0c;可以试着在文中找寻一下答案。&#xff08;答案…

时间序列大模型:TimeGPT

论文&#xff1a;https://arxiv.org/pdf/2310.03589.pdf TimeGPT&#xff0c;这是第一个用于时间序列的基础模型&#xff0c;能够为训练期间未见过的多样化数据集生成准确的预测。 大规模时间序列模型通过利用当代深度学习进步的能力&#xff0c;使精确预测和减少不确定性成为…

VSCode 更换默认的 terminal(终端)

Win10 中 VSCode 默认的 terminal 为 PowerShell, 想要更换为 Git bash。 1. 按快捷键&#xff1a;Ctrl Shift P 2. 搜索&#xff1a;“erminal: Select Default Profile” 3. 你会看到可选的终端列表&#xff0c;然后选择 Git Bash

3.Eureka注册中心

3.Eureka注册中心 假如我们的服务提供者user-service部署了多个实例&#xff0c;如图&#xff1a; 大家思考几个问题&#xff1a; order-service在发起远程调用的时候&#xff0c;该如何得知user-service实例的ip地址和端口&#xff1f;有多个user-service实例地址&#xff0…

JVM对象创建与内存回收机制

对象的创建过程有如下步骤&#xff1a; 1.类加载检查&#xff1a; 虚拟机遇到一个new指令时&#xff0c;首先将去检查这个指令的参数是否能在常量池中定位到一个类的符号引用&#xff0c;并且检查这个符号引用代表的类是否已被加载、解析和初始化过&#xff0c;如果没…

长城资产信息技术岗24届校招面试面经

本文介绍2024届秋招中&#xff0c;中国长城资产管理股份有限公司的信息技术岗岗位一面的面试基本情况、提问问题等。 10月投递了中国长城资产管理股份有限公司的信息技术岗岗位&#xff0c;所在部门为长城新盛信托有限责任公司。目前完成了一面&#xff0c;在这里记录一下一面经…

函数递归(Recursion)一篇便懂

递归的概念 在 C 语言中&#xff0c;递归&#xff08;Recursion&#xff09;是一种函数调用自身的编程技术。当一个函数在其定义中调用自身时&#xff0c;就称为递归函数。 了解递归思想 把⼀个大型复杂问题层层转化为⼀个与原问题相似&#xff0c;但规模较小的子问题来求解…

3.chrony服务器

目录 1. 简介 1.1. 重要性 1.2. Linux的两个时钟 1.3. 设置日期时间 1.3.1. timedatectl命令设置 1.3.2. date命令设置 1.4. NTP 1.5. Chrony介绍 2. 安装与配置 2.1. 安装&#xff1a; 2.2. Chrony配置文件分析 2.3. 同步时间服务器 2.3.1. 授时中心 2.3.2. 实验…

制造业中的数据治理

随着信息技术的飞速发展&#xff0c;数据已经成为现代制造业的核心资产。数据治理作为确保数据质量、安全性、可靠性和一致性的关键过程&#xff0c;对于提高生产效率和质量控制具有不可忽视的影响。本文将深入探讨制造业中数据治理的重要性、挑战和实践&#xff0c;以揭示其对…

HCIP:不同VLAN下实现网络互相通信

配置pc1 配置pc2 配置pc3 将sw1划分到vlan3 将sw3划分到vlan3 在sw1上进行缺省 将sw1上&#xff08;g0/0/1&#xff09;的untagged改成 1 3 则在pc1上ping pc2可通 在sw1上进行缺省 在sw3上&#xff08;e0/0/1&#xff09;打标记 则在pc1上ping pc3可通&#xff08;实现互通&am…

新特性Record最全用法总结---动力节点总结

目录 0、有用的新特性 一、Record 1.1、Record的介绍&#xff1a; 1.2、Record的声明&#xff1a; 1.3、Record的创建&#xff1a; 1.4、Record使用举例&#xff1a; 1.5、Record-实例方法、静态方法 1.6、Record-三类构造方法 1.6.1、紧凑型构造、定制构造方法&#…

服务器的组成

服务器的重要结构组成 家用电脑组成&#xff1a; CPU、主板、内存条、显卡、硬盘、电源、风扇、网卡、显示器、机箱、键盘鼠标等等。 CPU CPU是电脑的大脑&#xff0c; CPU发展史&#xff1a; 32 位CPU&#xff1a;最大的内存寻址地址2^32&#xff0c;大约4G的大小。 CP…

爬虫进阶之selenium模拟浏览器

爬虫进阶之selenium模拟浏览器 简介环境配置1、建议先安装conda2、创建虚拟环境并安装对应的包3、下载对应的谷歌驱动以及与驱动对应的浏览器 代码setting.py配置scrapy脚本参考中间件middlewares.py 附录&#xff1a;selenium教程 简介 Selenium是一个用于自动化浏览器操作的…

CSS 楼梯弹弹球

<template><view class="loader"></view> </template><script></script><style>body {background-color: #212121;/* 设置背景颜色为 #212121 */}.loader {position: relative;/* 设置定位为相对定位 */width: 120px;/* 设…

38-WEB漏洞-反序列化之PHPJAVA全解(下)

WEB漏洞-反序列化之PHP&JAVA全解&#xff08;下&#xff09; 一、Java中API实现二、序列化理解三、案例演示3.1、本地3.2、Java 反序列化及命令执行代码测试3.3、WebGoat_Javaweb 靶场反序列化测试3.4、2020-网鼎杯-朱雀组-Web-think_java 真题复现 四、涉及资源 一、Java中…

springboot118共享汽车管理系统

简介 【毕设源码推荐 javaweb 项目】基于springbootvue 的共享汽车管理系统 适用于计算机类毕业设计&#xff0c;课程设计参考与学习用途。仅供学习参考&#xff0c; 不得用于商业或者非法用途&#xff0c;否则&#xff0c;一切后果请用户自负。 看运行截图看 第五章 第四章 获…

『论文阅读|2024 WACV 多目标跟踪Deep-EloU|纯中文版』

论文题目&#xff1a; Iterative Scale-Up ExpansionIoU and Deep Features Association for Multi-Object Tracking in Sports 论文特点&#xff1a; 作者提出了一种迭代扩展的 ExpansionIoU 和深度特征关联方法Deep-EIoU&#xff0c;用于体育场景中的多目标跟踪&#xff0c;旨…