标签 - swith

vlc swith command line swith command    2021-04-10 10:11:07    12    0    0

google和百度的TTS我都不太好用,因为我的homeassistant是docker版的,无法调用宿主声卡,所以我曲线救国

一、设置一个swith command_line来修改一个文本标志

  • 修改configuration.yaml
  • /config 是docker的加载目录
  1. switch:
  2. - platform: command_line
  3. switches:
  4. egg:
  5. command_on: sed -i 's/stop/on/' /config/egg.txt
  6. command_off: sed -i 's/stop/off/' /config/egg.txt

二、一个循环脚本

  1. while [ i==0 ]
  2. do
  3. msg=$(sed -n '1,1p' /data/docker/hass_config/egg.txt)
  4. echo "查看egg.txt: ... ... ... " $msg
  5. if [ $msg = "on" ];then
  6. echo "on"
  7. cvlc --no-interact --play-and-exit file:///opt/say/egg_on.mp3
  8. sleep 7;
  9. sudo sed -i 's/on/stop/' /data/docker/hass_config/egg.txt
  10. elif [ $msg = "off" ];then
  11. echo "off"
  12. cvlc --no-interact --play-and-exit file:///opt/say/egg_off.mp3
  13. sleep 7;
  14. sudo sed -i 's/off/stop/' /data/docker/hass_config/egg.txt
  15. else
  16. echo "stop"
  17. fi
  18. sleep 2;
  19. done

三、利用文本转语音工具制做.mp3

title

四、在启动raspberrypi时