Open tonyphoang opened 2 months ago
Hi, I'm trying to use the python API call to input more than 5000 characters. I keep getting an error. Is there a way to do it? Would I need to run multiple inferences and stitch them together?
My code is
def save_to_mp3(input_text, output_path): CHUNK_SIZE = 1024 XI_API_KEY = "my_api_key" VOICE_ID = "my_voice_id" TEXT_TO_SPEAK = f"{input_text}" OUTPUT_PATH = f"{output_path}.mp3" tts_url = f"https://api.elevenlabs.io/v1/text-to-speech/{VOICE_ID}/stream" headers = { "Accept": "application/json", "xi-api-key": XI_API_KEY, "Content-Type": "application/json" } data = { "text": TEXT_TO_SPEAK, "model_id": "eleven_turbo_v2", "voice_settings": { "stability": 0.5, "similarity_boost": 0.75, } } response = requests.post(tts_url, json=data, headers=headers, stream=True) with open(OUTPUT_PATH, 'wb') as f: for chunk in response.iter_content(chunk_size=CHUNK_SIZE): if chunk: f.write(chunk)
Hi, I'm trying to use the python API call to input more than 5000 characters. I keep getting an error. Is there a way to do it? Would I need to run multiple inferences and stitch them together?
My code is