Skip to main content

The official Python SDK for SpeechCortex ASR platform.

Project description

SpeechCortex Python SDK

CI PyPI version Python Versions License: MIT Code style: black

Official Python SDK for SpeechCortex ASR (Automatic Speech Recognition) platform.

Features

  • Real-time Speech Recognition: WebSocket-based streaming ASR
  • Pre-recorded Transcription: REST API for batch processing (coming soon)
  • Easy Integration: Simple, intuitive API
  • Async Support: Full async/await support for modern Python applications

Requirements

  • Python 3.10 or higher

Installation

pip install "git+https://github.com/speechcortex/speechcortex-sdk.git@package_init"
export SPEECHCORTEX_API_KEY=your_api_key_here
export SPEECHCORTEX_HOST=wss://api.speechcortex.com

Quick Start

Real-time Transcription

from speechcortex import SpeechCortexClient, LiveTranscriptionEvents, LiveOptions

# Initialize the client
speechcortex = SpeechCortexClient(api_key="your_api_key_here")

# Get WebSocket connection
connection = speechcortex.listen.websocket.v("1")

# Set up event handlers
def on_message(self, result, **kwargs):
    sentence = result.channel.alternatives[0].transcript
    if result.is_final:
        print(f"Final: {sentence}")
    else:
        print(f"Interim: {sentence}")

def on_error(self, error, **kwargs):
    print(f"Error: {error}")

# Register event handlers
connection.on(LiveTranscriptionEvents.Transcript, on_message)
connection.on(LiveTranscriptionEvents.Error, on_error)

# Configure options
options = LiveOptions(
    model="zeus-v1",
    language="en-US",
    smart_format=True,
)

# Start the connection
connection.start(options)

# Send audio data
connection.send(audio_data)

# Close when done
connection.finish()

Using with Microphone

from speechcortex import SpeechCortexClient, LiveTranscriptionEvents, LiveOptions, Microphone

speechcortex = SpeechCortexClient()
connection = speechcortex.listen.websocket.v("1")

# Set up event handlers...
connection.on(LiveTranscriptionEvents.Transcript, on_message)

# Start connection
options = LiveOptions(model="zeus-v1", smart_format=True)
connection.start(options)

# Use microphone helper
microphone = Microphone(connection.send)
microphone.start()

# Microphone will stream audio automatically
# Press Ctrl+C to stop

microphone.finish()
connection.finish()

Configuration

API Key

Set your API key via environment variable:

export SPEECHCORTEX_API_KEY=your_api_key_here

Or pass it directly:

speechcortex = SpeechCortexClient(api_key="your_api_key_here")

Custom Endpoints

from speechcortex import SpeechCortexClient, SpeechCortexClientOptions

config = SpeechCortexClientOptions(
    api_key="your_api_key",
    url="https://custom-api.speechcortex.com"
)
speechcortex = SpeechCortexClient(config=config)

Features

Real-time Transcription Options

  • model: ASR model to use (e.g., "zeus-v1")
  • language: Language code (e.g., "en-US")
  • smart_format: Enable smart formatting
  • punctuate: Enable punctuation
  • interim_results: Receive interim results
  • utterance_end_ms: Utterance end timeout in milliseconds
  • vad_events: Enable voice activity detection events

Events

  • Open: Connection opened
  • Transcript: Transcription result received
  • Metadata: Metadata received
  • SpeechStarted: Speech detected
  • UtteranceEnd: End of utterance detected
  • Close: Connection closed
  • Error: Error occurred
  • Unhandled: Unhandled message received

Development

Setup Development Environment

# Clone the repository
git clone https://github.com/speechcortex/speechcortex-sdk.git
cd speechcortex-sdk

# Install dependencies
pip install -r requirements-dev.txt

# Run tests
pytest

# Run linting
pylint speechcortex/

# Format code
black speechcortex/

License

MIT License - see LICENSE file for details.

Support

For issues, questions, or contributions, please visit our GitHub repository.

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

speechcortex_sdk-0.1.3.tar.gz (20.3 kB view details)

Uploaded Source

Built Distribution

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

speechcortex_sdk-0.1.3-py3-none-any.whl (24.7 kB view details)

Uploaded Python 3

File details

Details for the file speechcortex_sdk-0.1.3.tar.gz.

File metadata

  • Download URL: speechcortex_sdk-0.1.3.tar.gz
  • Upload date:
  • Size: 20.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for speechcortex_sdk-0.1.3.tar.gz
Algorithm Hash digest
SHA256 5ca4be480c1c4cba373efb14ed860cc7b6c2f28de06965bdd2b46ab05d9cfee2
MD5 663d966c57c5e1de5b27667caebd173f
BLAKE2b-256 ff5ce101811f594576d09f5d08afd06f4f19a986f6c3174b4e65c040cc187425

See more details on using hashes here.

Provenance

The following attestation bundles were made for speechcortex_sdk-0.1.3.tar.gz:

Publisher: publish.yml on speechcortex/speechcortex-sdk

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

File details

Details for the file speechcortex_sdk-0.1.3-py3-none-any.whl.

File metadata

File hashes

Hashes for speechcortex_sdk-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 308947213d02088370734fb4a5d0f6fc083a0959c3760194ed8cac4f07a9da6c
MD5 d5bb028d7bf8c5b4a6fd8723f8185892
BLAKE2b-256 55198d765cc98059e95e392b6bfea4f382f940fd8388c7a9e4ba2b9d550c134d

See more details on using hashes here.

Provenance

The following attestation bundles were made for speechcortex_sdk-0.1.3-py3-none-any.whl:

Publisher: publish.yml on speechcortex/speechcortex-sdk

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