0

我尝试连接到 google api 并收到此错误

requests.exceptions.ConnectionError: HTTPSConnectionPool(host='www.google.com', port=443): Max retries exceeded with url: /speech-api/v1/recognize?xjerr=1&client=chromium&lang=ru-RU (Caused by <class 'socket.error'>: [Errno 10054] An existing connection was forcibly closed by the remote host)

这是我的代码,我使用了库 urllib3,urllib2,requests 但它没有帮助

import requests

recording = 'C:/Users/sborovskiy/PycharmProjects/VoiceManager/com/work/voiceManager/output.flac'
url = 'https://www.google.com/speech-api/v1/recognize?xjerr=1&client=chromium&lang=ru-RU'
headers = {'Content-Type' : 'audio/x-flac; rate=16000', 'User-Agent': 'Netscape 6.0'}
files = {'output.flac' : open(recording, 'rb')}
response = requests.post(url = url, data = files, headers = headers)

网上没有给出具体答案

4

0 回答 0