KoljaB / RealtimeTTS

Converts text to speech in realtime
1.39k stars 119 forks source link

KeyError: 'audio' #49

Closed ajeema closed 4 months ago

ajeema commented 4 months ago

I continue to get this error and have yet to figure out why. Any ideas?

`Exception in thread Thread-2 (play): Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/threading.py", line 1038, in _bootstrap_inner self.run() File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/threading.py", line 975, in run self._target(*self._args, **self._kwargs) File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/RealtimeTTS/text_to_stream.py", line 231, in play self.engine.synthesize(self.char_iter) File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/RealtimeTTS/engines/elevenlabs_engine.py", line 121, in synthesize self.stream(self.audio_stream) File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/RealtimeTTS/engines/elevenlabs_engine.py", line 177, in stream for chunk in audio_stream: File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/elevenlabs/api/tts.py", line 134, in generate_stream_input if data["audio"]:


KeyError: 'audio'
`
KoljaB commented 4 months ago

It's a known elevenlabs issue.

Try using eleven_monolingual_v1 and eleven_multilingual_v1 models, but not the v2 models, they are not fast enough for realtime streaming. In the elevenlabs thread some other possible reasons are mentioned: missing API key, unended/timed-out input stream, account usage exceeded. Subscription to a elevenlabs paid membership also was mentioned.

ajeema commented 4 months ago

I did come across some of those, I will continue to explore. Thank you

roperi commented 3 months ago

Result of printing the data object just before it checks the audio key is present.

{'message': 'Unusual activity detected. Free Tier usage disabled. If you are using a proxy/VPN you might need to purchase a Paid Plan to not trigger our abuse detectors. Free Tier only works if users do not abuse it, for example by creating multiple free accounts. If we notice that many people try to abuse it, we will need to reconsider Free Tier altogether. \nPlease play fair and purchase any Paid Subscription to continue.', 'error': 'detected_unusual_activity', 'code': 1008}

Changing to a paid subscription made it work.