Prerequisites
- An LMNT account
- An API key
Call the API
- Set your API key
Get your API key from the Playground and set it as an environment variable:
export LMNT_API_KEY=your-api-keyTo persist the key across shell sessions, add the line to your shell profile (such as
~/.zshrcor~/.bashrc). - Install the SDK
pip install lmnt - Write your code
Save this as
quickstart.py:from lmnt import Lmnt client = Lmnt() text = ( 'The lazy yellow dog was caught by the slow red fox ' 'as he lay sleeping in the sun.' ) with client.speech.with_streaming_response.generate( text=text, voice='leah', ) as response: response.stream_to_file('story.mp3') - Run your code
python quickstart.pyExample outputwrote ~32 KB to story.mp3
Next steps
You've made your first API call. Next, learn the Speech API patterns you'll use in every LMNT integration.
Working with the Speech API
Learn how to get word timestamps if you want them, generating conversational speech, and other core patterns.
Once you're comfortable with the basics, explore further: