elevenlabs / elevenlabs-python

The official Python API for ElevenLabs Text to Speech.
https://elevenlabs.io/docs/api-reference/getting-started
MIT License
2.08k stars 237 forks source link

Unable to use voice_id #293

Open veeragoni opened 3 months ago

veeragoni commented 3 months ago

I am using a voice_id from the library in python SDK, but I get an error saying

status_code: 400, body: {'detail': {'status': 'voice_does_not_exist', 'message': 'A voice with voice_id TqZ039H4XqpiGTowubpy does not exist.'}}

Here is the code. I can pass a voice name (not the name it has though. a different one, ex: Chris). Are VoiceLab voices are not available via Python SDK? I am assuming they will be available via REST API.

    voice_client = ElevenLabs()
    audio_stream = voice_client.generate(
        text=msg.content,
        voice="TqZ039H4XqpiGTowubpy",
        model="eleven_multilingual_v2",
        stream=True)
veeragoni commented 3 months ago

I even tried following. same issue


    """
    Converts text to speech and returns the audio data as a byte stream.

    This function invokes a text-to-speech conversion API with specified parameters, including
    voice ID and various voice settings, to generate speech from the provided text. Instead of
    saving the output to a file, it streams the audio data into a BytesIO object.

    Args:
        text (str): The text content to be converted into speech.

    Returns:
        IO[bytes]: A BytesIO stream containing the audio data.
    """
    # Perform the text-to-speech conversion
    response = client.text_to_speech.convert(
        voice_id=voice_id,  # Adam pre-made voice
        optimize_streaming_latency="0",
        output_format="mp3_22050_32",
        text=text,
        model_id="eleven_multilingual_v2",
        voice_settings=VoiceSettings(
            stability=0.0,
            similarity_boost=1.0,
            style=0.0,
            use_speaker_boost=True,
        ),
    )

    print("Streaming audio data...")

    # Create a BytesIO object to hold audio data
    audio_stream = BytesIO()

    # Write each chunk of audio data to the stream
    for chunk in response:
        if chunk:
            audio_stream.write(chunk)

    # Reset stream position to the beginning
    audio_stream.seek(0)

    # Return the stream for further use
    return audio_stream```
dsinghvi commented 3 months ago

Hey @veeragoni -- do you mind trying the same code snippets but with passing in an api key?

veeragoni commented 3 months ago

I actually have the api key coming from environment variables.

this call works fine. its jus that voice_id doesn't work.

    audio_stream = voice_client.generate(
        text=msg.content,
        # voice="TqZ039H4XqpiGTowubpy",
        voice = "Chris",
        model="eleven_multilingual_v2",
        stream=True)
dsinghvi commented 3 months ago

@veeragoni that's interesting, we haven't been able to create a successful reproduction. Would you be up to grab 15 minutes with me to help get to the bottom of this?

veeragoni commented 3 months ago

Sure. Meantime can you try on a free account vs. paid. That could be it too? I will grab time anyways.

mhussar commented 3 months ago

was this ever resolved? I'm been having the same issue. it looks like you can't use custom voice lab voices. doesn't recognize the voice id

dsinghvi commented 2 months ago

@mhussar do you have a reproduction of the issue? we weren't able to reproduce it with @veeragoni

rawadtraboulsi commented 2 months ago

@dsinghvi we are having the same issue and we are able to reproduce