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

Dutch tts.google_say pronounces Month as march, instead of Maart... #47220

Closed
Mariusthvdb opened this issue Mar 1, 2021 · 15 comments
Closed

Comments

@Mariusthvdb
Copy link
Contributor

Mariusthvdb commented Mar 1, 2021

The problem

as above, a Dutch speaker says 'march' (marg) instead of Maart.

What is version of Home Assistant Core has the issue?

2021.2.3

What was the last working version of Home Assistant Core?

?

What type of installation are you running?

Home Assistant OS

Integration causing the issue

google translate

Link to integration documentation on our website

https://www.home-assistant.io/integrations/google_translate/

Example YAML snippet

# Put your YAML below this line
  notify_startup:
    alias: Notify startup
    mode: restart
    sequence:
      - service: script.intercom_message
        data:
          message_en: >
            Good {{states('sensor.part_of_day')}}, Home-assistant Rpi4 is back up and running since
            {{now().strftime('%d %B %X')}} and it is
            {{states('sensor.temp_current')}} degrees.
          message_nl: >
            Goede{{states('sensor.dag_deel')}}, Home-assistant Rpi4 is weer actief sinds
            {{now().strftime('%-d %B %X')}} en buiten is het
            {{states('sensor.temp_current')}} graden.

and script

      - service: tts.google_say
        data:
          language: >
            {{states('input_select.intercom_language')|lower}}
          entity_id: >
            {{states('sensor.intercom')}}
          message: >
            {% set language = states('input_select.intercom_language') %}
            {% if language == 'En' %} {{message_en}}
            {% elif language == 'Nl' %} {{message_nl}}
            {% else %} {{message_en}}
            {% endif %}

Anything in the logs that might be useful for us?

# Put your logs below this line

switching the language to English works fine, and the rest of the templates are spoken perfectly. Its only the date sensor which confuses the TTS engine, and has done so for long while. Don't remember which version , sorry, though did file earlier issues on the subject.
Before, Google was smart enough to translate all in correct Dutch, just like it still does with 'uur, minuten en seconden'

{{now().strftime('%A %-d %B %X')}}

makes the same error, saying 'monday' instead of Maandag.....

@probot-home-assistant
Copy link

google_translate documentation
google_translate source
(message by IssueLinks)

@dougmaitelli
Copy link

Does google translate say it correctly if you try it directly there? https://translate.google.com/

@Mariusthvdb
Copy link
Contributor Author

not sure how that would work with a template?

@dougmaitelli
Copy link

not sure how that would work with a template?

Well, my point is, HA is just calling google translate and getting the mp3 audio file, if the pronunciation is not correct it most likely is a Google issue and not an HA issue.

I am not telling you to try https://translate.google.com/ in your template, but instead get the text that your TTS is reading wrong and see if https://translate.google.com/ does in fact read it right. If it does not then this is not an HA issue.

@Mariusthvdb
Copy link
Contributor Author

well, it was translated just fine before.
And yes, it is still translated correctly:
Schermafbeelding 2021-03-02 om 22 51 31

is this really relevant, as in, is this the same Google translate service?

@hmmbob
Copy link
Contributor

hmmbob commented Mar 3, 2021

Well, you are telling Google that the text you want to be transferred in audio is Dutch (by language: nl) yet you are feeding it English language month and day information.

Even though the service is called google_translate, HA does not target the translating code but the "audio generation part" of Google Translate. As such, this is expected behavior and the solution lies in you feeding the correct info into the template.

This is not a HA issue, and it might have worked before by the grace of Google's inner workings but that apparently has changed.

If you feed it Dutch information, it'll work fine. You'll probably need some templating.

@hmmbob
Copy link
Contributor

hmmbob commented Mar 3, 2021

And please stop using other issues to refer to this issue, that's not how this works. You can close the others as they are resolved.

@Mariusthvdb
Copy link
Contributor Author

Mariusthvdb commented Mar 3, 2021

If you feed it Dutch information, it'll work fine. You'll probably need some templating.

yet you are feeding it English language month and day information.

that's just the thing, I am feeding it core HA template, which should be translated. And, it has been translated before, right now it only does so partly.

my language: nl is only to have the non template part of the message be set to dutch. Seems a bit unexpected the grace of Google's inner workings would have changed that, especially since I've shown in the post above, it does so correctly.

besides all of this, what template would you suggest to feed it replacing

{{now().strftime('%A %-d %B %X')}}

which is the issue at hand.

fwiw, the template you suggested in the other issue:

{{as_timestamp(now())|timestamp_custom('%A %-d %B %X')}}

produces the same error in Dutch and other languages, do you really hear it say
Woensdag 3 Maart 13:42:00?

Setting the main config language has no effect either (thought for a minute it could be the fact my main config is in English.)

@hmmbob
Copy link
Contributor

hmmbob commented Mar 3, 2021

Read the first two blocks of my answer again, combined with this result in the template editor:
image

You are feeding the system with an English string. The system is trying to create audio based on that string. It is not a translation service, it is an audio generation service. So as long as you feed it English and expect Dutch as an answer it will not work. Like said, it might have worked in the past but apparently it doesn't work anymore.

By the way: the answer above is the same as what I was trying to tell you here: #40925 (comment). I'll put it really blunt here:

As long as you feed it English text and expect Dutch audio as an answer it will not work


As for the template; I am using this in my lovelace. Something similar might help you here.

{% set months = ["januari", "februari", "maart", "april", "mei", "juni", "juli", "augustus", "september", "oktober", "november", "december"] %}
{% set month = months[now().month -1] %}
{% set days = ["Maandag", "Dinsdag", "Woensdag", "Donderdag", "Vrijdag", "Zaterdag", "Zondag"]  %}
{% set day = days[now().weekday()] %}
# {{ day + ' ' + now().strftime('%-d') + ' ' + month }}

@Mariusthvdb
Copy link
Contributor Author

Ok thanks. Was merely comparing with before. too bad things changed for the worse.

btw, why do you say this is an English language string

{{now().strftime('%A %-d %B %X')}}

Would think this to be a language agnostic string.
And yes, I have these translating templates in my config too. That's not the issue. Using this for now:

            Goede{{states('sensor.dag_deel')}}, Home-assistant Rpi4 is weer actief sinds
            {{states('sensor.dag')}} {{now().strftime('%-d')}} {{states('sensor.maand')}} en buiten is het
            {{states('sensor.temp_current')}} graden.

got to admit this is rather contrived... Hope this gets repaired, where ever that might be needed.

@hmmbob
Copy link
Contributor

hmmbob commented Mar 3, 2021

btw, why do you say this is an English language string

{{now().strftime('%A %-d %B %X')}}

Would think this to be a language agnostic string.

See screenshot. Or try it yourself in the template editor.

@Mariusthvdb
Copy link
Contributor Author

Mariusthvdb commented Mar 3, 2021

Well yes, I understand the HA template editor shows an English sentence. That is, it uses English words. As Strftime.org indicates though, it should create a 'locale' string:

Schermafbeelding 2021-03-03 om 15 23 02

which is what I mean with language agnostic. The template doesn't set the translation, the interpreter does (or should we say 'should')

so where lies the error...

@hmmbob
Copy link
Contributor

hmmbob commented Mar 3, 2021

Not with Google Translate TTS.

Again: As long as you feed it English text and expect Dutch audio as an answer it will not work. But I'll stop repeating myself, as I am probably not clear in my communication or something.

@Mariusthvdb
Copy link
Contributor Author

Mariusthvdb commented Mar 3, 2021

yeah, I'll close. Its not you.. I do see what you are saying.

Rather it's me, I seem not to get across the fact that when using a template in HA, is should be localized according to strftime's own documentation, and not default to English as it seems to do, no matter the instances language setting.

Leaving it up to the enduser to create all sorts of complex templates, where the system should take care of this really.
Also, the 'Google must have changed something' is not very satisfactory and might even be not the case, since we don't know do we.

Anyways, thanks for your time and effort.
cheers!

@hmmbob
Copy link
Contributor

hmmbob commented Mar 3, 2021

I've read, while researching this, more complaints like this on the forums and I tend to agree with your statements that this shouldn't be handled through templates. Maybe creating a specific issue for this (strftime not being localized or something) might help. But, as you validly state: it's an issue in the core, not in the component.

cheers!

@github-actions github-actions bot locked and limited conversation to collaborators Apr 2, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants