Skip to content

v0.6.0

Choose a tag to compare

@rootint rootint released this 14 Sep 01:35
· 1 commit to main since this release

Realtime streaming

client.realtime.connect() now speaks the public streaming.nexara.ru WebSocket protocol (v1): GET /v1/transcribe with the session parameters in the query string and the API key as a Bearer token; raw PCM in, final words out.

async with client.realtime.connect(sample_rate=16000, diarize=True) as session:
    async for event in session.stream(microphone()):
        print(event.speaker, event.words[0].start, event.text)
    print(session.ended.text)
  • RealtimeSession: async iteration of RealtimeTranscript events, stream(), finish() (sends input_audio.end, resolves on session.ended), keepalive(), close(). Sending and receiving are concurrent.
  • Parameters: encoding (pcm_s16le default, pcm_f32le, pcm_mulaw, pcm_alaw), sample_rate (8–48 kHz), channels, multichannel, diarize, delay_ms, client_id; invalid values raise NexaraValidationError before connecting.
  • Every word is final, with integer-millisecond timestamps on the audio clock and, with diarize=True, a speaker label (0–3 or None).
  • New RealtimeError(code, reason, message) for server-side closes (session_full, idle_timeout, audio_backlog, service_restart, …); wallet exhaustion mid-session raises InsufficientBalanceError; a rejected handshake raises the usual status-mapped errors.
  • Requires the realtime extra: pip install nexara[realtime].

Breaking: the previous placeholder realtime API (RealtimeEvent, RealtimeToken, is_final) is gone — it never matched a real server.