-
Notifications
You must be signed in to change notification settings - Fork 3.8k
[Audio.transcribe] JsonDecodeError when printing vtt from m4a #243
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Also happens with srt
|
And for text:
|
Seems similar to #216 |
thanks for reporting @sheikheddy - we seem to have missed this. please tag me if you do end up putting a pr up! |
Background
DiscussionFundamentally, the problem here is that we're violating the assumption that the request always returns a JSON encoded response. My proposal is to prepare requests to Whisper such that they always return serialized JSON, and if the user wants a vtt or srt file, we do the conversion on the client inside audio.py. Concretely, a call to EvaluationLet's consider our options and tradeoffs in terms of the user experience, product roadmap, and technical architecture. In some cases, it may be more beneficial to perform formatting on the client-side, especially when there are multiple clients consuming the same API resource, but each client requires a different data format. For instance, if Alice and Bob request a transcription of an identical audio file, Alice may require the transcription in vtt format, while Bob may need it in srt format. It is more efficient to store a single compact idempotent representation instead of multiple representations. When sending text over the wire, using a binary format that is deserialized into JSON on the client can be more efficient compared to the wasteful I/O overhead of sending the text directly. In the future, as we support passing URLs to remote files, we may see a pattern of a few popular, large-size tracks being transcribed frequently, while the majority of requests will be for smaller one-off transcriptions. It's worth noting that we can cache the result of the first request and serve it from the cache on the second request. Cache management is more complex in practice, but let's keep it simple for now. Biggest drawback I can see is that converting large files might be slow, especially on older hardware, and we should be careful to control the footprint of client workloads. AlternativesOne potential fix may be to check and enforce the If nobody suggests something more clever/elegant/scalable, I'll just implement the best I can come up with right now and get that reviewed. |
Anybody can fix this problem quickly,i do need it 😢 |
I try to fix it and create a PR |
this is my PR:#277 |
Still fails in precisely the same way :/ |
OK i'll check it ASAP |
could you tell me how do you test it?i don't know how to test it locally |
I am on Windows with Python 3.10. Can I find you in a discord or telegram channel? |
+86 13048282493 telegram |
I checked and the Content-Type header on the response is always set correctly (at least for the audio transcription responses), so we can deduce whether to json-decode within For the if rheaders.get('Content-Type') == 'application/json':
data = json.loads(rbody)
else:
data = rbody Alternatively if we want to be more conservative in case responses from other parts of the API might not have the if 'text/plain' in rheaders.get('Content-Type'):
data = rbody
else:
data = json.loads(rbody) |
what is your handle on telegram? the number is not working |
@MattFisher please review it in #282, i don't know how to close it in same PR 😭 |
if you need assistance reproducing the error or details, I made this TG channel for us.. https://t.me/guagua_mfisher |
I'm in |
|
Just made you an admin @guaguaguaxia |
Describe the bug
This section of the codebase expects json even when the response_format is not json:
https://github.com/openai/openai-python/blob/75c90a71e88e4194ce22c71edeb3d2dee7f6ac93/openai/api_requestor.py#L668C7-L673
I think I can contribute a quick bug fix PR today!
To Reproduce
Stack:
JSONDecodeError Traceback (most recent call last)
File ~\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\openai\api_requestor.py:669, in APIRequestor._interpret_response_line(self, rbody, rcode, rheaders, stream)
668 try:
--> 669 data = json.loads(rbody)
670 except (JSONDecodeError, UnicodeDecodeError) as e:
Code snippets
OS
Windows 11
Python version
Python v3.10.10
Library version
openai-python 0.27.0
The text was updated successfully, but these errors were encountered: