adrianlyjak / obsidian-aloud-tts

MIT License
12 stars 1 forks source link

Not working on OSX #26

Closed razeghi71 closed 3 weeks ago

razeghi71 commented 1 month ago

Hi, the plugin doesn't work for mac with this error in console:

app.js:1 Uncaught (in promise) Error: Request failed, status 429
    at new t (app.js:1:1977769)
    at qG (app.js:1:1977961)
    at app.js:1:1978638
    at app.js:1:237056
    at Object.next (app.js:1:237161)
    at a (app.js:1:235879)

I have the latest version (0.2.0) and obsidian version 1.5.12

Let me know if you need any additional info.

adrianlyjak commented 1 month ago

@razeghi71 that appears like you're getting a 429 request from openAI, which is a rate limit error code.

Does the plugin ever work? Or do you immediately get the error. I would think either that A. something else is using the API key, exceeding your usage limits, B. or there's a bug in the plugin causing excessive requests

Are you using the api key for anything else that might be using up your limits? If you navigate to the network tab, do you see many requests to openai? Are some of them successes? (200 error response, or are they all 429?)

razeghi71 commented 1 month ago

I get this error when I click on the side button at the left, and there is no request actualy being sent at all, the network page shows nothing which returns 429, here are everything:

Screenshot 2024-04-17 at 12 37 43

adrianlyjak commented 1 month ago

This issue looks related: https://github.com/nhaouari/obsidian-textgenerator-plugin/issues/143. Unfortunately, OpenAI recently changed their billing such that you need to buy credits ahead of tiem for personal / low usage account, so I wouldn't be surprised if that's the issue.

Either way, It looks like the error handling in the plugin here is not working well. I'll look into bubbling up the error to the UI and giving more informative text. This seems like a common scenario that lots of other users will run into.

In the meantime, I don't know how technical you are, but you could attempt to confirm this by making a request with curl separate from the plugin to confirm (replacing <YOUR_OPENAI_API_KEY>)

cd ~/Desktop; curl -s https://api.openai.com/v1/audio/speech \
  -H "Authorization: Bearer <YOUR_OPENAI_AP_ KEY>" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "tts-1",
    "input": "this is a test",
    "voice": "shimmer",
    "speed": 1
  }' \
  --output test.mp3

If it worked, the test.mp3 file on your desktop should be playable. If not, and you open the file in a text editor or on the command line with less ~/Desktop/test.mp3, it should instead be a text error message that hopefully gives more detail

razeghi71 commented 1 month ago

Thanks for looking into this @adrianlyjak, yeah so it seems that this was related to the fact that OpenAI migrated from Personal API Keys to Project API Keys, so I've created a new project and there got an API Key and it worked! Should I close this now? or you want it to be open for future reference on error handling features you mentioned?

adrianlyjak commented 4 weeks ago

@razeghi71 glad to hear you figured it out! I'll keep this open. It looks like I created some regressions in the error reporting with the latest release

adrianlyjak commented 3 weeks ago

Error messaging issues fixed in https://github.com/adrianlyjak/obsidian-aloud-tts/pull/30, released in 0.2.1