Skip to main content

Gladia SDK for Python

Project description

Gladia Python SDK

A Python SDK for the Gladia API.

Requirements

You need Python 3.10+ for this package.
It may work on lower versions but they are not supported / tested.

Installation

Using pip

pip install gladiaio-sdk

Using uv

uv add gladiaio-sdk

Usage

To use the SDK, import GladiaClient and create a new instance of it.

You can also configure api_key, api_url and region through their respective environment variables: GLADIA_API_KEY, GLADIA_API_URL and GLADIA_REGION.

from gladiaio_sdk import GladiaClient

gladia_client = GladiaClient(
  api_key="your_api_key"
)

Live V2

Threaded vs Async

Our Python SDK supports sync/threaded and asyncio versions.
To get the sync/threaded version, do:

live_client = gladia_client.live_v2()

And to get the async version:

live_client = gladia_client.live_v2_async()

Usage

Once you decided between sync and async client, you can use the client to run a Live session:

# Create session
live_session = live_client.start_session(
  LiveV2InitRequest(
    language_config=LiveV2LanguageConfig(
      languages=["en"],
    ),
    messages_config=LiveV2MessagesConfig(
      receive_partial_transcripts=True,
    ),
  )
)


# Add listeners
@live_session.on("message")
def on_message(message: LiveV2WebSocketMessage):
  if message.type == "transcript":
    print(f"{'F' if message.data.is_final else 'P'} | {message.data.utterance.text.strip()}")


@live_session.once("started")
def on_started(response: LiveV2InitResponse):
  print(f"Session {response.id} started")


@live_session.on("error")
def on_error(error: Exception):
  print(f"An error occurred during live session: {error}")


@live_session.once("ended")
def on_ended(ended: LiveV2EndedMessage):
  print(f"Session {live_session.session_id} ended")


# Send audio
live_session.send_audio(audio_bytes)
# ...
live_session.send_audio(audio_bytes)

# Stop the recording when all audio have been sent.
# Remaining audio will be processed and after post-processing,
# the session is ended.
live_session.stop_recording()

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

gladiaio_sdk-1.0.0.tar.gz (53.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gladiaio_sdk-1.0.0-py3-none-any.whl (46.4 kB view details)

Uploaded Python 3

File details

Details for the file gladiaio_sdk-1.0.0.tar.gz.

File metadata

  • Download URL: gladiaio_sdk-1.0.0.tar.gz
  • Upload date:
  • Size: 53.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.1 {"installer":{"name":"uv","version":"0.11.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for gladiaio_sdk-1.0.0.tar.gz
Algorithm Hash digest
SHA256 4cf2fcde336811f13a3f949aa61b155fef420dedc77c9a410067075c28976a62
MD5 ae0e891b6d0fedf17cd956c50ebb681b
BLAKE2b-256 90f60634581406f76fc15cc808cf9e1d1b293c3d2cf85b9e87f1c8441030cae4

See more details on using hashes here.

File details

Details for the file gladiaio_sdk-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: gladiaio_sdk-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 46.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.1 {"installer":{"name":"uv","version":"0.11.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for gladiaio_sdk-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8441d543d81397bc168c8ca823e880692040f2376be2aa1ba422856c750d31be
MD5 6cb21ed91bd2ab61145ed88737cb988b
BLAKE2b-256 96188a53951c004bd61e91111d28120cbea687f679789fbc0cc45da1acec850e

See more details on using hashes here.

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