Skip to content

Commit f2d9538

Browse files
committed
update: whisper
1 parent 145e6e6 commit f2d9538

File tree

6 files changed

+105
-3
lines changed

6 files changed

+105
-3
lines changed

.vitepress/config.mjs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,10 @@ export default defineConfig({
100100
{
101101
text: '沙箱化代码执行器(beta)',
102102
link: '/code-interpreter'
103+
},
104+
{
105+
text: '接入 Whisper 语音转文字',
106+
link: '/whisper'
103107
}
104108
]
105109
},

config/provider.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,4 +137,13 @@ AstrBot 支持加载使用 `LlamaFactory` 微调的模型。
137137

138138
AstrBot 支持接入 Dify。
139139

140-
请参考 [接入 Dify](/others/dify)
140+
请参考 [接入 Dify](/others/dify)
141+
142+
143+
## Whisper 语音转文字
144+
145+
AstrBot 支持接入 OpenAI 开源的 Whisper 模型,实现语音转文字。
146+
147+
可以接入 API 版本的,也可以在本地部署 Whisper。
148+
149+
详见 [Whisper 语音转文字](/use/whisper)

deploy/platform/aiocqhttp/napcat.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,25 @@ NapCatQQ 的文档:[NapCatQQ 文档](https://napcat.napneko.icu/)
1010
> - 一个 QQ 号(最好不是新创建的 QQ 号)。
1111
> - 一台具有摄像功能的手机以扫码登录 QQ。
1212
13-
NapCat 提供了大量的部署方式,包括 Docker、Windows 一键安装包等等。在本篇文章里将以 Docker 部署为例。
13+
NapCat 提供了大量的部署方式,包括 Docker、Windows 一键安装包等等。
14+
15+
## 通过一键脚本部署
16+
17+
推荐这种方式。
18+
19+
### Windows
20+
21+
看这篇文章:[NapCat.Shell - Win手动启动教程](https://napneko.github.io/guide/boot/Shell#napcat-shell-win%E6%89%8B%E5%8A%A8%E5%90%AF%E5%8A%A8%E6%95%99%E7%A8%8B)
22+
23+
### Linux
24+
25+
看这篇文章:[NapCat.Installer - Linux一键使用脚本(支持Ubuntu 20+/Debian 10+/Centos9)](https://napneko.github.io/guide/boot/Shell#napcat-installer-linux%E4%B8%80%E9%94%AE%E4%BD%BF%E7%94%A8%E8%84%9A%E6%9C%AC-%E6%94%AF%E6%8C%81ubuntu-20-debian-10-centos9)
1426

1527
## 通过 Docker 部署
1628

29+
> [!TIP]
30+
> 如果用 Docker 部署,将无法正常接收到`语音数据``文件数据`。这意味着语音转文字、沙箱的文件输入功能将无法使用。可以接收到文字消息、图片消息等其他类型的消息。
31+
1732
默认您安装了 Docker。
1833

1934
在终端执行以下命令即可一键部署。

source/images/whisper/image.png

86.6 KB
Loading

use/code-interpreter.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
`v3.4.2` 版本及之后,AstrBot 支持代码执行器以强化 LLM 的能力,并实现一些自动化的操作。
44

5+
> [!TIP]
6+
> 如果您使用 Docker 部署 AstrBot,将无法使用文件输入/输出功能,因为 Docker 无法直接访问宿主机的文件系统。
7+
58
## Demo
69

710
![](../source/images/code-interpreter/a3cd3a0e-aca5-41b2-aa52-66b568bd955b.png)
@@ -61,4 +64,4 @@
6164

6265
代码执行器除了能够识别和处理图片、文字任务,还能够识别您发送的文件,并且能够发送文件。但是,目前来说有一些环境上的限制。
6366

64-
文件输入/输出只支持 `QQ` 平台,并且使用 `napcat`
67+
文件输入/输出只支持 `QQ` 平台,并且使用 `napcat`,并且非 Docker 部署 napcat

use/whisper.md

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
## 接入 Whisper 语音转文字
2+
3+
> [!TIP]
4+
> 如果您使用 Docker 部署 AstrBot,`目前`将无法接收到 QQ 的语音消息,因为无法访问宿主机文件系统。
5+
6+
AstrBot 支持接入 Whisper 语音转文字。
7+
8+
有两种接入方式,一种是使用 OpenAI API 的 Whisper API 接口,另一种是在本地部署 Whisper。
9+
10+
### API 接入
11+
12+
和接入支持 OpenAI API 的大语言模型提供商一样,OpenAI API 也提供了调用 Whisper 模型的 API 接口。
13+
14+
配置文件类似:
15+
16+
```json
17+
{
18+
"id": "new_whisper(api)",
19+
"type": "openai_whisper_api",
20+
"enable": false,
21+
"api_key": "your_openai_api_key",
22+
"api_base": "your openai api base",
23+
"model": "whisper-1"
24+
},
25+
```
26+
27+
在管理面板上配置,只需要点击此项即可可视化配置:
28+
29+
![](../source/images/whisper/image.png)
30+
31+
如果你使用 OpenAI 中转服务,请确保你的 OpenAI 的中转服务商支持 Whisper 调用。
32+
33+
### 本地部署
34+
35+
本地运行 Whisper 模型需要 `openai-whisper` 的 Python 库,请先 Pip 安装。
36+
37+
> [!TIP]
38+
> 可以在管理面板 `控制台` 页快捷 pip 安装。
39+
> 安装此库会自动安装 Pytorch(一个深度学习库)。N 卡用户大约下载 2GB,主要是 torch 和 cuda,CPU 用户大约下载 1 GB。
40+
41+
除了安装 `openai-whisper` 库,还需要你的设备上安装有 `ffmpeg`
42+
43+
对于 Linux,大多数包管理器都有 ffmpeg,可以直接安装。
44+
45+
对于 Windows,可以从 [ffmpeg 官网](https://ffmpeg.org/download.html) 下载。下载完成后建议重启电脑以使环境变量生效。
46+
47+
```
48+
{
49+
"id": "new_whisper(本地加载)",
50+
"type": "openai_whisper_selfhost",
51+
"enable": true,
52+
"model": "tiny"
53+
},
54+
```
55+
56+
在管理面板上配置,只需要点击此项的后面那项即可可视化配置:
57+
58+
![](../source/images/whisper/image.png)
59+
60+
Whisper 有多种模型,默认启用最小的 `tiny` 模型,如果你的设备性能较好,可以尝试使用其他模型。
61+
62+
模型列表:
63+
64+
| 模型名 | 参数量 | English-only model | Multilingual model | 需要的显存 | Relative speed |
65+
|:------:|:----------:|:------------------:|:------------------:|:-------------:|:--------------:|
66+
| tiny | 39 M | `tiny.en` | `tiny` | ~1 GB | ~10x |
67+
| base | 74 M | `base.en` | `base` | ~1 GB | ~7x |
68+
| small | 244 M | `small.en` | `small` | ~2 GB | ~4x |
69+
| medium | 769 M | `medium.en` | `medium` | ~5 GB | ~2x |
70+
| large | 1550 M | N/A | `large` | ~10 GB | 1x |
71+
| turbo | 809 M | N/A | `turbo` | ~6 GB | ~8x |

0 commit comments

Comments
 (0)