Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Over 5000 character audio file #329

Open
tonyphoang opened this issue Jul 24, 2024 · 0 comments
Open

Over 5000 character audio file #329

tonyphoang opened this issue Jul 24, 2024 · 0 comments

Comments

@tonyphoang
Copy link

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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant