我在Ubuntu 23.10 64位上运行Python 3.11.6和deepgram API 2.12.0。
我有这个项目的venv设置。我相信这是某种环境问题,但我已经更新了所有的软件包到当前版本。任何帮助是非常感谢!!
下面是我的代码:
from deepgram import Deepgram
import json
DEEPGRAM_API_KEY = 'XXXXX'
PATH_TO_FILE = '/home/dave/Downloads/harvard.wav'
MIMETYPE = 'audio/wav'
def main():
dg_client = Deepgram(DEEPGRAM_API_KEY)
with open(PATH_TO_FILE, 'rb') as audio:
source = {'buffer': audio, 'mimetype': MIMETYPE}
options = {"smart_format": False, "model": "nova", "language": "en-GB"}
print('Requesting transcript... for ', PATH_TO_FILE)
response = dg_client.transcription.sync_prerecorded(source, options)
print(json.dumps(response, indent=4))
main()
字符串
堆栈跟踪:
Traceback (most recent call last):
File "/usr/lib/python3.11/urllib/request.py", line 1348, in do_open
h.request(req.get_method(), req.selector, req.data, headers,
File "/usr/lib/python3.11/http/client.py", line 1286, in request
self._send_request(method, url, body, headers, encode_chunked)
File "/usr/lib/python3.11/http/client.py", line 1332, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "/usr/lib/python3.11/http/client.py", line 1281, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "/usr/lib/python3.11/http/client.py", line 1080, in _send_output
self.send(chunk)
File "/usr/lib/python3.11/http/client.py", line 1002, in send
self.sock.sendall(data)
File "/usr/lib/python3.11/ssl.py", line 1274, in sendall
v = self.send(byte_view[count:])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/ssl.py", line 1243, in send
return self._sslobj.write(data)
^^^^^^^^^^^^^^^^^^^^^^^^
ssl.SSLEOFError: EOF occurred in violation of protocol (_ssl.c:2427)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/dave/Dropbox/Code/LLM/venv/lib/python3.11/site-packages/deepgram/_utils.py", line 203, in _sync_request
return attempt()
^^^^^^^^^
File "/home/dave/Dropbox/Code/LLM/venv/lib/python3.11/site-packages/deepgram/_utils.py", line 177, in attempt
with urllib.request.urlopen(req, timeout=timeout) as resp:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/urllib/request.py", line 216, in urlopen
return opener.open(url, data, timeout)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/urllib/request.py", line 519, in open
response = self._open(req, data)
^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/urllib/request.py", line 536, in _open
result = self._call_chain(self.handle_open, protocol, protocol +
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/urllib/request.py", line 496, in _call_chain
result = func(*args)
^^^^^^^^^^^
File "/usr/lib/python3.11/urllib/request.py", line 1391, in https_open
return self.do_open(http.client.HTTPSConnection, req,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/urllib/request.py", line 1351, in do_open
raise URLError(err)
urllib.error.URLError: <urlopen error EOF occurred in violation of protocol (_ssl.c:2427)>
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/dave/Dropbox/Code/LLM/Media-Ingest/test.py", line 26, in <module>
main()
File "/home/dave/Dropbox/Code/LLM/Media-Ingest/test.py", line 22, in main
response = dg_client.transcription.sync_prerecorded(source, options)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/dave/Dropbox/Code/LLM/venv/lib/python3.11/site-packages/deepgram/transcription.py", line 378, in sync_prerecorded
return SyncPrerecordedTranscription(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/dave/Dropbox/Code/LLM/venv/lib/python3.11/site-packages/deepgram/transcription.py", line 121, in __call__
return _sync_request(
^^^^^^^^^^^^^^
File "/home/dave/Dropbox/Code/LLM/venv/lib/python3.11/site-packages/deepgram/_utils.py", line 209, in _sync_request
raise DeepgramApiError(exc, http_library_error=exc) from exc
deepgram.errors.DeepgramApiError: <urlopen error EOF occurred in violation of protocol (_ssl.c:2427)>
Process finished with exit code 1
型
我更新了venv中的所有软件包,并与某人验证了代码是正确的。
1条答案
按热度按时间ct2axkht1#
我有同样的问题,更换了API键与一个新的,它再次工作。
我假设这个错误意味着你的API密钥不再有效,你需要替换它。