import elevenlabs
from elevenlabs.api.error import RateLimitError
elevenlabs.set_api_key("407a82347a3fb49c9c6f25c97752e706")
# List of your API keys
api_keys = ["407a82347a3fb49c9c6f25c97752e706", "api_key_two", "api_key_three", ...]
# Text for audio generation
text = "जीरोडोल-एसपी टैबलेट एक कॉम्बिनेशन वाली दवा है जिसका उपयोग मांसपेशियों में दर्द, जोड़ों के दर्द और ऑपरेशन के बाद दर्द जैसी विभिन्न स्थितियों में दर्द और सूजन को दूर करने के लिए किया जाता है ."
# Loop through API keys
for api_key in api_keys:
try:
# Set the current API key
elevenlabs.set_api_key(api_key)
# Generate audio
audio = elevenlabs.generate(text=text, voice="Adam", model='eleven_multilingual_v1')
# Save the audio to a file
audio_file_path = f"/Users/jitendersingh/Documents/elevenaudio_{api_key}.wav"
elevenlabs.save(audio, audio_file_path)
print(f"Audio generated successfully using {api_key}.")
# Exit the loop since audio was successfully generated
break
except RateLimitError:
print(f"Rate limit exceeded for {api_key}. Trying the next API key.")
# Continue to the next API key
continue
except Exception as e:
print(f"An error occurred: {e}")
# Handle other errors if needed
# If all API keys are exhausted
else:
print("Audio generation failed with all API keys.")
0 comments:
Post a Comment