Skip to main content

Python client for the Sonantic API

Project description

Sonantic Python Library

CI

Interact with the Sonantic API from Python.

Installation

You can install sonantic from PyPI

pip install sonantic

Example

You will need to set your API key which can be found in your Sonantic Dashboard

import sonantic
from sonantic.core import Error

# make sure to set the API key before you call any methods
sonantic.api_key = "live_c..."

# list available voices
voices = sonantic.voices.list()


print("Available voices")
for voice in voices.items:
    print(f"\t{voice.name}")

print()
print("Creating speech...")

speech = sonantic.speech.create(
    voice="taylor", text="The quick brown fox jumps over the lazy dog."
)

# check the request was successful and handle the error otherwise
if isinstance(speech, Speech):
    path = f"./{speech.id}.wav"
    print(f"Saving audio to file {path}")
    # store generated speech - the audio is decoded by default
    with open(path, "bx") as f:
        f.write(speech.audio.content)
else:
    # handle the error
    print(speech.error)
    print(speech.message)

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

sonantic-0.1.0.tar.gz (6.4 kB view hashes)

Uploaded Source

Built Distribution

sonantic-0.1.0-py3-none-any.whl (7.0 kB view hashes)

Uploaded Python 3

Supported by

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