We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Add note about legal issues when using gTTS in public or commercial projects
originally opened in the OVOS plugin repo

> I've just posted an issue about potential legal issues with this API in the gTTS repo: [pndurette/gTTS#309](https://github.com/pndurette/gTTS/issues/309)
> 
> From the plugin description people will only understand that the service can break anytime but there are more risks. Imagine someone will build a system that goes into "production" with this plugin active (you know how people are ^^) and commercializes it. In the best case Google will just ask the owner to shut it down, in the worst case they will get sued :-/.
> 
> Personally I don't think an undocumented and unstable API moving in a legal gray area should be included in a system called OpenVoiceOS. For the same reasons it is not part of SEPIA OpenAssistant Framework.
> 
> That said I know first hand how hard it is to find an alternative that has comparable quality, is free (=self-hosted) and fast enough to run on Raspberry Pi etc., but I think services like gTTS are just a distraction on the path to become really "open"!



links:

https://github.com/OpenVoiceOS/ovos-tts-plugin-google-tx/issues/1
https://github.com/pndurette/gTTS/issues/309

--- 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 from gtts.lang import tts_langs
17 
18 from .tts import TTS, TTSValidator
19 
20 from mycroft.util.log import LOG
21 
22 # Live list of languages
23 # Cached list of supported languages (2021-02-09)
24 _default_langs = {'af': 'Afrikaans', 'sq': 'Albanian', 'ar': 'Arabic',
25                   'hy': 'Armenian', 'bn': 'Bengali', 'bs': 'Bosnian',
26                   'ca': 'Catalan', 'hr': 'Croatian', 'cs': 'Czech',
27                   'da': 'Danish', 'nl': 'Dutch', 'en': 'English',
28                   'eo': 'Esperanto', 'et': 'Estonian', 'tl': 'Filipino',
29                   'fi': 'Finnish', 'fr': 'French', 'de': 'German',
30                   'el': 'Greek', 'gu': 'Gujarati', 'hi': 'Hindi',
31                   'hu': 'Hungarian', 'is': 'Icelandic', 'id': 'Indonesian',
32                   'it': 'Italian', 'ja': 'Japanese', 'jw': 'Javanese',
33                   'kn': 'Kannada', 'km': 'Khmer', 'ko': 'Korean',
34                   'la': 'Latin', 'lv': 'Latvian', 'mk': 'Macedonian',
35                   'ml': 'Malayalam', 'mr': 'Marathi',
36                   'my': 'Myanmar (Burmese)', 'ne': 'Nepali',
37                   'no': 'Norwegian', 'pl': 'Polish', 'pt': 'Portuguese',
38                   'ro': 'Romanian', 'ru': 'Russian', 'sr': 'Serbian',
39                   'si': 'Sinhala', 'sk': 'Slovak', 'es': 'Spanish',
40                   'su': 'Sundanese', 'sw': 'Swahili', 'sv': 'Swedish',
41                   'ta': 'Tamil', 'te': 'Telugu', 'th': 'Thai', 'tr': 'Turkish',
42                   'uk': 'Ukrainian', 'ur': 'Urdu', 'vi': 'Vietnamese',
43                   'cy': 'Welsh', 'zh': 'Chinese (Mandarin/China)'
44                   }
45 
46 
47 _supported_langs = None
48 
49 
50 def get_supported_langs():
51     """Get dict of supported languages.
52 
53     Tries to fetch remote list, if that fails a local cache will be used.
54 
55     Returns:
56         (dict): Lang code to lang name map.
57     """
58     global _supported_langs
59     if not _supported_langs:
60         try:
61             _supported_langs = tts_langs()
62         except Exception:
63             LOG.warning('Couldn\'t fetch upto date language codes')
64     return _supported_langs or _default_langs
65 
66 
67 class GoogleTTS(TTS):
68     """Interface to google TTS."""
69     def __init__(self, lang, config):
70         self._google_lang = None
71         super(GoogleTTS, self).__init__(lang, config, GoogleTTSValidator(
72             self), 'mp3')
73 
74     @property
75     def google_lang(self):
76         """Property containing a converted language code suitable for gTTS."""
77         supported_langs = get_supported_langs()
78         if not self._google_lang:
79             if self.lang.lower() in supported_langs:
80                 self._google_lang = self.lang.lower()
81             elif self.lang[:2].lower() in supported_langs:
82                 self._google_lang = self.lang[:2]
83         return self._google_lang or self.lang.lower()
84 
85     def get_tts(self, sentence, wav_file):
86         """Fetch tts audio using gTTS.
87 
88         Args:
89             sentence (str): Sentence to generate audio for
90             wav_file (str): output file path
91         Returns:
92             Tuple ((str) written file, None)
93         """
94         tts = gTTS(text=sentence, lang=self.google_lang)
95         tts.save(wav_file)
96         return (wav_file, None)  # No phonemes
97 
98 
99 class GoogleTTSValidator(TTSValidator):
100     def __init__(self, tts):
101         super(GoogleTTSValidator, self).__init__(tts)
102 
103     def validate_lang(self):
104         lang = self.tts.google_lang
105         if lang.lower() not in get_supported_langs():
106             raise ValueError("Language not supported by gTTS: {}".format(lang))
107 
108     def validate_connection(self):
109         try:
110             gTTS(text='Hi').save(self.tts.filename)
111         except Exception:
112             raise Exception(
113                 'GoogleTTS server could not be verified. Please check your '
114                 'internet connection.')
115 
116     def get_tts_class(self):
117         return GoogleTTS
118
```
--- 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()

```

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
@@ -70,6 +70,13 @@
         self._google_lang = None
         super(GoogleTTS, self).__init__(lang, config, GoogleTTSValidator(
             self), 'mp3')
