Skip to content
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

ExOpenAI.Audio.create_speech tries to parse response as JSON when it is the raw MP3 string #19

Closed
hawkyre opened this issue Feb 10, 2024 · 3 comments · Fixed by #20
Closed

Comments

@hawkyre
Copy link

hawkyre commented Feb 10, 2024

I'm getting this error because the library is trying to parse the response as a JSON when it's just the raw binary in string format.

Here's the error:

no case clause matching: {:ok, %HTTPoison.Response{status_code: 200, body: {:error, %Jason.DecodeError{position: 0, token: nil, data: <<255, 243, 228, 196, 0, 91, 100, 57, 232, 21, 90, 192, 0, 105, 255, 83, 205, 128, 236, 76, 55, 204, 13, 17, 96, 49, 6, 244, 26, 36, 206, 179, 57, 51, 79, 183, 35, 229, 184, 243, 94, ...>>}}, headers: [{"Date", "Sat, 10 Feb 2024 16:37:49 GMT"}, {"Content-Type", "audio/mpeg"}, {"Transfer-Encoding", "chunked"}, {"Connection", "keep-alive"}, {"openai-organization", "user-wrp869fi21tfiba2c6pbgtzk"}, {"openai-processing-ms", "360"}, {"openai-version", "2020-10-01"}, {"strict-transport-security", "max-age=15724800; includeSubDomains"}, {"x-ratelimit-limit-requests", "100"}, {"x-ratelimit-remaining-requests", "99"}, {"x-ratelimit-reset-requests", "600ms"}, {"x-request-id", "req_2bea2f766ab224baaabfd670b08a848b"}, {"CF-Cache-Status", "DYNAMIC"}, {"Set-Cookie", "__cf_bm=c8hZghGTexxu3aBBeC3VLcn.WvGjFtOuXf6vVL41cxk-1707583069-1-AZXuK2wvaT6R5ez3gM6UNEZSOsLc0eET5P7hCfrwGz7y0mzBishNY9UV9vRFJSQUDfd4HEG+MzeEszFDo28H9k0=; path=/; expires=Sat, 10-Feb-24 17:07:49 GMT; domain=.api.openai.com; HttpOnly; Secure; SameSite=None"}, {"Set-Cookie", "_cfuvid=DVhy6UAnPoUha56tErBCRatIWg8.QnVt37EerIA6yh8-1707583069884-0-604800000; path=/; domain=.api.openai.com; HttpOnly; Secure; SameSite=None"}, {"Server", "cloudflare"}, {"CF-RAY", "8535c7652fa38680-MAD"}, {"alt-svc", "h3=\":443\"; ma=86400"}], request_url: "https://api.openai.com/v1/audio/speech?", request: %HTTPoison.Request{method: :post, url: "https://api.openai.com/v1/audio/speech?", headers: [{"Authorization", "Bearer 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"}, {"Content-type", "application/json"}], body: "{\"input\":\"weekend\",\"voice\":\"alloy\",\"model\":\"tts-1\"}", params: %{}, options: [recv_timeout: 50000, stream_to: nil]}}}
    (ex_openai 1.5.0) lib/ex_openai/client.ex:11: ExOpenAI.Client.handle_response/1
    (ex_openai 1.5.0) lib/ex_openai/client.ex:126: ExOpenAI.Client.api_post/4
@dvcrn
Copy link
Owner

dvcrn commented Feb 11, 2024

There’s a open PR for this, but couldn’t merge it yet because CI breaks - #18
Let me see if I can get it done this weekend!

@dvcrn
Copy link
Owner

dvcrn commented Feb 17, 2024

Could you give this branch a go? #20

@dvcrn dvcrn closed this as completed in #20 Apr 2, 2024
@dvcrn
Copy link
Owner

dvcrn commented Apr 2, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants