#I’m working with the ElevenLabs Python SDK and have encountered an issue. I need to generate audio
1 messages · Page 1 of 1 (latest)
To use your custom cloned voice with the ElevenLabs SDK, you need to reference it by its voice ID, not by its name. The voice ID is a unique identifier for each voice in your library.
You can find the voice ID of your custom cloned voice in the "My Voices" section of the ElevenLabs website. Select the voice to open up details about it in the right-hand pane. Hovering over the 'ID' button will display the voice_id, and clicking it will copy the voice_id to your clipboard. You can then paste it into your code directly.
If you want to fetch all the voices in your library via the API, you can use the following Python code:
import requests
import json
XI_API_KEY = "<xi-api-key>"
url = "https://api.elevenlabs.io/v1/voices"
headers = {
"Accept": "application/json",
"xi-api-key": XI_API_KEY,
"Content-Type": "application/json"
}
response = requests.get(url, headers=headers)
data = response.json()
for voice in data['voices']:
print(f"{voice['name']}; {voice['voice_id']}")
This code will print out the name and voice ID of each voice in your library. Make sure to replace <xi-api-key> with your actual API key. Once you have the voice ID, you can use it in your code to generate audio with your custom cloned voice.
Okay I suycessfully uploaded my dictionary through the SDK. Now how do I apply it to a specific project?
To apply a pronunciation dictionary to a specific project, you need to use the pronunciation_dictionary_locators parameter when generating text-to-speech audio. This parameter takes a list of PronunciationDictionaryVersionLocator objects, each of which includes the pronunciation_dictionary_id and version_id of the pronunciation dictionary you want to use.
Here's an example of how to use a pronunciation dictionary when generating audio:
from elevenlabs import PronunciationDictionaryVersionLocator
audio = client.generate(
text="Your text here",
voice="Rachel",
model="eleven_turbo_v2",
pronunciation_dictionary_locators=[
PronunciationDictionaryVersionLocator(
pronunciation_dictionary_id=pronunciation_dictionary.id,
version_id=pronunciation_dictionary.version_id,
)
],
)
In this example, pronunciation_dictionary.id and pronunciation_dictionary.version_id are the ID and version ID of the pronunciation dictionary you uploaded. You should replace these with the actual ID and version ID of your pronunciation dictionary.
This will generate audio using the specified text, voice, and model, and apply the pronunciation rules from your pronunciation dictionary.
Do I need to upload the .pls file in "Edit Project Settings" too?
No, you don't need to upload the .pls file in "Edit Project Settings". Once you've uploaded your pronunciation dictionary using the SDK, you can apply it to a specific project by using the pronunciation_dictionary_locators parameter in your text-to-speech request.
Here's an example of how to do this in Python:
from elevenlabs import PronunciationDictionaryVersionLocator
# Assuming you have the pronunciation_dictionary object from the upload step
pronunciation_dictionary_id = pronunciation_dictionary.id
version_id = pronunciation_dictionary.version_id
# Generate audio with the custom pronunciation dictionary
audio = client.generate(
text="Your text here",
voice="Your Voice",
model="Your Model",
pronunciation_dictionary_locators=[
PronunciationDictionaryVersionLocator(
pronunciation_dictionary_id=pronunciation_dictionary_id,
version_id=version_id,
)
],
)
In this example, client is your ElevenLabs client instance, text is the text you want to convert to speech, voice is the voice you want to use, and model is the model you want to use. The pronunciation_dictionary_locators parameter is a list of PronunciationDictionaryVersionLocator objects, each of which specifies a pronunciation dictionary to use by its ID and version ID.
When I generate audio using my pronunciation dictionary, it is pronouncing the IPA phoneme entries literally
Mispronunciations can occur due to several reasons. One common reason is misspelling. The AI will try to read the words exactly as they are written, so it's important to ensure that the text is proofread and finished before having the AI read it.
If you want to force a certain pronunciation, you can use SSML phoneme tags with the English V1 and Turbo V2 models.
Sometimes, the AI might mispronounce words or have a strange accent that is not the one you are expecting. This can happen for a few reasons, and in most cases, it's very voice-dependent and language-dependent. The best way to ensure the correct accent and pronunciation is to clone a voice with the correct accent and pronunciation.
The language is specified by the text, and the accent is specified by the voice. So if you're writing in a language that might share a lot of common words or is fairly closely related to another language, the AI might have a hard time understanding how to pronounce certain words or switch between accents.
However, under certain circumstances, the AI might mispronounce words that are written correctly, even in English. This seems to be highly dependent on the voice used and the text used, but should be a rare occurrence.
Yes but it's not pronouncing the words according to IPA rules
To ensure that the words are pronounced according to the International Phonetic Alphabet (IPA) rules, you need to use the Speech Synthesis Markup Language (SSML) phoneme tag. You should wrap the desired word or phrase in the <phoneme alphabet="ipa" ph="your-IPA-Pronunciation-here">word</phoneme> tag. Replace "your-IPA-Pronunciation-here" with the desired IPA pronunciation.
For example, if you want to pronounce the word "actually" in a specific way, you would use:
<phoneme alphabet="ipa" ph="ˈæktʃuəli">actually</phoneme>
Please note that this feature is currently only supported by the “Eleven English V1” and “Eleven Turbo V2” models. Also, remember to include the lexical stress when writing IPA as the relative salience of each syllable is crucial for proper pronunciation and meaning distinctions.
it still is not pronouncing the IPA entries correctly
I'm sorry to hear that you're having trouble with the pronunciation of IPA entries. It's important to note that the pronunciation dictionary feature is currently only supported by the “Eleven English V1” and “Eleven Turbo V2” models.
When specifying pronunciations, you need to wrap the desired word or phrase in the <phoneme alphabet="ipa" ph="your-IPA-Pronunciation-here">word</phoneme> tag for IPA. Replace "your-IPA-Pronunciation-here" with the desired IPA pronunciation.
For example, if you want to specify the pronunciation for the word "actually", you would use:
<phoneme alphabet="ipa" ph="ˈæktʃuəli">actually</phoneme>
Also, remember that English is a lexical stress language, which means that within multi-syllable words, some syllables are emphasized more than others. The relative salience of each syllable is crucial for proper pronunciation and meaning distinctions. So, it is very important to remember to include the lexical stress when writing IPA.
If you're still having trouble, please double-check your IPA entries and ensure that they are correctly formatted and include the necessary lexical stress. If the problem persists, it may be best to reach out to ElevenLabs support for further assistance.
Who do I reach out to?