daihui.zhang
commited on
Commit
·
9e66f7d
1
Parent(s):
25d38b7
update llamacpp install and add to readme
Browse files- .gitignore +1 -1
- README.md +14 -1
- pyproject.toml +0 -2
- transcribe/utils.py +1 -1
- transcribe/whisper_llm_serve.py +2 -2
- uv.lock +0 -56
.gitignore
CHANGED
|
@@ -72,7 +72,7 @@ docs/_build/
|
|
| 72 |
# PyBuilder
|
| 73 |
.pybuilder/
|
| 74 |
target/
|
| 75 |
-
|
| 76 |
# Jupyter Notebook
|
| 77 |
.ipynb_checkpoints
|
| 78 |
|
|
|
|
| 72 |
# PyBuilder
|
| 73 |
.pybuilder/
|
| 74 |
target/
|
| 75 |
+
llama-cpp-python/
|
| 76 |
# Jupyter Notebook
|
| 77 |
.ipynb_checkpoints
|
| 78 |
|
README.md
CHANGED
|
@@ -8,4 +8,17 @@ license: mit
|
|
| 8 |
> 2. `python run_server.py`
|
| 9 |
|
| 10 |
## 前端
|
| 11 |
-
> 文件路径: frontend/index.html打开浏览器即可运行
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
> 2. `python run_server.py`
|
| 9 |
|
| 10 |
## 前端
|
| 11 |
+
> 文件路径: frontend/index.html打开浏览器即可运行
|
| 12 |
+
|
| 13 |
+
## whispercpp安装
|
| 14 |
+
> git clone --recurse-submodules https://github.com/absadiki/pywhispercpp.git
|
| 15 |
+
> git checkout d43237bd75076615349004270a721e3ebe1deabb
|
| 16 |
+
> WHISPER_COREML=1 pip setup.py install
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
## Llama-cpp-python
|
| 20 |
+
> git clone --recurse-submodules https://github.com/abetlen/llama-cpp-python.git
|
| 21 |
+
> cd llama-cpp-python && git checkout 0580cf273debf4a7f2efcdfd5ef092ff5cedf9b0
|
| 22 |
+
> cd llama-cpp-python/vendor/llama.cpp &7 git checkout ecebbd292d741ac084cf248146b2cfb17002aa1d
|
| 23 |
+
|
| 24 |
+
> 安装命令: CMAKE_ARGS="-DGGML_METAL=on" pip install -e .
|
pyproject.toml
CHANGED
|
@@ -7,12 +7,10 @@ requires-python = ">=3.11"
|
|
| 7 |
dependencies = [
|
| 8 |
"av>=14.2.0",
|
| 9 |
"librosa>=0.11.0",
|
| 10 |
-
"llama-cpp-python>=0.3.8",
|
| 11 |
"numpy>=2.1.3",
|
| 12 |
"onnxruntime>=1.21.0",
|
| 13 |
"pyaudio>=0.2.14",
|
| 14 |
"pydantic>=2.11.2",
|
| 15 |
-
"pywhispercpp>=1.3.0",
|
| 16 |
"setuptools>=78.1.0",
|
| 17 |
"soundfile>=0.13.1",
|
| 18 |
"torch>=2.6.0",
|
|
|
|
| 7 |
dependencies = [
|
| 8 |
"av>=14.2.0",
|
| 9 |
"librosa>=0.11.0",
|
|
|
|
| 10 |
"numpy>=2.1.3",
|
| 11 |
"onnxruntime>=1.21.0",
|
| 12 |
"pyaudio>=0.2.14",
|
| 13 |
"pydantic>=2.11.2",
|
|
|
|
| 14 |
"setuptools>=78.1.0",
|
| 15 |
"soundfile>=0.13.1",
|
| 16 |
"torch>=2.6.0",
|
transcribe/utils.py
CHANGED
|
@@ -7,7 +7,7 @@ import logging
|
|
| 7 |
import av
|
| 8 |
def log_block(key: str, value, unit=''):
|
| 9 |
"""格式化输出日志内容"""
|
| 10 |
-
key_fmt = f"[{key.ljust(25)}]" # 左对齐填充
|
| 11 |
val_fmt = f"{value} {unit}".strip()
|
| 12 |
logging.info(f"{key_fmt}: {val_fmt}")
|
| 13 |
|
|
|
|
| 7 |
import av
|
| 8 |
def log_block(key: str, value, unit=''):
|
| 9 |
"""格式化输出日志内容"""
|
| 10 |
+
key_fmt = f"[ {key.ljust(25)}]" # 左对齐填充
|
| 11 |
val_fmt = f"{value} {unit}".strip()
|
| 12 |
logging.info(f"{key_fmt}: {val_fmt}")
|
| 13 |
|
transcribe/whisper_llm_serve.py
CHANGED
|
@@ -129,13 +129,13 @@ class PyWhiperCppServe(ServeClientBase):
|
|
| 129 |
return None, left_watch_string, right_watch_string, is_end_sentence
|
| 130 |
|
| 131 |
def speech_to_text(self):
|
| 132 |
-
c = 0
|
| 133 |
while True:
|
| 134 |
if self.exit:
|
| 135 |
logger.info("Exiting speech to text thread")
|
| 136 |
break
|
| 137 |
|
| 138 |
-
if self.frames_np is None:
|
| 139 |
time.sleep(0.02) # wait for any audio to arrive
|
| 140 |
continue
|
| 141 |
|
|
|
|
| 129 |
return None, left_watch_string, right_watch_string, is_end_sentence
|
| 130 |
|
| 131 |
def speech_to_text(self):
|
| 132 |
+
# c = 0
|
| 133 |
while True:
|
| 134 |
if self.exit:
|
| 135 |
logger.info("Exiting speech to text thread")
|
| 136 |
break
|
| 137 |
|
| 138 |
+
if self.frames_np is None or self.frames_np.shape[0] < self.sample_rate * 2:
|
| 139 |
time.sleep(0.02) # wait for any audio to arrive
|
| 140 |
continue
|
| 141 |
|
uv.lock
CHANGED
|
@@ -223,15 +223,6 @@ wheels = [
|
|
| 223 |
{ url = "https://files.pythonhosted.org/packages/4e/8c/f3147f5c4b73e7550fe5f9352eaa956ae838d5c51eb58e7a25b9f3e2643b/decorator-5.2.1-py3-none-any.whl", hash = "sha256:d316bb415a2d9e2d2b3abcc4084c6502fc09240e292cd76a76afc106a1c8e04a", size = 9190 },
|
| 224 |
]
|
| 225 |
|
| 226 |
-
[[package]]
|
| 227 |
-
name = "diskcache"
|
| 228 |
-
version = "5.6.3"
|
| 229 |
-
source = { registry = "https://pypi.org/simple" }
|
| 230 |
-
sdist = { url = "https://files.pythonhosted.org/packages/3f/21/1c1ffc1a039ddcc459db43cc108658f32c57d271d7289a2794e401d0fdb6/diskcache-5.6.3.tar.gz", hash = "sha256:2c3a3fa2743d8535d832ec61c2054a1641f41775aa7c556758a109941e33e4fc", size = 67916 }
|
| 231 |
-
wheels = [
|
| 232 |
-
{ url = "https://files.pythonhosted.org/packages/3f/27/4570e78fc0bf5ea0ca45eb1de3818a23787af9b390c0b0a0033a1b8236f9/diskcache-5.6.3-py3-none-any.whl", hash = "sha256:5e31b2d5fbad117cc363ebaf6b689474db18a1f6438bc82358b024abd4c2ca19", size = 45550 },
|
| 233 |
-
]
|
| 234 |
-
|
| 235 |
[[package]]
|
| 236 |
name = "filelock"
|
| 237 |
version = "3.18.0"
|
|
@@ -339,18 +330,6 @@ wheels = [
|
|
| 339 |
{ url = "https://files.pythonhosted.org/packages/b5/ba/c63c5786dfee4c3417094c4b00966e61e4a63efecee22cb7b4c0387dda83/librosa-0.11.0-py3-none-any.whl", hash = "sha256:0b6415c4fd68bff4c29288abe67c6d80b587e0e1e2cfb0aad23e4559504a7fa1", size = 260749 },
|
| 340 |
]
|
| 341 |
|
| 342 |
-
[[package]]
|
| 343 |
-
name = "llama-cpp-python"
|
| 344 |
-
version = "0.3.8"
|
| 345 |
-
source = { registry = "https://pypi.org/simple" }
|
| 346 |
-
dependencies = [
|
| 347 |
-
{ name = "diskcache" },
|
| 348 |
-
{ name = "jinja2" },
|
| 349 |
-
{ name = "numpy" },
|
| 350 |
-
{ name = "typing-extensions" },
|
| 351 |
-
]
|
| 352 |
-
sdist = { url = "https://files.pythonhosted.org/packages/95/4e/da912ff2bf9bf855c86e8b1ae9fe1eaedf47d75a66728896b533901c4610/llama_cpp_python-0.3.8.tar.gz", hash = "sha256:31c91323b555c025a76a30923cead9f5695da103dd68c15cdbb4509b17f0ed77", size = 67301056 }
|
| 353 |
-
|
| 354 |
[[package]]
|
| 355 |
name = "llvmlite"
|
| 356 |
version = "0.44.0"
|
|
@@ -861,37 +840,6 @@ wheels = [
|
|
| 861 |
{ url = "https://files.pythonhosted.org/packages/5a/dc/491b7661614ab97483abf2056be1deee4dc2490ecbf7bff9ab5cdbac86e1/pyreadline3-3.5.4-py3-none-any.whl", hash = "sha256:eaf8e6cc3c49bcccf145fc6067ba8643d1df34d604a1ec0eccbf7a18e6d3fae6", size = 83178 },
|
| 862 |
]
|
| 863 |
|
| 864 |
-
[[package]]
|
| 865 |
-
name = "pywhispercpp"
|
| 866 |
-
version = "1.3.0"
|
| 867 |
-
source = { registry = "https://pypi.org/simple" }
|
| 868 |
-
dependencies = [
|
| 869 |
-
{ name = "numpy" },
|
| 870 |
-
{ name = "platformdirs" },
|
| 871 |
-
{ name = "requests" },
|
| 872 |
-
{ name = "tqdm" },
|
| 873 |
-
]
|
| 874 |
-
sdist = { url = "https://files.pythonhosted.org/packages/85/bf/213ab706513a2ad6f0266b44c841f5123ae3592e769488be1e62268f0451/pywhispercpp-1.3.0.tar.gz", hash = "sha256:d5d4ddfdbe7472736343413355f47a74783bc40891c5826b607eac4f62b08279", size = 1580900 }
|
| 875 |
-
wheels = [
|
| 876 |
-
{ url = "https://files.pythonhosted.org/packages/79/4d/4765b2477e028d27f0f497f9e7e27ecfd207cf1d133c12626a7901ceca8a/pywhispercpp-1.3.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:f66cc5ff624744cf0b7da1c53d67d2e3416f92a02c7ae945697d47d13eed5845", size = 1562728 },
|
| 877 |
-
{ url = "https://files.pythonhosted.org/packages/e5/0d/a17a403feeea0e0d064fb230d56119718ca813d6b382804848c387387022/pywhispercpp-1.3.0-cp311-cp311-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:b2fb92868fb7219478f6bdff50d5045583466985e3e9017af040735eb650772d", size = 1893935 },
|
| 878 |
-
{ url = "https://files.pythonhosted.org/packages/3f/09/db14ce3c4555a642ba62e4da226e578ea86d1c32ca70b93e32dae3309cf2/pywhispercpp-1.3.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:66270fb0dbb00745419001eef7c46c49e2104b80ebd21d8e65d58f0bdef7c2a7", size = 1788858 },
|
| 879 |
-
{ url = "https://files.pythonhosted.org/packages/a0/28/fd4de678cfc50ad8dedba1ab5f9a3e3563759ca3dce273eb2b09b95e4729/pywhispercpp-1.3.0-cp311-cp311-musllinux_1_2_i686.whl", hash = "sha256:f61f2e36f06bb98cd139aee073d6af5223fe551bab80ce3cbdc643eb7edb5e1b", size = 3026209 },
|
| 880 |
-
{ url = "https://files.pythonhosted.org/packages/94/a3/81c3616eb033344e4af356896aded58c1f36fdca253294dd501db7630a09/pywhispercpp-1.3.0-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:bf0478a443ea7a56f35fbeba1c5f1988b13088aafc79d533a67020ee7ce146f3", size = 2792276 },
|
| 881 |
-
{ url = "https://files.pythonhosted.org/packages/49/83/0bcb864c5dff802afd4c1887149bf029ea6715e20438feb0eb0727e0e70d/pywhispercpp-1.3.0-cp311-cp311-win32.whl", hash = "sha256:0c906e7537d9e81813d86bcc98824085058174b238900bad655c8d7bd426f9a4", size = 731243 },
|
| 882 |
-
{ url = "https://files.pythonhosted.org/packages/a7/15/5421c0814e611aae9f1541c36d4bfba157ae30580424091519aaeffe3f1d/pywhispercpp-1.3.0-cp311-cp311-win_amd64.whl", hash = "sha256:3af25987a0d3caa88a6c795b2e0051b74515a81c33bdbd49c6e8ca65b7fdc6db", size = 863874 },
|
| 883 |
-
{ url = "https://files.pythonhosted.org/packages/4b/e6/c4008fed98e0ab047bd458aaeb675226d2bd630c11939e641c3385657552/pywhispercpp-1.3.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:dd0903d9685447700ed4cad48f298cb73dd073bcd0abb8bcf974646006f4e222", size = 1563954 },
|
| 884 |
-
{ url = "https://files.pythonhosted.org/packages/d9/31/5de448da80b8e58bda47e2ca503b97484afafe93d93793f5f7b6140f9fba/pywhispercpp-1.3.0-cp312-cp312-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:e84926618d819aaeb128170351b7489dc01cabb0e58c44c6b11f8449f0850d7a", size = 1893782 },
|
| 885 |
-
{ url = "https://files.pythonhosted.org/packages/5c/82/cb38ffa05a0fcbff7547a42735b05f36d92af5352ae7273764e05ca85363/pywhispercpp-1.3.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:2ba675b98ffd1901d3696613655700d3d407bd952e110a1bfbbb618997818d8b", size = 1787927 },
|
| 886 |
-
{ url = "https://files.pythonhosted.org/packages/90/9d/3aa981b0551d44339ffc613c4466df4d8e3c59609da444a490eac032e0a2/pywhispercpp-1.3.0-cp312-cp312-musllinux_1_2_i686.whl", hash = "sha256:2b8407a9cae5555bd276fac578155de6273f3bcc0ee8960c1fd0cfb7f4be1be9", size = 3027385 },
|
| 887 |
-
{ url = "https://files.pythonhosted.org/packages/b0/3f/85924b54772e5ce5222bbf9aa98247800c7be2262daf17d07e2fae6e1ced/pywhispercpp-1.3.0-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:fd31fa0992a39e55d4a793dad1f6d2a1a97261998d52726f4568cea0af78ff93", size = 2791659 },
|
| 888 |
-
{ url = "https://files.pythonhosted.org/packages/71/63/0ed9a4a776d81018536f2e5556fe364599a661aeded42627f93e1d4282aa/pywhispercpp-1.3.0-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:e8d1b339409668382f68b810c2ccac010e71d580c6afe6d67e86336daeb939ed", size = 1563943 },
|
| 889 |
-
{ url = "https://files.pythonhosted.org/packages/e4/3b/f9fda6bd691900e76702945405919174838497096961f56aa8583b6373ed/pywhispercpp-1.3.0-cp313-cp313-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:0ac9fea9e3aeb5219ce614f644c4f1b38b9561eede1e4380ab39de96afba8864", size = 1893777 },
|
| 890 |
-
{ url = "https://files.pythonhosted.org/packages/42/fc/26b0811b3964f4b14691ff28d84ccfd5fb7b800eab7ca898f538271c9c61/pywhispercpp-1.3.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:fc6801332deb2d6efc67e5dd7c9c9b1ce06f8235270b3ebd5546a79040a67314", size = 1787957 },
|
| 891 |
-
{ url = "https://files.pythonhosted.org/packages/3a/f2/1673b43721246a9da0a9820abb6aa442c4de0129d2039fd107f0657878f4/pywhispercpp-1.3.0-cp313-cp313-musllinux_1_2_i686.whl", hash = "sha256:5bc5742787037f421f748ad463d85bce565287e77dfddaa5536d37d59ac44267", size = 3027419 },
|
| 892 |
-
{ url = "https://files.pythonhosted.org/packages/d2/33/292a727bd3aa826c5981df32ce228f3e89edf4116ae4cc9d76ddedb9fb07/pywhispercpp-1.3.0-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:a6f7578fb9a8de4c8663323060c0715713168ae174ab022dfe9ad13b21223c3c", size = 2791670 },
|
| 893 |
-
]
|
| 894 |
-
|
| 895 |
[[package]]
|
| 896 |
name = "requests"
|
| 897 |
version = "2.32.3"
|
|
@@ -1152,12 +1100,10 @@ source = { virtual = "." }
|
|
| 1152 |
dependencies = [
|
| 1153 |
{ name = "av" },
|
| 1154 |
{ name = "librosa" },
|
| 1155 |
-
{ name = "llama-cpp-python" },
|
| 1156 |
{ name = "numpy" },
|
| 1157 |
{ name = "onnxruntime" },
|
| 1158 |
{ name = "pyaudio" },
|
| 1159 |
{ name = "pydantic" },
|
| 1160 |
-
{ name = "pywhispercpp" },
|
| 1161 |
{ name = "setuptools" },
|
| 1162 |
{ name = "soundfile" },
|
| 1163 |
{ name = "torch" },
|
|
@@ -1170,12 +1116,10 @@ dependencies = [
|
|
| 1170 |
requires-dist = [
|
| 1171 |
{ name = "av", specifier = ">=14.2.0" },
|
| 1172 |
{ name = "librosa", specifier = ">=0.11.0" },
|
| 1173 |
-
{ name = "llama-cpp-python", specifier = ">=0.3.8" },
|
| 1174 |
{ name = "numpy", specifier = ">=2.1.3" },
|
| 1175 |
{ name = "onnxruntime", specifier = ">=1.21.0" },
|
| 1176 |
{ name = "pyaudio", specifier = ">=0.2.14" },
|
| 1177 |
{ name = "pydantic", specifier = ">=2.11.2" },
|
| 1178 |
-
{ name = "pywhispercpp", specifier = ">=1.3.0" },
|
| 1179 |
{ name = "setuptools", specifier = ">=78.1.0" },
|
| 1180 |
{ name = "soundfile", specifier = ">=0.13.1" },
|
| 1181 |
{ name = "torch", specifier = ">=2.6.0" },
|
|
|
|
| 223 |
{ url = "https://files.pythonhosted.org/packages/4e/8c/f3147f5c4b73e7550fe5f9352eaa956ae838d5c51eb58e7a25b9f3e2643b/decorator-5.2.1-py3-none-any.whl", hash = "sha256:d316bb415a2d9e2d2b3abcc4084c6502fc09240e292cd76a76afc106a1c8e04a", size = 9190 },
|
| 224 |
]
|
| 225 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 226 |
[[package]]
|
| 227 |
name = "filelock"
|
| 228 |
version = "3.18.0"
|
|
|
|
| 330 |
{ url = "https://files.pythonhosted.org/packages/b5/ba/c63c5786dfee4c3417094c4b00966e61e4a63efecee22cb7b4c0387dda83/librosa-0.11.0-py3-none-any.whl", hash = "sha256:0b6415c4fd68bff4c29288abe67c6d80b587e0e1e2cfb0aad23e4559504a7fa1", size = 260749 },
|
| 331 |
]
|
| 332 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 333 |
[[package]]
|
| 334 |
name = "llvmlite"
|
| 335 |
version = "0.44.0"
|
|
|
|
| 840 |
{ url = "https://files.pythonhosted.org/packages/5a/dc/491b7661614ab97483abf2056be1deee4dc2490ecbf7bff9ab5cdbac86e1/pyreadline3-3.5.4-py3-none-any.whl", hash = "sha256:eaf8e6cc3c49bcccf145fc6067ba8643d1df34d604a1ec0eccbf7a18e6d3fae6", size = 83178 },
|
| 841 |
]
|
| 842 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 843 |
[[package]]
|
| 844 |
name = "requests"
|
| 845 |
version = "2.32.3"
|
|
|
|
| 1100 |
dependencies = [
|
| 1101 |
{ name = "av" },
|
| 1102 |
{ name = "librosa" },
|
|
|
|
| 1103 |
{ name = "numpy" },
|
| 1104 |
{ name = "onnxruntime" },
|
| 1105 |
{ name = "pyaudio" },
|
| 1106 |
{ name = "pydantic" },
|
|
|
|
| 1107 |
{ name = "setuptools" },
|
| 1108 |
{ name = "soundfile" },
|
| 1109 |
{ name = "torch" },
|
|
|
|
| 1116 |
requires-dist = [
|
| 1117 |
{ name = "av", specifier = ">=14.2.0" },
|
| 1118 |
{ name = "librosa", specifier = ">=0.11.0" },
|
|
|
|
| 1119 |
{ name = "numpy", specifier = ">=2.1.3" },
|
| 1120 |
{ name = "onnxruntime", specifier = ">=1.21.0" },
|
| 1121 |
{ name = "pyaudio", specifier = ">=0.2.14" },
|
| 1122 |
{ name = "pydantic", specifier = ">=2.11.2" },
|
|
|
|
| 1123 |
{ name = "setuptools", specifier = ">=78.1.0" },
|
| 1124 |
{ name = "soundfile", specifier = ">=0.13.1" },
|
| 1125 |
{ name = "torch", specifier = ">=2.6.0" },
|