在树莓派 AI 盒子上部署 Whisper
简介
Whisper 是由 OpenAI 开发的多功能、最先进的自动语音识别(ASR)和语音处理模型。与传统的语音转文本系统不同,Whisper 在从网络收集的 680,000 小时多语言和多任务监督数据上进行训练。这个庞大而多样化的数据集使模型对口音、背景噪音和技术术语具有极强的鲁棒性。
本指南提供了在树莓派 AI 盒子上部署和使用 Whisper 的全面演练。

准备硬件
AI 盒子
| reComputer AI R2130 | reComputer AI Industrial R2145 | reComputer Industrial R20xx | reComputer Industrial R21xx |
|---|---|---|---|
![]() | ![]() | ![]() | ![]() |
麦克风阵列

准备软件
更新系统
sudo apt update
sudo apt full-upgrade
note
有时您在更新过程中可能会遇到以下问题。
Get:1 http://deb.debian.org/debian bookworm InRelease [151 kB]
Get:2 http://deb.debian.org/debian-security bookworm-security InRelease [48.0 kB]
Get:3 http://deb.debian.org/debian bookworm-updates InRelease [55.4 kB]
Get:4 http://archive.raspberrypi.com/debian bookworm InRelease [39.0 kB]
Reading package lists... Done
E: Release file for http://deb.debian.org/debian/dists/bookworm/InRelease is not valid yet (invalid for another 58d 8h 26min 35s). Updates for this repository will not be applied.
E: Release file for http://deb.debian.org/debian-security/dists/bookworm-security/InRelease is not valid yet (invalid for another 84d 18h 23min 59s). Updates for this repository will not be applied.
E: Release file for http://archive.raspberrypi.com/debian/dists/bookworm/InRelease is not valid yet (invalid for another 84d 13h 13min 5s). Updates for this repository will not be applied.
E: Release file for http://deb.debian.org/debian/dists/bookworm-updates/InRelease is not valid yet (invalid for another 85d 0h 52min 29s). Updates for this repository will not be applied.
这是因为树莓派上的时间设置不正确,您需要使用以下命令手动设置树莓派的时间:
# This command only you can connect google.com
sudo date -s "$(wget -qSO- --max-redirect=0 google.com 2>&1 | grep Date: | cut -d' ' -f5-8)Z"
设置树莓派时间后,您可以更新您的树莓派。
设置 pcie 为 gen2/gen3(gen3 比 gen2 更快)
将以下文本添加到 /boot/firmware/config.txt
#Enable the PCIe external connector
dtparam=pciex1
#Force Gen 3.0 speeds
dtparam=pciex1_gen=3
note
如果您想使用 gen2,请注释掉 dtparam=pciex1_gen=3
安装 hailo-all 并重启
在树莓派 5 上打开终端,输入以下命令安装 Hailo 软件。
sudo apt install hailo-all
sudo apt-get -y install libblas-dev nlohmann-json3-dev
sudo reboot
检查软件和硬件
在树莓派 5 上打开终端,输入以下命令检查 hailo-all 是否已安装。
hailortcli fw-control identify
正确的结果如下所示:

在树莓派 5 上打开终端,输入以下命令检查 hailo-8L 是否已连接。
lspci | grep Hailo
正确的结果如下所示:

安装项目
下载项目
cd ~ && git clone https://github.com/Seeed-Projects/STT_hailo_whisper.git
cd STT_hailo_whisper
安装必要的包
sudo apt update
sudo apt install ffmpeg
sudo apt install libportaudio2
sudo apt install portaudio19-dev python3-pyaudio
sudo apt install hailo-all
创建 Python 环境
python -m venv .env --system-site-packages && source .env/bin/activate
cd app && python download_resources.py
cd .. && pip install -r requirements.txt
运行项目
启动后端。
python hailo_whisper.py --hw-arch hailo8 --variant base --udp-host 0.0.0.0 --udp-port 12345

结果
启动前端,然后您可以看到实时 STT 结果。
cd test && python recive_message.py --host 0.0.0.0 --port 12345 --stats-interval 5

技术支持与产品讨论
感谢您选择我们的产品!我们在这里为您提供不同的支持,以确保您使用我们产品的体验尽可能顺畅。我们提供多种沟通渠道,以满足不同的偏好和需求。



