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

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

[插件集成] 小爱同学TTS服务(2019年5月29日更新可用版本)

  [复制链接]

0

主题

62

帖子

299

积分

论坛积极会员

积分
299
金钱
237
HASS币
0
发表于 2018-5-6 19:42:40 | 显示全部楼层
好贴大家分享
回复

使用道具 举报

0

主题

18

帖子

80

积分

注册会员

Rank: 2

积分
80
金钱
62
HASS币
0
发表于 2018-5-6 19:47:50 | 显示全部楼层
執行python3 hello_miai.py 後 輸入完帳號密碼出現下面錯誤? 請問是我操作上的問題嗎? 謝謝

Traceback (most recent call last):
  File "hello_miai.py", line 255, in <module>
    xiaomi_tts(miid,password,login_info_dir='../.xiaoai',can_input_capt=True).speech("Token已生成",int(num))
  File "hello_miai.py", line 81, in __init__
    self._get_logon_info()
  File "hello_miai.py", line 237, in _get_logon_info
    self._serviceToken()
  File "hello_miai.py", line 157, in _serviceToken
    _serviceLoginAuth2_json=self._serviceLoginAuth2()
  File "hello_miai.py", line 109, in _serviceLoginAuth2
    self._headers['Cookie']='pass_ua={}; deviceId={}; pass_trace={}; uLocale={}; JSESSIONID={}'.format(self._cookies['pass_ua'],self._cookies['deviceId'],self._cookies['pass_trace'],self._cookies['uLocale'],self._cookies['JSESSIONID'])     
KeyError: 'pass_ua'
回复

使用道具 举报

15

主题

193

帖子

2052

积分

论坛技术达人

积分
2052
金钱
1839
HASS币
0

卓越贡献

 楼主| 发表于 2018-5-6 20:02:37 | 显示全部楼层
flame0205 发表于 2018-5-6 19:47
執行python3 hello_miai.py 後 輸入完帳號密碼出現下面錯誤? 請問是我操作上的問題嗎? 謝謝

Traceback (mo ...

这个错误是获取_sgin的时候失败了,应该还有一个报错的。
你看看有吗?
回复

使用道具 举报

5

主题

113

帖子

604

积分

高级会员

Rank: 4

积分
604
金钱
491
HASS币
0
发表于 2018-5-6 20:05:29 | 显示全部楼层
message: >
            主人,
            {% set timenow_hour = now().time().strftime("%H") | int %}
            {% if timenow_hour > 0 and timenow_hour < 13 %}
            今天是{{states.sensor.holiday.attributes.今天日期}},农历{{states.sensor.holiday.attributes.农历}},{{states.sensor.holiday.attributes.weekday}},{{states('sensor.holiday')}},
            {%- endif %}
            室外空气质量指数为{{states('sensor.caiyun_realtime_aqi')}},

楼主,上面代码在百度TTS等里面无问题,这个插件不能将{}里面的翻译为对应数据。
回复

使用道具 举报

0

主题

130

帖子

890

积分

高级会员

Rank: 4

积分
890
金钱
760
HASS币
0
发表于 2018-5-6 20:06:04 | 显示全部楼层
flame0205 发表于 2018-5-6 19:47
執行python3 hello_miai.py 後 輸入完帳號密碼出現下面錯誤? 請問是我操作上的問題嗎? 謝謝

Traceback (mo ...

我的执行完这样
Traceback (most recent call last):
  File "hello_miai.py", line 2, in <module>
    import requests
ImportError: No module named 'requests'
回复

使用道具 举报

15

主题

193

帖子

2052

积分

论坛技术达人

积分
2052
金钱
1839
HASS币
0

卓越贡献

 楼主| 发表于 2018-5-6 20:07:54 | 显示全部楼层
l58128667 发表于 2018-5-6 20:05
message: >
            主人,
            {% set timenow_hour = now().time().strftime("%H") | int % ...
    - service: hello_miai.send
      data_template: 
        message: "警报,警报,入侵警报,危险接近,还有{{ trigger.to_state.state}}公里,请小心!"
        miai_num: "0"

给你一个我在用的简单示例,比你的简单,但是原理是一样的
回复

使用道具 举报

15

主题

193

帖子

2052

积分

论坛技术达人

积分
2052
金钱
1839
HASS币
0

卓越贡献

 楼主| 发表于 2018-5-6 20:09:49 | 显示全部楼层
thruway 发表于 2018-5-6 20:06
我的执行完这样
Traceback (most recent call last):
  File "hello_miai.py", line 2, in

pip3 install requests
回复

使用道具 举报

2

主题

231

帖子

1866

积分

金牌会员

Rank: 6Rank: 6

积分
1866
金钱
1635
HASS币
0
发表于 2018-5-6 20:11:37 来自手机 | 显示全部楼层
感謝分享
回复

使用道具 举报

123

主题

4630

帖子

1万

积分

管理员

囧死

Rank: 9Rank: 9Rank: 9

积分
16131
金钱
11416
HASS币
45
发表于 2018-5-6 20:50:20 | 显示全部楼层
更新版测试成功,s大v5!
回复

使用道具 举报

9

主题

358

帖子

3063

积分

论坛元老

Rank: 8Rank: 8

积分
3063
金钱
2705
HASS币
0
发表于 2018-5-6 20:51:23 | 显示全部楼层
我的錯誤如下

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/config/custom_components/hello_miai.py", line 93, in _get_sign
    self._cookies['pass_ua']=self._request.cookies.get_dict()['pass_ua']
KeyError: 'pass_ua'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/app/homeassistant/core.py", line 1014, in _event_to_service_call
    await self._hass.async_add_job(execute_service)
  File "/usr/local/lib/python3.6/asyncio/futures.py", line 327, in __iter__
    yield self  # This tells Task to wait for completion.
  File "/usr/local/lib/python3.6/asyncio/tasks.py", line 250, in _wakeup
    future.result()
  File "/usr/local/lib/python3.6/asyncio/futures.py", line 243, in result
    raise self._exception
  File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/app/homeassistant/core.py", line 1011, in execute_service
    service_handler.func(service_call)
  File "/config/custom_components/hello_miai.py", line 50, in send_message
    client = xiaomi_tts(miid, password,login_info_dir=hass.config.config_dir+'/.xiaoai')
  File "/config/custom_components/hello_miai.py", line 81, in __init__
    self._get_logon_info()
  File "/config/custom_components/hello_miai.py", line 237, in _get_logon_info
    self._serviceToken()
  File "/config/custom_components/hello_miai.py", line 157, in _serviceToken
    _serviceLoginAuth2_json=self._serviceLoginAuth2()
  File "/config/custom_components/hello_miai.py", line 108, in _serviceLoginAuth2
    self._sign=self._get_sign()  #获取sign
  File "/config/custom_components/hello_miai.py", line 98, in _get_sign
    _LOGGER.error('_get_sign',e)
  File "/usr/local/lib/python3.6/logging/__init__.py", line 1335, in error
    self._log(ERROR, msg, args, **kwargs)
  File "/usr/local/lib/python3.6/logging/__init__.py", line 1442, in _log
    self.handle(record)
  File "/usr/local/lib/python3.6/logging/__init__.py", line 1452, in handle
    self.callHandlers(record)
  File "/usr/local/lib/python3.6/logging/__init__.py", line 1514, in callHandlers
    hdlr.handle(record)
  File "/usr/local/lib/python3.6/logging/__init__.py", line 863, in handle
    self.emit(record)
  File "/usr/src/app/homeassistant/components/system_log/__init__.py", line 131, in emit
    entry = self._create_entry(record, stack)
  File "/usr/src/app/homeassistant/components/system_log/__init__.py", line 110, in _create_entry
    'message': record.getMessage(),
  File "/usr/local/lib/python3.6/logging/__init__.py", line 338, in getMessage
    msg = msg % self.args
TypeError: not all arguments converted during string formatting
回复

使用道具 举报

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

本版积分规则

Archiver|手机版|小黑屋|Hassbian

GMT+8, 2024-6-1 23:44 , Processed in 0.055683 second(s), 31 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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