『瀚思彼岸』» 智能家居技术论坛

 找回密码
 立即注册
查看: 2093|回复: 1

[流程系列] MrDiy Audio Notifier, tts 播报 不支持 https 解决

[复制链接]

80

主题

388

帖子

1680

积分

金牌会员

Rank: 6Rank: 6

积分
1680
金钱
1292
HASS币
0
发表于 2022-4-18 16:23:09 | 显示全部楼层 |阅读模式
本帖最后由 ciasdmxhxjjpd@c 于 2022-4-18 16:38 编辑

===================================================================================
硬件实现,见之前发帖, https://bbs.hassbian.com/thread-16077-1-1.html
固件,https://github.com/schmurtzm/MrDiy-Audio-Notifier, 支持 esp32/8266。
===================================================================================

本贴主要是解决 tts 播报时, 不支持 https 问题。


原因: MrDiy Audio Notifier 在播放时,esp32/8266 不支持 https(内存太小),而我们的homeassisstant 基本都配置成了 https,导致有冲突。

google tts ( 路由器需要全局fq,不是此贴讨论范围), 代替物 baidu tts
# Text to speech
tts:
  - platform: google_translate
    language: "zh-CN"
    cache: true
    cache_dir: /config/tts
    time_memory: 300
    base_url: https://yourdomain:8123
    service_name: google_say


开启 cache,每次tts ,会保存到 /config/tts

docker 版,创建 /config/init.sh , 加上执行权限
python -m http.server 8124 -d /config/tts &
/init
docker 启动时,添加 命令  /config/init.sh, 会启动一个 http 的 server,监听8124

解释下流程中重要的部分,nodered 通过
/api/tts_get_url ,获取 tts path 和 url,后,简单处理下,替换 host = yourdomain:8124
log:
==================================================================
  MrDIY Notifier - Modified By Schmurtz 
==================================================================

Connected to Wifi       [192.168.1.225]
Connected to MQTT
[MQTT] media/LWT        online
[MQTT] media/SSID       NodeMCU-32S-AP
[MQTT] media/IPAddress  192.168.1.225
[MQTT] media/status     idle
State changed from: 3 to 4

Requested [media/play] http://192.168.1.2:8124/367f479200d9e0f1f1be0301d3422d84bf147d9b_zh-cn_-_google_translate.mp3
[V][HTTPClient.cpp:245] beginInternal(): url: http://192.168.1.2:8124/367f479200d9e0f1f1be0301d3422d84bf147d9b_zh-cn_-_google_translate.mp3
[D][HTTPClient.cpp:293] beginInternal(): protocol: http, host: 192.168.1.2 port: 8124 url: /367f479200d9e0f1f1be0301d3422d84bf147d9b_zh-cn_-_google_translate.mp3
[D][HTTPClient.cpp:579] sendRequest(): request type: 'GET' redirCount: 0

[D][HTTPClient.cpp:1125] connect():  connected to 192.168.1.2:8124
[V][HTTPClient.cpp:1216] handleHeaderResponse(): RX: 'HTTP/1.0 200 OK'
[V][HTTPClient.cpp:1216] handleHeaderResponse(): RX: 'Server: SimpleHTTP/0.6 Python/3.9.7'
[V][HTTPClient.cpp:1216] handleHeaderResponse(): RX: 'Date: Mon, 18 Apr 2022 06:15:58 GMT'
[V][HTTPClient.cpp:1216] handleHeaderResponse(): RX: 'Content-type: audio/mpeg'
[V][HTTPClient.cpp:1216] handleHeaderResponse(): RX: 'Content-Length: 40237'
[V][HTTPClient.cpp:1216] handleHeaderResponse(): RX: 'Last-Modified: Mon, 18 Apr 2022 06:15:57 GMT'
[V][HTTPClient.cpp:1216] handleHeaderResponse(): RX: ''
[D][HTTPClient.cpp:1257] handleHeaderResponse(): code: 200
[D][HTTPClient.cpp:1260] handleHeaderResponse(): size: 40237
[D][HTTPClient.cpp:603] sendRequest(): sendRequest code=200

[MQTT] media/status     playing
Free: 139972  (46980 lost)  -----------
Free: 140828  (47836 lost)  -----------
Free: 141032  (48040 lost)  -----------
Free: 141032  (48040 lost)  -----------
Free: 141032  (48040 lost)  -----------
Free: 142548  (49556 lost)  -----------
Free: 141004  (48036 lost)  -----------
Free: 141028  (48036 lost)  -----------
Free: 142544  (49552 lost)  ----------- 
Free: 146412  (53420 lost)  ----------- 
[D][WiFiClient.cpp:514] connected(): Disconnected: RES: 0, ERR: 128
[D][HTTPClient.cpp:400] disconnect(): tcp is closed

[D][HTTPClient.cpp:400] disconnect(): tcp is closed

...#Interrupted!

[MQTT] media/status     idle







捕获.JPG

mrdiyaudio-g-tts.json

5.97 KB, 下载次数: 3

回复

使用道具 举报

14

主题

430

帖子

2713

积分

金牌会员

Rank: 6Rank: 6

积分
2713
金钱
2283
HASS币
0
发表于 2022-4-23 07:15:05 来自手机 | 显示全部楼层
谢谢分享!这么好的帖竟然没人顶!
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|Hassbian

GMT+8, 2024-12-22 22:10 , Processed in 0.105800 second(s), 26 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表