Привет. Я собираю данные с веб-сайта и преобразую текст в mp3, но каждый раз, когда он выдает мне эту ошибку:
Traceback (most recent call last):
File "/home/awais/.local/lib/python2.7/site-packages/flask/app.py", line 2447, in wsgi_app
response = self.full_dispatch_request()
File "/home/awais/.local/lib/python2.7/site-packages/flask/app.py", line 1952, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/home/awais/.local/lib/python2.7/site-packages/flask/app.py", line 1821, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/home/awais/.local/lib/python2.7/site-packages/flask/app.py", line 1950, in full_dispatch_request
rv = self.dispatch_request()
File "/home/awais/.local/lib/python2.7/site-packages/flask/app.py", line 1936, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/home/awais/Desktop/sipgateio-incomingcall-python-master/incoming_call/__main__.py", line 93, in handle_on_dtmf
ttmp3.save("bbc.mp3")
File "/home/awais/.local/lib/python2.7/site-packages/gtts/tts.py", line 295, in save
self.write_to_fp(f)
File "/home/awais/.local/lib/python2.7/site-packages/gtts/tts.py", line 272, in write_to_fp
raise gTTSError(tts=self)
gTTSError: Failed to connect. Probable cause: Host 'https://translate.google.en/' is not reachable
Вот как выглядит мой код:
URL = requests.get("https://www.bbc.co.uk/news")
soup = BeautifulSoup(URL.text, 'html.parser')
headlines = soup.select(".gs-c-promo-heading__title")
all = ""
for h in headlines:
h=h.text
h = h.encode('ascii', 'ignore').decode('ascii')
all = str(all) + " " + str(h)
print(all)
ttmp3 = gTTS(all, "en")
ttmp3.save("bbc.mp3")
Я застрял здесь в течение последнего 1 дня, пожалуйста, помогите мне