Mythic Infinity python client library.
Project description
MythicInfinity Python Client
Ultra-low latency realtime AI Text to Speech.
Sign Up for an API Key »
Read the docs
·
Report Bug
Overview
- Easy installation with pip.
- Streaming audio bytes and non-streaming both supported.
- Async/await and standard sync code both supported.
- Full IDE support with autocomplete, type-hinting, and in-code documentation.
Installation
Install the python package as a dependency of your application.
$ pip install mythicinfinity
Basic Example
from mythicinfinity import MythicInfinityClient
def main():
# Instantiate the client with your api key
client = MythicInfinityClient(api_key="YOUR_API_KEY")
# Call the TTS API. By default, stream is False.
audio_bytes = client.tts.generate(text="Hello world.")
with open('my_audio.wav', 'wb') as f:
f.write(audio_bytes)
if __name__ == "__main__":
main()
This sample calls the Text-To-Speech service and saves the resultant audio bytes to a file.
Environment Variables
| Name | Description |
|---|---|
MYTHICINFINITY_API_KEY |
Sets the api key. There is no need to pass api_key="YOUR_API_KEY" to the client constructor when using the environment variable. |
Streaming Example
from mythicinfinity import MythicInfinityClient
def main():
# Instantiate the client with your api key
client = MythicInfinityClient(api_key="YOUR_API_KEY")
# Call the TTS API with stream=True.
# This will stream the audio bytes in real-time,
# as they become available from the AI model.
audio_bytes_generator = client.tts.generate(text="Hello world.", stream=True)
with open('my_audio.wav', 'wb') as f:
for audio_bytes in audio_bytes_generator:
f.write(audio_bytes)
if __name__ == "__main__":
main()
Async Support
- Code relying on
async / awaitpatterns is fully supported.
import asyncio
from mythicinfinity import AsyncMythicInfinityClient
async def main():
# Instantiate the client with your api key
client = AsyncMythicInfinityClient(api_key="YOUR_API_KEY")
# Call the TTS API with stream=False.
audio_bytes = await client.tts.generate(text="Hello world.")
with open('my_async_audio_1.wav', 'wb') as f:
f.write(audio_bytes)
# Call the TTS API with stream=True.
# This will stream the audio bytes in real-time,
# as they become available from the AI model.
audio_bytes_generator = await client.tts.generate(text="Hello world.", stream=True)
with open('my_async_audio_2.wav', 'wb') as f:
async for audio_bytes in audio_bytes_generator:
f.write(audio_bytes)
if __name__ == "__main__":
asyncio.run(main())
This sample first calls the client.tts.generate method without streaming using await and then does the same with
streaming enabled.
Voice API
Voice Object
class Voice:
name: str
voice_id: str
model_ids: typing.List[str]
"""
Model IDs that this voice is compatible with.
"""
preview_urls_by_model_id: typing.Dict[str, str]
"""
Preview urls for this voice per model id.
"""
The voice objects returned by this api will have this structure.
List Voices
Sync
all_voices = client.tts.voices.list()
Async
all_voices = await async_client.tts.voices.list()
Get Voice Data
Sync
voice = client.tts.voices.get("kiera")
Async
voice = await async_client.tts.voices.get("kiera")
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file mythicinfinity-0.1.5.tar.gz.
File metadata
- Download URL: mythicinfinity-0.1.5.tar.gz
- Upload date:
- Size: 24.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e00624cbf80e523fc7e2dc3b244d09e7c5da2a9cf261aa5cd41430472d25a26e
|
|
| MD5 |
c53be0d679d0a764d9147b8d010c1eb9
|
|
| BLAKE2b-256 |
74502d4fd55d016df2ca6632d0ee686ea49007b71cd3a0385e869f69f9d731a2
|
Provenance
The following attestation bundles were made for mythicinfinity-0.1.5.tar.gz:
Publisher:
release.yml on MythicInfinity/mythicinfinity-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mythicinfinity-0.1.5.tar.gz -
Subject digest:
e00624cbf80e523fc7e2dc3b244d09e7c5da2a9cf261aa5cd41430472d25a26e - Sigstore transparency entry: 237539911
- Sigstore integration time:
-
Permalink:
MythicInfinity/mythicinfinity-python@27623746c86a8d32bebcd0b5daef2143838410fb -
Branch / Tag:
refs/tags/v0.1.5 - Owner: https://github.com/MythicInfinity
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@27623746c86a8d32bebcd0b5daef2143838410fb -
Trigger Event:
push
-
Statement type: