Instant Voice Clone (Python SDK)

View as Markdown

Create an instant voice clone by uploading a short audio sample (5-15 seconds) via the Python SDK.

You can access the source code for the Python SDK on our GitHub repository.

Requirements

Before you begin, ensure you have the following:

  • Python (3.9 or higher) installed on your machine.
  • An API key from the Smallest AI platform.

Setup

Install our SDK

$pip install smallestai

Set your API key as an environment variable.

$export SMALLEST_API_KEY=YOUR_API_KEY

Add your Voice

The Smallest AI SDK allows you to clone your voice by uploading an audio file. This feature is available both synchronously and asynchronously, making it flexible for different use cases. Below are examples of how to use this functionality.

Synchronously

python
1from smallestai.waves import WavesClient
2
3def main():
4 client = WavesClient(api_key="YOUR_API_KEY")
5 res = client.add_voice(display_name="My Voice", file_path="my_voice.wav")
6 print(res)
7
8if __name__ == "__main__":
9 main()

Asynchronously

python
1import asyncio
2from smallestai.waves import AsyncWavesClient
3
4async def main():
5 client = AsyncWavesClient(api_key="YOUR_API_KEY")
6 res = await client.add_voice(display_name="My Voice", file_path="my_voice.wav")
7 print(res)
8
9if __name__ == "__main__":
10 asyncio.run(main())

Parameters

  • api_key: Your API key (can be set via SMALLEST_API_KEY environment variable).
  • display_name: Name of the voice to be created.
  • file_path: Path to the audio file to be cloned.

These parameters are part of the add_voice function. They can be set when calling the function as shown above.

Get All Cloned Voices

Once you have cloned your voices, you can retrieve a list of all cloned voices associated with your account using the following code:

python
1from smallestai.waves import WavesClient
2
3client = WavesClient(api_key="YOUR_API_KEY")
4print(f"Available Voices: {client.get_cloned_voices()}")

If you have any questions or run into any issues, our community is here to help!