[bash] update

This commit is contained in:
IrvingGao 2024-05-27 05:57:45 +08:00
parent 09a0865c5c
commit 423269f538
4 changed files with 58 additions and 22 deletions

View File

@ -12,13 +12,10 @@
#### (1) 安装依赖项:
```
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install cmake g++ gcc
sudo apt-get install python3-pip python3-dev portaudio19-dev libsndfile1
# wifi hotspot
sudo pip install flask
sudo apt-get update -y
sudo apt-get upgrade -y
sudo apt-get install -y cmake g++ gcc
sudo apt-get install -y git swig python3-pip python3-dev portaudio19-dev libsndfile1 python3-setuptools
```
#### (2) 克隆项目到本地并安装依赖:
@ -36,6 +33,15 @@ sudo pip install -v -e .
pip install -r requirements/board_requirements.txt
```
- WiringPi用于控制GPIO
```
cp -r /usr/src/wiringOP-Python/ ./
cd wiringOP-Python
python3 generate-bindings.py > bindings.i
sudo python3 setup.py install
```
#### (4) 下载相关模型文件:
- [Picovoice](https://picovoice.ai/docs/quick-start/porcupine-python/)边缘端关键词唤醒模型
@ -47,5 +53,5 @@ pip install -r requirements/board_requirements.txt
#### (5) 启动服务:
```
python ws_client.py
sudo python3 ws_client.py
```

View File

@ -1,24 +1,37 @@
#!/bin/bash
# 给bashrc添加自启动python脚本
# echo "nohup python3 /home/orangepi/takway_base/ws_client.py& " >> ~/.bashrc
# update system
sudo -S apt-get update -y << EOF
orangepi
EOF
# install dependencies
sudo apt-get install -y cmake g++ gcc
sudo apt-get install -y python3-pip python3-dev portaudio19-dev libsndfile1
sudo apt-get upgrade -y
sudo apt-get install -y cmake g++ gcc git
sudo apt-get install -y swig python3-pip python3-dev portaudio19-dev libsndfile1 python3-setuptools
# install python dependencies
# git clone https://Irvingao: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@github.com/Irvingao/takway_base.git
# install wiringOP-Python
cp -r /usr/src/wiringOP-Python/ ./
cd wiringOP-Python
python3 generate-bindings.py > bindings.i
sudo python3 setup.py install
cd ..
# install TakwayBoard
git clone http://43.132.157.186:3000/gaohz/TakwayBoard.git
cd TakwayBoard
# git remote set-url origin https://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@github.com/Irvingao/takway_base.git
pip install -v -e .
pip install -r requirements.txt
sudo pip install -v -e .
reboot
cd ..
# install wifi hotspot
sudo apt-get install -y hostapd dnsmasq
git clone http://43.132.157.186:3000/gaohz/wifi_hotpot.git
cd wifi_hotpot
sudo pip install flask psutil
# reboot
reboot

View File

@ -1,10 +1,14 @@
import wave
# 读取wave文件并打印采样率、量化位数、声道数
# 读取wave文件并打印data长度
with wave.open('output_1708083097.9604511.wav', 'rb') as f:
with wave.open('output.wav', 'rb') as f:
data = f.readframes(f.getnframes())
print(len(data))
print(type(data))
nchannels, sampwidth, framerate, nframes, comptype, compname = f.getparams()
print(framerate, sampwidth, nchannels)
print("采样率:", framerate)
print("量化位数:", sampwidth)
print("声道数:", nchannels)
print("data长度:", nframes)
print("压缩类型:", comptype)
print("压缩名称:", compname)

13
tools/orangepi_player.py Normal file
View File

@ -0,0 +1,13 @@
from takway.audio_utils import AudioPlayer
# RATE = 22050
RATE = 16000
# device_idx = 3 # 声卡编号,根据实际情况修改
device_idx = None # 使用默认声卡
if __name__ == '__main__':
audio_player = AudioPlayer(RATE=RATE, output_device_index=device_idx)
# frames = audio_player.load_audio_file("my_recording.wav") # wav或pcm格式音频都支持
frames = audio_player.load_audio_file("output.wav") # wav或pcm格式音频都支持
audio_player.play(frames)