Skip to content

Commit

Permalink
[RU] Fix negative temperature pronouncing (#2068)
Browse files Browse the repository at this point in the history
In russian language TTS doesn't handle negative values correctly and
thus does not pronounce word "minus".

In order to fix this problem, temperature value is checked before
response and if it's negative, word “minus” is added at the response
begining.

This fix addressing #1683 and has been ported from #2038.
  • Loading branch information
HepoH3 committed Mar 9, 2024
1 parent f2450b6 commit e1a0c27
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 4 deletions.
11 changes: 10 additions & 1 deletion responses/ru/HassGetWeather.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,13 @@ responses:
'windy': ', ветренно',
'windy-variant': ', ветренно и облачно'
} %}
{{ state.attributes.get('temperature') }} {{ state.attributes.get('temperature_unit') }}{{ weather_condition.get((state.state | string).lower(), "") }}
{% set temperature = state.attributes.get('temperature') | float %}
{% if temperature < 0 %}
{% set temperature_string = 'минус ' ~ (temperature * -1) | string | replace('.', ',') %}
{% else %}
{% set temperature_string = temperature | string | replace('.', ',') %}
{% endif %}
{{ temperature_string }} {{ state.attributes.get('temperature_unit') }}{{ weather_condition.get((state.state | string).lower(), state.state | string) }}
7 changes: 7 additions & 0 deletions tests/ru/_fixtures.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -680,6 +680,13 @@ entities:
temperature: "24"
temperature_unit: "°C"

- name: "Зеленоград[е]"
id: "weather.zelenograd"
state: "sunny"
attributes:
temperature: "-5.5"
temperature_unit: "°C"

- name: "Воронеж[е]"
id: "weather.voronezh"
state: "clear"
Expand Down
14 changes: 11 additions & 3 deletions tests/ru/weather_HassGetWeather.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ tests:
- "погода"
intent:
name: HassGetWeather
response: 24 °C, облачно
response: 24,0 °C, облачно

- sentences:
- "Какая погода в Москве?"
Expand All @@ -14,12 +14,20 @@ tests:
name: HassGetWeather
slots:
name: Москве
response: 24 °C, облачно
response: 24,0 °C, облачно

- sentences:
- "Какая погода в Зеленограде?"
intent:
name: HassGetWeather
slots:
name: Зеленограде
response: минус 5,5 °C, солнечно

- sentences:
- "погода в Воронеже"
intent:
name: HassGetWeather
slots:
name: Воронеже
response: 13 °C, ясно
response: 13,0 °C, ясно

0 comments on commit e1a0c27

Please sign in to comment.