Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Google TTS can't read sensor value containing the percent sign '%' #6971

Closed
pezinek opened this issue Apr 7, 2017 · 4 comments · Fixed by #7030
Closed

Google TTS can't read sensor value containing the percent sign '%' #6971

pezinek opened this issue Apr 7, 2017 · 4 comments · Fixed by #7030

Comments

@pezinek
Copy link
Contributor

pezinek commented Apr 7, 2017

Home Assistant release (hass --version):

0.41.0

Python release (python3 --version):

Python 3.4.2

Component/platform:

tts/google

Description of problem:

When the Google TTS engine receives a message template with sensor value that contains the percent sign '%' exception is thrown and nothing will get said.

Expected:

Make the Google TTS behave consistently no matter what sensor values we are trying to read.

Problem-relevant configuration.yaml entries and steps to reproduce:

tts:
  platform: google
  language: cs

automation:
  - alias: 'weather forecast'
    trigger:
      - platform: time
        after: '7:00:00'
  action:
     - service: tts.google_say
       entity_id: media_player.kodi
       data_template:
          message: "Předpověď počasí: {{ states('sensor.pws_forecast_daily_1_text_metric') }}"
          cache: false

Where the state of the sensor is:

Dnes bude Déšť. Nejvyšší teploty 8 ° C. Vítr ZSZ o rychlosti 15 - 30 km/h. Pravděpod. deště 90 %. Dešťové srážky kolem ~ 6 mm.

How to reproduce:

  1. Go to the "Services" page in the GUI

  2. Set these values

    Domain:

    tts
    

    Service:

    google_say
    

    Service Data:

    {"message":"90 %"}
    
  3. Click "Call Service"

Traceback (if applicable):

17-04-07 07:51:41 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/lib/python3.4/asyncio/tasks.py", line 235, in _step
    result = coro.send(value)
  File "/srv/homeassistant/lib/python3.4/site-packages/homeassistant/core.py", line 1010, in _event_to_service_call
    yield from service_handler.func(service_call)
  File "/srv/homeassistant/lib/python3.4/site-packages/homeassistant/components/tts/__init__.py", line 139, in async_say_handle
    options=options
  File "/srv/homeassistant/lib/python3.4/site-packages/homeassistant/components/tts/__init__.py", line 310, in async_get_url
    engine, key, message, use_cache, language, options)
  File "/srv/homeassistant/lib/python3.4/site-packages/homeassistant/components/tts/__init__.py", line 324, in async_get_tts_audio
    message, language, options)
  File "/srv/homeassistant/lib/python3.4/site-packages/homeassistant/components/tts/google.py", line 90, in async_get_tts_audio
    'q': yarl.quote(part),
  File "yarl/_quoting.pyx", line 45, in yarl._quoting._quote (yarl/_quoting.c:1533)
  File "yarl/_quoting.pyx", line 135, in yarl._quoting._do_quote (yarl/_quoting.c:2483)
ValueError: Unallowed PCT %
17-04-07 07:51:45 ERROR (MainThread) [homeassistant.components.tts.google] Error 404 on load url http://translate.google.com/translate_tts?total=1&tk=903490.760623&idx=0&client=tw-ob&tl=cs&q=&textlen=0&ie=UTF-8

Additional info:

@pvizeli
Copy link
Member

pvizeli commented Apr 7, 2017

Please make a issue here: https://github.com/aio-libs/yarl/

@pezinek
Copy link
Contributor Author

pezinek commented Apr 10, 2017

This issue seems to be solved in yarl already in aio-libs/yarl#21 by introducing "non-strict" mode.
If I understand the yarl code properly, tts.google should now just call quote as:

yarl.quote(part, strict=False)

@pvizeli
Copy link
Member

pvizeli commented Apr 10, 2017

Please make a PR with that 👍

pezinek added a commit to pezinek/home-assistant that referenced this issue Apr 10, 2017
@pezinek
Copy link
Contributor Author

pezinek commented Apr 10, 2017

OK, even though the hass integration process is kind of heavy-weight for me and I may need some hand holding to get through it ;-)

@balloob balloob mentioned this issue Apr 21, 2017
@home-assistant home-assistant locked and limited conversation to collaborators Jul 17, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants