使用ElevenLabs API生成长文本语音时频繁出现401未授权错误求助
ElevenLabs API长文本语音合成报错问题
我在测试ElevenLabs的API时,发现生成较长文本(超过几个单词)的语音时,仅偶尔能成功,大多数情况下会返回以下错误:
Error: 401 Client Error: Unauthorized for url:
https://api.elevenlabs.io/v1/text-to-speech/h1YH6feHIpk966qs5vt1/stream
我猜测这可能与某种按时间或字符计算的限制有关,ElevenLabs官网提到有2500字符的限制,但我在API文档中未找到相关说明,请问有相关经验的人能解答吗?
我的代码如下:
from elevenlabslib import * import os def get_path(): return input('Path: ') user = ElevenLabsUser('<API_KEY>') voice = user.get_voices_by_name('Adam')[0] text = 'In botany, a tree is a perennial plant with an elongated stem, or trunk, usually supporting branches and leaves. In some usages, the definition of a tree may be narrower, including only woody plants with secondary growth, plants that are usable as lumber or plants above a specified height. In wider definitions, the taller palms, tree ferns, bananas, and bamboos are also trees.' path = get_path() while not os.path.exists(path): print('Path does not exist') path = get_path() path.replace('\\', '/') if path[-1] != '/': path += '/' name = input('File name: ') if name[-4:] != '.mp3': name += '.mp3' with open(path + name, 'wb') as f: f.write(voice.generate_audio_bytes(text)) f.close()
内容的提问来源于stack exchange,提问作者bob0815
相关产品推荐
相关产品推荐

