prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Italian language with Google TTS
  I'm running Mycroft on Manjaro Linux, with Italian language.
  I tried both the "British male" and "American male" voices, and they do not speak Italian at all. So I decided to try the Google Voice.
  That way, no sound is emitted. Whenever Mycroft tries to speak, I see this error in logs (file audio.log):
  
  ```
  2020-04-13 10:45:39.632 | INFO     | 195922 | mycroft.audio.speech:mute_and_speak:127 | Speak: Va uno spettacolo
  2020-04-13 10:45:40.070 | ERROR    | 195922 | mycroft.audio.speech:handle_speak:99 | Error in mute_and_speak
  Traceback (most recent call last):
    File "/home/luke/git/mycroft-core/mycroft/audio/speech.py", line 95, in handle_speak
      mute_and_speak(chunk, ident, listen)
    File "/home/luke/git/mycroft-core/mycroft/audio/speech.py", line 129, in mute_and_speak
      tts.execute(utterance, ident, listen)
    File "/home/luke/git/mycroft-core/mycroft/tts/tts.py", line 337, in execute
      wav_file, phonemes = self.get_tts(sentence, wav_file)
    File "/home/luke/git/mycroft-core/mycroft/tts/google_tts.py", line 35, in get_tts
      tts = gTTS(text=sentence, lang=self.lang)
    File "/home/luke/git/mycroft-core/.venv/lib/python3.8/site-packages/gtts/tts.py", line 121, in __init__
      raise ValueError("Language not supported: %s" % lang)
  ValueError: Language not supported: it-it
  ```
  
  The problem is that Google TTS can handle "it", but it cannot handle "it-it".
  
  I will release a PR shortly for fixing this. (So far, Google Voice seems my only option for Italian language, so I really need that).
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `mycroft/tts/google_tts.py`
  Content:
  ```
  1 # Copyright 2017 Mycroft AI Inc.
  2 #
  3 # Licensed under the Apache License, Version 2.0 (the "License");
  4 # you may not use this file except in compliance with the License.
  5 # You may obtain a copy of the License at
  6 #
  7 #    http://www.apache.org/licenses/LICENSE-2.0
  8 #
  9 # Unless required by applicable law or agreed to in writing, software
  10 # distributed under the License is distributed on an "AS IS" BASIS,
  11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12 # See the License for the specific language governing permissions and
  13 # limitations under the License.
  14 #
  15 from gtts import gTTS
  16 
  17 from .tts import TTS, TTSValidator
  18 
  19 
  20 class GoogleTTS(TTS):
  21     """Interface to google TTS."""
  22     def __init__(self, lang, config):
  23         super(GoogleTTS, self).__init__(lang, config, GoogleTTSValidator(
  24             self), 'mp3')
  25 
  26     def get_tts(self, sentence, wav_file):
  27         """Fetch tts audio using gTTS.
  28 
  29         Arguments:
  30             sentence (str): Sentence to generate audio for
  31             wav_file (str): output file path
  32         Returns:
  33             Tuple ((str) written file, None)
  34         """
  35         tts = gTTS(text=sentence, lang=self.lang)
  36         tts.save(wav_file)
  37         return (wav_file, None)  # No phonemes
  38 
  39 
  40 class GoogleTTSValidator(TTSValidator):
  41     def __init__(self, tts):
  42         super(GoogleTTSValidator, self).__init__(tts)
  43 
  44     def validate_lang(self):
  45         # TODO
  46         pass
  47 
  48     def validate_connection(self):
  49         try:
  50             gTTS(text='Hi').save(self.tts.filename)
  51         except Exception:
  52             raise Exception(
  53                 'GoogleTTS server could not be verified. Please check your '
  54                 'internet connection.')
  55 
  56     def get_tts_class(self):
  57         return GoogleTTS
  58
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/mycroft/tts/google_tts.py b/mycroft/tts/google_tts.py
  --- a/mycroft/tts/google_tts.py
  +++ b/mycroft/tts/google_tts.py
  @@ -13,13 +13,19 @@
   # limitations under the License.
   #
   from gtts import gTTS
  +from gtts.lang import tts_langs
   
   from .tts import TTS, TTSValidator
   
  +supported_langs = tts_langs()
  +
   
   class GoogleTTS(TTS):
       """Interface to google TTS."""
       def __init__(self, lang, config):
  +        if lang.lower() not in supported_langs and \
  +                                     lang[:2].lower() in supported_langs:
  +            lang = lang[:2]
           super(GoogleTTS, self).__init__(lang, config, GoogleTTSValidator(
               self), 'mp3')
   
  @@ -42,8 +48,10 @@
           super(GoogleTTSValidator, self).__init__(tts)
   
       def validate_lang(self):
  -        # TODO
  -        pass
  +        lang = self.tts.lang
  +        if lang.lower() not in supported_langs:
  +            raise ValueError("Language not supported by gTTS: {}"
  +                             .format(lang))
   
       def validate_connection(self):
           try:
  
verification_info: {"golden_diff": "diff --git a/mycroft/tts/google_tts.py b/mycroft/tts/google_tts.py\n--- a/mycroft/tts/google_tts.py\n+++ b/mycroft/tts/google_tts.py\n@@ -13,13 +13,19 @@\n # limitations under the License.\n #\n from gtts import gTTS\n+from gtts.lang import tts_langs\n \n from .tts import TTS, TTSValidator\n \n+supported_langs = tts_langs()\n+\n \n class GoogleTTS(TTS):\n     \"\"\"Interface to google TTS.\"\"\"\n     def __init__(self, lang, config):\n+        if lang.lower() not in supported_langs and \\\n+                                     lang[:2].lower() in supported_langs:\n+            lang = lang[:2]\n         super(GoogleTTS, self).__init__(lang, config, GoogleTTSValidator(\n             self), 'mp3')\n \n@@ -42,8 +48,10 @@\n         super(GoogleTTSValidator, self).__init__(tts)\n \n     def validate_lang(self):\n-        # TODO\n-        pass\n+        lang = self.tts.lang\n+        if lang.lower() not in supported_langs:\n+            raise ValueError(\"Language not supported by gTTS: {}\"\n+                             .format(lang))\n \n     def validate_connection(self):\n         try:\n", "issue": "Italian language with Google TTS\nI'm running Mycroft on Manjaro Linux, with Italian language.\r\nI tried both the \"British male\" and \"American male\" voices, and they do not speak Italian at all. So I decided to try the Google Voice.\r\nThat way, no sound is emitted. Whenever Mycroft tries to speak, I see this error in logs (file audio.log):\r\n\r\n```\r\n2020-04-13 10:45:39.632 | INFO     | 195922 | mycroft.audio.speech:mute_and_speak:127 | Speak: Va uno spettacolo\r\n2020-04-13 10:45:40.070 | ERROR    | 195922 | mycroft.audio.speech:handle_speak:99 | Error in mute_and_speak\r\nTraceback (most recent call last):\r\n  File \"/home/luke/git/mycroft-core/mycroft/audio/speech.py\", line 95, in handle_speak\r\n    mute_and_speak(chunk, ident, listen)\r\n  File \"/home/luke/git/mycroft-core/mycroft/audio/speech.py\", line 129, in mute_and_speak\r\n    tts.execute(utterance, ident, listen)\r\n  File \"/home/luke/git/mycroft-core/mycroft/tts/tts.py\", line 337, in execute\r\n    wav_file, phonemes = self.get_tts(sentence, wav_file)\r\n  File \"/home/luke/git/mycroft-core/mycroft/tts/google_tts.py\", line 35, in get_tts\r\n    tts = gTTS(text=sentence, lang=self.lang)\r\n  File \"/home/luke/git/mycroft-core/.venv/lib/python3.8/site-packages/gtts/tts.py\", line 121, in __init__\r\n    raise ValueError(\"Language not supported: %s\" % lang)\r\nValueError: Language not supported: it-it\r\n```\r\n\r\nThe problem is that Google TTS can handle \"it\", but it cannot handle \"it-it\".\r\n\r\nI will release a PR shortly for fixing this. (So far, Google Voice seems my only option for Italian language, so I really need that).\r\n\n", "before_files": [{"content": "# Copyright 2017 Mycroft AI Inc.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#    http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n#\nfrom gtts import gTTS\n\nfrom .tts import TTS, TTSValidator\n\n\nclass GoogleTTS(TTS):\n    \"\"\"Interface to google TTS.\"\"\"\n    def __init__(self, lang, config):\n        super(GoogleTTS, self).__init__(lang, config, GoogleTTSValidator(\n            self), 'mp3')\n\n    def get_tts(self, sentence, wav_file):\n        \"\"\"Fetch tts audio using gTTS.\n\n        Arguments:\n            sentence (str): Sentence to generate audio for\n            wav_file (str): output file path\n        Returns:\n            Tuple ((str) written file, None)\n        \"\"\"\n        tts = gTTS(text=sentence, lang=self.lang)\n        tts.save(wav_file)\n        return (wav_file, None)  # No phonemes\n\n\nclass GoogleTTSValidator(TTSValidator):\n    def __init__(self, tts):\n        super(GoogleTTSValidator, self).__init__(tts)\n\n    def validate_lang(self):\n        # TODO\n        pass\n\n    def validate_connection(self):\n        try:\n            gTTS(text='Hi').save(self.tts.filename)\n        except Exception:\n            raise Exception(\n                'GoogleTTS server could not be verified. Please check your '\n                'internet connection.')\n\n    def get_tts_class(self):\n        return GoogleTTS\n", "path": "mycroft/tts/google_tts.py"}], "after_files": [{"content": "# Copyright 2017 Mycroft AI Inc.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#    http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n#\nfrom gtts import gTTS\nfrom gtts.lang import tts_langs\n\nfrom .tts import TTS, TTSValidator\n\nsupported_langs = tts_langs()\n\n\nclass GoogleTTS(TTS):\n    \"\"\"Interface to google TTS.\"\"\"\n    def __init__(self, lang, config):\n        if lang.lower() not in supported_langs and \\\n                                     lang[:2].lower() in supported_langs:\n            lang = lang[:2]\n        super(GoogleTTS, self).__init__(lang, config, GoogleTTSValidator(\n            self), 'mp3')\n\n    def get_tts(self, sentence, wav_file):\n        \"\"\"Fetch tts audio using gTTS.\n\n        Arguments:\n            sentence (str): Sentence to generate audio for\n            wav_file (str): output file path\n        Returns:\n            Tuple ((str) written file, None)\n        \"\"\"\n        tts = gTTS(text=sentence, lang=self.lang)\n        tts.save(wav_file)\n        return (wav_file, None)  # No phonemes\n\n\nclass GoogleTTSValidator(TTSValidator):\n    def __init__(self, tts):\n        super(GoogleTTSValidator, self).__init__(tts)\n\n    def validate_lang(self):\n        lang = self.tts.lang\n        if lang.lower() not in supported_langs:\n            raise ValueError(\"Language not supported by gTTS: {}\"\n                             .format(lang))\n\n    def validate_connection(self):\n        try:\n            gTTS(text='Hi').save(self.tts.filename)\n        except Exception:\n            raise Exception(\n                'GoogleTTS server could not be verified. Please check your '\n                'internet connection.')\n\n    def get_tts_class(self):\n        return GoogleTTS\n", "path": "mycroft/tts/google_tts.py"}]}