Announcement

Collapse
No announcement yet.

Google Translator and accented characters problem

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Google Translator and accented characters problem

    First of all, what a great plugin this is!

    What is really cool that we can use Google Translator TTS engine to make it talk in any language. But there is a problem. If I use accented characters, like ä, in a phrase, those characters are encoded in a way that doesn't make sense to Google. For instance, if you want Homeseer say, "Motörhead", it sounds right with Homeseer voice, but not with Google translator voice. Could this be fixed?

  • #2
    I'll have a look, sure.

    And I love Motörhead, my favourite song God Was Never on Your Side

    Comment


    • #3
      I made the Google TTS text encoding configurable, so accented characters are supported (not encoded). But this change may produce unexpected results, i.e. '+' sign is not encoded anymore, so it's now ignored because it's treated as 'space'. URL encoding is a messy question, so I don't know which way is safer. We'll see..

      Ver 1.0.0.7 now in Beta section (until approved by HST)

      Comment


      • #4
        Is it possible to get localised voices? Like English (AU) for us Aussies, Alex?

        Guessing not because Google translate TTS isn't Google Assistant's voice.

        Comment


        • #5
          Originally posted by XeKToReX View Post
          Is it possible to get localised voices? Like English (AU) for us Aussies, Alex?
          Actually it's pretty easy, you can test yourself using Google Translate url, i.e.

          https://translate.google.com/transla...guage&tl=en_uk
          https://translate.google.com/transla...guage&tl=en_us
          https://translate.google.com/transla...guage&tl=en_au

          I'll see when and how I can modify the plugin to support that.
          Also I'm planning to add official Google Cloud translate API as another option - it should be much better, but will require user registration.

          Anyways, better place for requests:

          https://forums.homeseer.com/forum/me...atures-request

          Comment


          • #6
            Ver 1.0.0.8 - Couldn't resist and implemented "en_us", "en_uk" and "en_au", and "CUSTOM" setting for any other languages, where you can enter the language id string directly.

            Comment


            • #7
              Originally posted by alexbk66 View Post
              I made the Google TTS text encoding configurable, so accented characters are supported (not encoded). But this change may produce unexpected results, i.e. '+' sign is not encoded anymore, so it's now ignored because it's treated as 'space'. URL encoding is a messy question, so I don't know which way is safer. We'll see..

              Ver 1.0.0.7 now in Beta section (until approved by HST)
              This is an old thread, I know, but… Did you really implement this? I may be missing something but I fail to see this configuration option anywhere.

              Comment


              • #8
                Originally posted by anhakkar View Post

                This is an old thread, I know, but… Did you really implement this? I may be missing something but I fail to see this configuration option anywhere.
                I did make it configurable at some stage, but then found better solution (can't remember exactly).

                Doesn't it work?

                Comment


                • #9
                  Originally posted by anhakkar View Post

                  This is an old thread, I know, but… Did you really implement this? I may be missing something but I fail to see this configuration option anywhere.
                  Actually, I checked the 1.0.0.7 commit - I added the setting in the config file - not exposed to the user because it was quite untested.

                  If you wanna try, it's in HSPI_AKGoogleCast.exe.config, change <value> to True

                  Code:
                  <setting name="UrlEncode" serializeAs="String">
                      <value>False</value>
                  </setting>

                  Comment


                  • #10
                    I tried this, but it doesn't seem to make any change in the output. I have a test event in HS: Speak "Motörhead". Either way, the Googlecast speaker says something like this:

                    mot, percent, U, 0, 0, F, 6, R, H, E, A, D

                    That is, mot%u00F6rhead

                    It seems that somewhere, URL escape codes are not formed correctly. Escape codes for urls and html are not the same.

                    https://graphemica.com/ö


                    This url, when pasted to browser, sounds right:
                    https://translate.google.com/transla...rhead&tl=fi_fi


                    This is what it now sounds like:
                    https://translate.google.com/transla...rhead&tl=fi_fi


                    Comment


                    • #11
                      Originally posted by anhakkar View Post
                      I tried this, but it doesn't seem to make any change in the output. I have a test event in HS: Speak "Motörhead". Either way, the Googlecast speaker says something like this:

                      mot, percent, U, 0, 0, F, 6, R, H, E, A, D

                      That is, mot%u00F6rhead

                      It seems that somewhere, URL escape codes are not formed correctly. Escape codes for urls and html are not the same.

                      https://graphemica.com/ö


                      This url, when pasted to browser, sounds right:
                      https://translate.google.com/transla...rhead&tl=fi_fi


                      This is what it now sounds like:
                      https://translate.google.com/transla...rhead&tl=fi_fi

                      "Motörhead" - that exactly what I was using for testing

                      I'll have to check again... I remember that .NET provides many different functions for encoding url, all of them have different behaviour...

                      Comment


                      • #12
                        Code:
                        if (UrlEncode)
                            text = HttpUtility.UrlEncode(text, Encoding.Default);
                        else
                            text = text.Replace(" ", "+");
                        I'm using HttpUtility.UrlEncode

                        Did you restart the plugin after changing "UrlEncode"?

                        Comment


                        • #13
                          I did. In fact, I had to shutdown HS to be able to edit the file.

                          Comment


                          • #14
                            Originally posted by anhakkar View Post
                            I did. In fact, I had to shutdown HS to be able to edit the file.
                            Ok, I'll check again.

                            Comment

                            Working...
                            X