树莓派蓝牙连接天猫精灵实现语音播报

树莓派安装bluealsa

sudo apt install bluealsa -y

添加pi用户到蓝牙组(需重启才能生效)
sudo usermod -aG bluetooth pi

sudo reboot

连接天猫精灵

# 树莓派打开蓝牙

sudo bluetoothctl
scan on

# 天猫精灵开启蓝牙配对

语音唤醒: 天猫精灵,开启蓝牙配对

# 语音唤醒后,树莓派将搜索到天猫精灵

方糖(xx)

# 树莓派执行连接

connect 38:D2:CA:9B:98:52  # 天猫精灵蓝牙地址
trust 38:D2:CA:9B:98:52

exit

将树莓派蓝牙音箱作为树莓派默认语音输出

# sudo vi /etc/asound.conf

pcm.!default {
      type plug
      slave.pcm {
              type bluealsa
              device "38:D2:CA:9B:98:52"
              profile "a2dp"
      }
      hint {
              show on
              description "BT Speaker"
      }
}

配置开机启动后自动连接蓝牙音箱

@reboot sleep 20 && echo "connect 38:D2:CA:9B:98:52" | sudo bluetoothctl

语音测试

aplay /usr/share/sounds/alsa/Front_Center.wav

最后修改于: 2023年8月9日 17:05