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

 找回密码
 立即注册
楼主: involute

[插件集成] 让你的HomePod可以TTS?没有那么多麻烦

  [复制链接]

5

主题

357

帖子

2046

积分

金牌会员

Rank: 6Rank: 6

积分
2046
金钱
1674
HASS币
60
发表于 2021-9-27 14:33:52 | 显示全部楼层
involute 发表于 2021-9-27 05:04
解决了米有?

你应该去正确的地方执行命令。

感谢i大指点,现在集成里面已经成功添加了家里的homepod了,但是发送播放文字的时候,提示报错:
File "/usr/local/lib/python3.9/site-packages/urllib3/util/retry.py", line 574, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='translate.google.com', port=443): Max retries exceeded with url: /_/TranslateWebserverUi/data/batchexecute (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0xa4455fd0>: Failed to establish a new connection: [Errno 110] Operation timed out'))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/gtts/tts.py", line 264, in write_to_fp
r = s.send(request=pr,
File "/usr/local/lib/python3.9/site-packages/requests/sessions.py", line 655, in send
r = adapter.send(request, **kwargs)
File "/usr/local/lib/python3.9/site-packages/requests/adapters.py", line 516, in send
raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='translate.google.com', port=443): Max retries exceeded with url: /_/TranslateWebserverUi/data/batchexecute (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0xa4455fd0>: Failed to establish a new connection: [Errno 110] Operation timed out'))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/google_translate/tts.py", line 133, in get_tts_audio
tts.write_to_fp(mp3_data)
File "/usr/local/lib/python3.9/site-packages/gtts/tts.py", line 280, in write_to_fp
raise gTTSError(tts=self)
gtts.tts.gTTSError: Failed to connect. Probable cause: Unknown
2021-09-27 14:13:54 ERROR (MainThread) [homeassistant.components.tts] Error on init TTS: No TTS from google_translate for '打开客厅灯'


是不是还要装微软的TTS服务?怎么安装呢?另外,我看服务里面,没有可被调用的airplay TTS项目,是无法通过调用服务运行吗?
回复

使用道具 举报

20

主题

550

帖子

3600

积分

元老级技术达人

积分
3600
金钱
3010
HASS币
210

教程狂人突出贡献

 楼主| 发表于 2021-9-27 15:11:20 | 显示全部楼层
muxiachuixue 发表于 2021-9-27 14:33
感谢i大指点,现在集成里面已经成功添加了家里的homepod了,但是发送播放文字的时候,提示报错:

你随意用什么TTS,但是你看你目前用的“google_translate”的TTS服务肯定是不能用的。

论坛里有不少TTS的方案,你找一个用吧。
回复

使用道具 举报

5

主题

357

帖子

2046

积分

金牌会员

Rank: 6Rank: 6

积分
2046
金钱
1674
HASS币
60
发表于 2021-9-27 20:06:07 | 显示全部楼层
involute 发表于 2021-9-27 15:11
你随意用什么TTS,但是你看你目前用的“google_translate”的TTS服务肯定是不能用的。

论坛里有不少TTS ...

明白了大佬,准备搞微软的了
回复

使用道具 举报

5

主题

357

帖子

2046

积分

金牌会员

Rank: 6Rank: 6

积分
2046
金钱
1674
HASS币
60
发表于 2021-9-28 08:29:19 | 显示全部楼层
本帖最后由 muxiachuixue 于 2021-9-28 08:32 编辑

i大,还是有问题,用您的插件把homepod mini 添加到HA里面了,添加了微软edge的TTS,运行的时候提示这个错误
Logger: homeassistant
Source: custom_components/apple_airplayer/media_player.py:110
Integration: Apple AirPlayer (documentation, issues)
First occurred: 2021年9月27日 22:36:22 (3 occurrences)
Last logged: 08:25:47

Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/aiohttp/connector.py", line 969, in _wrap_create_connection
    return await self._loop.create_connection(*args, **kwargs)  # type: ignore  # noqa
  File "/usr/local/lib/python3.9/asyncio/base_events.py", line 1056, in create_connection
    raise exceptions[0]
  File "/usr/local/lib/python3.9/asyncio/base_events.py", line 1041, in create_connection
    sock = await self._connect_sock(
  File "/usr/local/lib/python3.9/asyncio/base_events.py", line 955, in _connect_sock
    await self.sock_connect(sock, address)
  File "/usr/local/lib/python3.9/asyncio/selector_events.py", line 502, in sock_connect
    return await fut
  File "/usr/local/lib/python3.9/asyncio/selector_events.py", line 537, in _sock_connect_cb
    raise OSError(err, f'Connect call failed {address}')
ConnectionRefusedError: [Errno 111] Connect call failed ('192.168.0.18', 80)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/config/custom_components/apple_airplayer/media_player.py", line 110, in async_play_stream
    r = await session.get(url)
  File "/usr/local/lib/python3.9/site-packages/aiohttp/client.py", line 520, in _request
    conn = await self._connector.connect(
  File "/usr/local/lib/python3.9/site-packages/aiohttp/connector.py", line 535, in connect
    proto = await self._create_connection(req, traces, timeout)
  File "/usr/local/lib/python3.9/site-packages/aiohttp/connector.py", line 892, in _create_connection
    _, proto = await self._create_direct_connection(req, traces, timeout)
  File "/usr/local/lib/python3.9/site-packages/aiohttp/connector.py", line 1051, in _create_direct_connection
    raise last_exc
  File "/usr/local/lib/python3.9/site-packages/aiohttp/connector.py", line 1020, in _create_direct_connection
    transp, proto = await self._wrap_create_connection(
  File "/usr/local/lib/python3.9/site-packages/aiohttp/connector.py", line 975, in _wrap_create_connection
    raise client_error(req.connection_key, exc) from exc
aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host 192.168.0.18:80 ssl:default [Connect call failed ('192.168.0.18', 80)]


回复

使用道具 举报

5

主题

357

帖子

2046

积分

金牌会员

Rank: 6Rank: 6

积分
2046
金钱
1674
HASS币
60
发表于 2021-9-28 09:05:41 | 显示全部楼层
您说要在宿主机中安装gcc,宿主机是树莓派再带的系统么?我在树莓派自带的系统中执行 apk,系统不认这个命令,进入docker中执行以下命令,可以成功,但是就算执行了以下命令,还是无法成功TTS:
docker exec -it homeassistant /bin/bash
apk update
apk add build-base
pip3 uninstall --yes miniaudio
pip3 install miniaudio
 
回复

使用道具 举报

20

主题

550

帖子

3600

积分

元老级技术达人

积分
3600
金钱
3010
HASS币
210

教程狂人突出贡献

 楼主| 发表于 2021-9-28 19:05:16 | 显示全部楼层
muxiachuixue 发表于 2021-9-28 08:29
i大,还是有问题,用您的插件把homepod mini 添加到HA里面了,添加了微软edge的TTS,运行的时候提示这个错 ...

我看你这个是ssl访问语音资源的问题,你确认你使用了ssl?而且ssl地址不可能是IP地址啊。
回复

使用道具 举报

5

主题

357

帖子

2046

积分

金牌会员

Rank: 6Rank: 6

积分
2046
金钱
1674
HASS币
60
发表于 2021-9-28 19:07:37 | 显示全部楼层
involute 发表于 2021-9-28 19:05
我看你这个是ssl访问语音资源的问题,你确认你使用了ssl?而且ssl地址不可能是IP地址啊。 ...

我没使用ssl啊,我看这个连接的是80端口?为什么会连接80端口呢?是不是我80端口没开的原因?刚用lsof -i:80  没显示任何内容
回复

使用道具 举报

5

主题

357

帖子

2046

积分

金牌会员

Rank: 6Rank: 6

积分
2046
金钱
1674
HASS币
60
发表于 2021-9-28 19:28:57 | 显示全部楼层
pi@raspberrypi:/usr/share/hassio $ curl '192.168.0.18:80'
curl: (7) Failed to connect to 192.168.0.18 port 80: 拒绝连接
pi@raspberrypi:/usr/share/hassio $ 

80端口拒绝连接
回复

使用道具 举报

20

主题

550

帖子

3600

积分

元老级技术达人

积分
3600
金钱
3010
HASS币
210

教程狂人突出贡献

 楼主| 发表于 2021-9-29 01:06:50 | 显示全部楼层
本帖最后由 involute 于 2021-9-29 01:07 编辑

这个是你HomePod的地址?
回复

使用道具 举报

5

主题

357

帖子

2046

积分

金牌会员

Rank: 6Rank: 6

积分
2046
金钱
1674
HASS币
60
发表于 2021-9-29 08:52:26 | 显示全部楼层
involute 发表于 2021-9-29 01:06
这个是你HomePod的地址?

这个是树莓派的地址,但是不知道为什么会访问80端口
回复

使用道具 举报

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

本版积分规则

Archiver|手机版|小黑屋|Hassbian

GMT+8, 2024-4-29 21:40 , Processed in 0.247809 second(s), 31 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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