How native language prompting works
By default, the model looks at your text and guesses the native language for your generated speech. But you can explicitly prompt the model for more control.
This shapes the accent and how the model handles foreign words.
from lmnt import Lmnt
client = Lmnt()
text = 'Hello, welcome to the show.'
for language in ['en', 'fr', 'ja']:
with client.speech.with_streaming_response.generate(
text=text,
voice='leah',
language=language,
) as response:
response.stream_to_file(f'{language}.mp3')The output:
en.mp3→ spoken by a native English speaker.fr.mp3→ spoken in English with a French accent.ja.mp3→ spoken in English with a Japanese accent.
Code switching
Code switching is mixing text from two or more of the model's supported languages into the same text prompt, and is fully supported.
from lmnt import Lmnt
client = Lmnt()
text = 'Bonjour! Did you know that mariposa means butterfly in Spanish?'
for language in ['en', 'fr', 'es']:
with client.speech.with_streaming_response.generate(
text=text,
voice='leah',
language=language,
) as response:
response.stream_to_file(f'{language}.mp3')The output:
en.mp3→ English speaker —Bonjourandmariposasound foreign.fr.mp3→ French speaker —butterflyandmariposasound foreign.es.mp3→ Spanish speaker —Bonjourandbutterflysound foreign.
Use native scripts
Our models have been trained on native scripts for all supported languages.
For languages with non-Latin scripts, write your text in the language's native script. Romanized or transliterated text may not always be pronounced as you'd expect.
Supported languages
| Language | Code |
|---|---|
| Arabic | ar |
| Chinese | zh |
| Dutch | nl |
| English | en |
| French | fr |
| German | de |
| Hindi | hi |
| Indonesian | id |
| Italian | it |
| Japanese | ja |
| Korean | ko |
| Polish | pl |
| Portuguese | pt |
| Russian | ru |
| Spanish | es |
| Swedish | sv |
| Thai | th |
| Turkish | tr |
| Ukrainian | uk |
| Urdu | ur |
| Vietnamese | vi |