Skip to main content

Mythic Infinity python client library.

Project description

Logo

MythicInfinity Python Client

pypi version supported python versions license

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.

Installation

Install the python package as a dependency of your application.

$ pip install mythicinfinity

Basic Examples

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.

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 / await patterns 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.

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

mythicinfinity-0.1.2.tar.gz (23.1 kB view details)

Uploaded Source

File details

Details for the file mythicinfinity-0.1.2.tar.gz.

File metadata

  • Download URL: mythicinfinity-0.1.2.tar.gz
  • Upload date:
  • Size: 23.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for mythicinfinity-0.1.2.tar.gz
Algorithm Hash digest
SHA256 9f98caa9045b7571f06e7482eeec5eff30fb82846234c98978566da2e8b5baf6
MD5 508d111e85e98c3bf2cc81c553d81405
BLAKE2b-256 f40165d5c41a558904a1b4f9bb21ea4c061cffad044a27cca9b64461167dcc34

See more details on using hashes here.

Provenance

The following attestation bundles were made for mythicinfinity-0.1.2.tar.gz:

Publisher: release.yml on MythicInfinity/mythicinfinity-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page