创建实时音频翻译服务 -- Google live 和 Whisper

默认分类,教程文档 · · · 💬 暂无评论

创建实时音频翻译服务 -- Google live 和 Whisper

前言

用过 Ollama 都知道,本地 AI 模型可以翻译文字、识别图片。但是要识别音频并翻译文字,也需要动些手脚。虽然现在已经开始有综合型 AI 了,但是在速度和质量上无法跟专用模型相比较。

方案一:使用 Google API

  1. 获取 Google API KEY:访问 https://aistudio.google.com/api-keys 创建
  2. 将 API KEY 填入「谈起哥爱翻译」工具即可使用

方案二:自建 Whisper 本地服务

以下教程基于 Ubuntu,用 cmake 编译以提高性能。

1. 下载并编译项目

sudo apt update
sudo apt install -y build-essential cmake git ffmpeg
git clone https://github.com/ggml-org/whisper.cpp.git

cd whisper.cpp
bash ./models/download-ggml-model.sh large-v3-turbo

cmake -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build -j --config Release

2. 测试

./build/bin/whisper-cli -m models/ggml-base.bin -f samples/jfk.wav

3. 创建 systemd 服务

[Unit]
Description=whisper.cpp server (ggml-base)
After=network.target

[Service]
Type=simple
User=glpi
WorkingDirectory=/data/whisper.cpp
ExecStart=/data/whisper.cpp/build/bin/whisper-server -m /data/whisper.cpp/models/ggml-large-v3-turbo.bin --host 0.0.0.0 --port 8080 -t 24 --public /data/whisper.cpp/examples/server/public --inference-path /v1/audio/transcriptions
Restart=always
RestartSec=5

[Install]
WantedBy=multi-user.target

总结

创建完成后,即可配置到翻译工具上使用。Whisper 识别会慢一点,毕竟云端算力比本地强,但用来看电影还能接受。

标签:无

添加新评论