+        LOG.warning(
+            "The Google TTS module uses the gTTS Python package which itself "
+            "interfaces with the Google Translate text-to-speech API. This is "
+            "not intended for commercial or production usage. The service "
+            "may break at any time, and you are subject to their Terms of "
+            "Service that can be found at https://policies.google.com/terms"
+        )
 
     @property
     def google_lang(self):

{"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@@ -70,6 +70,13 @@\n         self._google_lang = None\n         super(GoogleTTS, self).__init__(lang, config, GoogleTTSValidator(\n             self), 'mp3')\n+        LOG.warning(\n+            \"The Google TTS module uses the gTTS Python package which itself \"\n+            \"interfaces with the Google Translate text-to-speech API. This is \"\n+            \"not intended for commercial or production usage. The service \"\n+            \"may break at any time, and you are subject to their Terms of \"\n+            \"Service that can be found at https://policies.google.com/terms\"\n+        )\n \n     @property\n     def google_lang(self):\n", "issue": "Add note about legal issues when using gTTS in public or commercial projects\noriginally opened in the OVOS plugin repo\r\n\r\n> I've just posted an issue about potential legal issues with this API in the gTTS repo: [pndurette/gTTS#309](https://github.com/pndurette/gTTS/issues/309)\r\n> \r\n> From the plugin description people will only understand that the service can break anytime but there are more risks. Imagine someone will build a system that goes into \"production\" with this plugin active (you know how people are ^^) and commercializes it. In the best case Google will just ask the owner to shut it down, in the worst case they will get sued :-/.\r\n> \r\n> Personally I don't think an undocumented and unstable API moving in a legal gray area should be included in a system called OpenVoiceOS. For the same reasons it is not part of SEPIA OpenAssistant Framework.\r\n> \r\n> That said I know first hand how hard it is to find an alternative that has comparable quality, is free (=self-hosted) and fast enough to run on Raspberry Pi etc., but I think services like gTTS are just a distraction on the path to become really \"open\"!\r\n\r\n\r\n\r\nlinks:\r\n\r\nhttps://github.com/OpenVoiceOS/ovos-tts-plugin-google-tx/issues/1\r\nhttps://github.com/pndurette/gTTS/issues/309\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\nfrom gtts.lang import tts_langs\n\nfrom .tts import TTS, TTSValidator\n\nfrom mycroft.util.log import LOG\n\n# Live list of languages\n# Cached list of supported languages (2021-02-09)\n_default_langs = {'af': 'Afrikaans', 'sq': 'Albanian', 'ar': 'Arabic',\n                  'hy': 'Armenian', 'bn': 'Bengali', 'bs': 'Bosnian',\n                  'ca': 'Catalan', 'hr': 'Croatian', 'cs': 'Czech',\n                  'da': 'Danish', 'nl': 'Dutch', 'en': 'English',\n                  'eo': 'Esperanto', 'et': 'Estonian', 'tl': 'Filipino',\n                  'fi': 'Finnish', 'fr': 'French', 'de': 'German',\n                  'el': 'Greek', 'gu': 'Gujarati', 'hi': 'Hindi',\n                  'hu': 'Hungarian', 'is': 'Icelandic', 'id': 'Indonesian',\n                  'it': 'Italian', 'ja': 'Japanese', 'jw': 'Javanese',\n                  'kn': 'Kannada', 'km': 'Khmer', 'ko': 'Korean',\n                  'la': 'Latin', 'lv': 'Latvian', 'mk': 'Macedonian',\n                  'ml': 'Malayalam', 'mr': 'Marathi',\n                  'my': 'Myanmar (Burmese)', 'ne': 'Nepali',\n                  'no': 'Norwegian', 'pl': 'Polish', 'pt': 'Portuguese',\n                  'ro': 'Romanian', 'ru': 'Russian', 'sr': 'Serbian',\n                  'si': 'Sinhala', 'sk': 'Slovak', 'es': 'Spanish',\n                  'su': 'Sundanese', 'sw': 'Swahili', 'sv': 'Swedish',\n                  'ta': 'Tamil', 'te': 'Telugu', 'th': 'Thai', 'tr': 'Turkish',\n                  'uk': 'Ukrainian', 'ur': 'Urdu', 'vi': 'Vietnamese',\n                  'cy': 'Welsh', 'zh': 'Chinese (Mandarin/China)'\n                  }\n\n\n_supported_langs = None\n\n\ndef get_supported_langs():\n    \"\"\"Get dict of supported languages.\n\n    Tries to fetch remote list, if that fails a local cache will be used.\n\n    Returns:\n        (dict): Lang code to lang name map.\n    \"\"\"\n    global _supported_langs\n    if not _supported_langs:\n        try:\n            _supported_langs = tts_langs()\n        except Exception:\n            LOG.warning('Couldn\\'t fetch upto date language codes')\n    return _supported_langs or _default_langs\n\n\nclass GoogleTTS(TTS):\n    \"\"\"Interface to google TTS.\"\"\"\n    def __init__(self, lang, config):\n        self._google_lang = None\n        super(GoogleTTS, self).__init__(lang, config, GoogleTTSValidator(\n            self), 'mp3')\n\n    @property\n    def google_lang(self):\n        \"\"\"Property containing a converted language code suitable for gTTS.\"\"\"\n        supported_langs = get_supported_langs()\n        if not self._google_lang:\n            if self.lang.lower() in supported_langs:\n                self._google_lang = self.lang.lower()\n            elif self.lang[:2].lower() in supported_langs:\n                self._google_lang = self.lang[:2]\n        return self._google_lang or self.lang.lower()\n\n    def get_tts(self, sentence, wav_file):\n        \"\"\"Fetch tts audio using gTTS.\n\n        Args:\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.google_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.google_lang\n        if lang.lower() not in get_supported_langs():\n            raise ValueError(\"Language not supported by gTTS: {}\".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"}], "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\nfrom mycroft.util.log import LOG\n\n# Live list of languages\n# Cached list of supported languages (2021-02-09)\n_default_langs = {'af': 'Afrikaans', 'sq': 'Albanian', 'ar': 'Arabic',\n                  'hy': 'Armenian', 'bn': 'Bengali', 'bs': 'Bosnian',\n                  'ca': 'Catalan', 'hr': 'Croatian', 'cs': 'Czech',\n                  'da': 'Danish', 'nl': 'Dutch', 'en': 'English',\n                  'eo': 'Esperanto', 'et': 'Estonian', 'tl': 'Filipino',\n                  'fi': 'Finnish', 'fr': 'French', 'de': 'German',\n                  'el': 'Greek', 'gu': 'Gujarati', 'hi': 'Hindi',\n                  'hu': 'Hungarian', 'is': 'Icelandic', 'id': 'Indonesian',\n                  'it': 'Italian', 'ja': 'Japanese', 'jw': 'Javanese',\n                  'kn': 'Kannada', 'km': 'Khmer', 'ko': 'Korean',\n                  'la': 'Latin', 'lv': 'Latvian', 'mk': 'Macedonian',\n                  'ml': 'Malayalam', 'mr': 'Marathi',\n                  'my': 'Myanmar (Burmese)', 'ne': 'Nepali',\n                  'no': 'Norwegian', 'pl': 'Polish', 'pt': 'Portuguese',\n                  'ro': 'Romanian', 'ru': 'Russian', 'sr': 'Serbian',\n                  'si': 'Sinhala', 'sk': 'Slovak', 'es': 'Spanish',\n                  'su': 'Sundanese', 'sw': 'Swahili', 'sv': 'Swedish',\n                  'ta': 'Tamil', 'te': 'Telugu', 'th': 'Thai', 'tr': 'Turkish',\n                  'uk': 'Ukrainian', 'ur': 'Urdu', 'vi': 'Vietnamese',\n                  'cy': 'Welsh', 'zh': 'Chinese (Mandarin/China)'\n                  }\n\n\n_supported_langs = None\n\n\ndef get_supported_langs():\n    \"\"\"Get dict of supported languages.\n\n    Tries to fetch remote list, if that fails a local cache will be used.\n\n    Returns:\n        (dict): Lang code to lang name map.\n    \"\"\"\n    global _supported_langs\n    if not _supported_langs:\n        try:\n            _supported_langs = tts_langs()\n        except Exception:\n            LOG.warning('Couldn\\'t fetch upto date language codes')\n    return _supported_langs or _default_langs\n\n\nclass GoogleTTS(TTS):\n    \"\"\"Interface to google TTS.\"\"\"\n    def __init__(self, lang, config):\n        self._google_lang = None\n        super(GoogleTTS, self).__init__(lang, config, GoogleTTSValidator(\n            self), 'mp3')\n        LOG.warning(\n            \"The Google TTS module uses the gTTS Python package which itself \"\n            \"interfaces with the Google Translate text-to-speech API. This is \"\n            \"not intended for commercial or production usage. The service \"\n            \"may break at any time, and you are subject to their Terms of \"\n            \"Service that can be found at https://policies.google.com/terms\"\n        )\n\n    @property\n    def google_lang(self):\n        \"\"\"Property containing a converted language code suitable for gTTS.\"\"\"\n        supported_langs = get_supported_langs()\n        if not self._google_lang:\n            if self.lang.lower() in supported_langs:\n                self._google_lang = self.lang.lower()\n            elif self.lang[:2].lower() in supported_langs:\n                self._google_lang = self.lang[:2]\n        return self._google_lang or self.lang.lower()\n\n    def get_tts(self, sentence, wav_file):\n        \"\"\"Fetch tts audio using gTTS.\n\n        Args:\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.google_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.google_lang\n        if lang.lower() not in get_supported_langs():\n            raise ValueError(\"Language not supported by gTTS: {}\".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"}]}