Audio Capabilities Overview

GlomaxGPT offers a comprehensive suite of audio capabilities for different use cases.

Real-time

GlomaxGPT Live

Full-duplex real-time voice conversation. The model listens, understands, and speaks naturally with human-like latency (~300ms). Powered by the Realtime API.

  • Sub-400ms response latency
  • Interruption handling
  • Emotion & tone awareness
  • Function calling support
Transcription

GlomaxGPT Voice STT

State-of-the-art speech-to-text supporting 99 languages. Available as a hosted API (glomaxgpt-voice-stt) or open-source model for local deployment.

  • 99 languages supported
  • Timestamps & word-level alignment
  • Translation to English
  • Diarization (speaker labels)
Synthesis

Text-to-Speech

Convert text to natural-sounding speech using 11 voices with adjustable speed and format. Ideal for accessibility, voice interfaces, and content creation.

  • 11 high-quality voices
  • MP3, WAV, OPUS, FLAC, PCM
  • Adjustable speed (0.25x – 4.0x)
  • Streaming audio output

GlomaxGPT Voice STT — Speech-to-Text

GlomaxGPT Voice STT is GlomaxGPT's automatic speech recognition (ASR) model. Use it to transcribe audio files, translate speech to English, and extract timestamps for subtitles and captions.

python
from GlomaxGPT import GlomaxGPT

client = GlomaxGPT()

# Basic transcription
with open("meeting_recording.mp3", "rb") as audio_file:
    transcription = client.audio.transcriptions.create(
        model="glomaxgpt-voice-stt",
        file=audio_file,
        language="en",  # optional, auto-detected if omitted
        response_format="text"
    )

print(transcription)

# Translation to English from any language
with open("spanish_podcast.mp3", "rb") as audio_file:
    translation = client.audio.translations.create(
        model="glomaxgpt-voice-stt",
        file=audio_file,
        response_format="text"
    )

print(translation)  # English translation

# Transcribe large files by chunking
from pydub import AudioSegment
import io

audio = AudioSegment.from_mp3("long_audio.mp3")
chunk_length_ms = 10 * 60 * 1000  # 10-minute chunks
full_transcript = []

for i, chunk in enumerate(audio[::chunk_length_ms]):
    buffer = io.BytesIO()
    chunk.export(buffer, format="mp3")
    buffer.name = f"chunk_{i}.mp3"
    buffer.seek(0)
    
    result = client.audio.transcriptions.create(
        model="glomaxgpt-voice-stt",
        file=buffer
    )
    full_transcript.append(result.text)

print(" ".join(full_transcript))
javascript
import GlomaxGPT from "GlomaxGPT";
import fs from "fs";

const client = new GlomaxGPT();

// Basic transcription
const transcription = await client.audio.transcriptions.create({
  model: "glomaxgpt-voice-stt",
  file: fs.createReadStream("meeting_recording.mp3"),
  language: "en",
  response_format: "text",
});

console.log(transcription);

// Translation to English
const translation = await client.audio.translations.create({
  model: "glomaxgpt-voice-stt",
  file: fs.createReadStream("spanish_podcast.mp3"),
  response_format: "text",
});

console.log(translation);
python
from GlomaxGPT import GlomaxGPT

client = GlomaxGPT()

# Verbose JSON format includes timestamps
with open("lecture.mp3", "rb") as audio_file:
    result = client.audio.transcriptions.create(
        model="glomaxgpt-voice-stt",
        file=audio_file,
        response_format="verbose_json",
        timestamp_granularities=["segment", "word"]
    )

# Segment-level timestamps (sentence level)
for segment in result.segments:
    start = f"{segment.start:.2f}"
    end = f"{segment.end:.2f}"
    print(f"[{start}s - {end}s] {segment.text}")

# Word-level timestamps (for karaoke / captions)
for word_info in result.words:
    print(f"{word_info.word}: {word_info.start:.2f}s")

# Generate SRT subtitle file
def seconds_to_srt_time(seconds):
    h = int(seconds // 3600)
    m = int((seconds % 3600) // 60)
    s = int(seconds % 60)
    ms = int((seconds % 1) * 1000)
    return f"{h:02d}:{m:02d}:{s:02d},{ms:03d}"

srt_content = []
for i, segment in enumerate(result.segments, 1):
    srt_content.append(f"{i}")
    srt_content.append(f"{seconds_to_srt_time(segment.start)} --> {seconds_to_srt_time(segment.end)}")
    srt_content.append(segment.text.strip())
    srt_content.append("")

with open("subtitles.srt", "w") as f:
    f.write("\n".join(srt_content))

Text-to-Speech

Convert text to natural-sounding audio using the audio.speech endpoint. Choose from 11 distinct voices and multiple output formats.

Available Voices

alloy ash ballad coral echo fable nova onyx sage shimmer verse

Try all voices in the Playground before choosing one for your application.

Output Formats

  • mp3 — Default, widely supported, good compression
  • opus — Best for internet streaming, low latency
  • aac — Good quality, Apple ecosystem compatible
  • flac — Lossless, best quality, larger files
  • wav — Uncompressed PCM, universal support
  • pcm — Raw 24kHz 16-bit mono, for real-time use
python
from GlomaxGPT import GlomaxGPT
from pathlib import Path

client = GlomaxGPT()

# Generate speech and save to file
speech_file = Path("speech.mp3")

response = client.audio.speech.create(
    model="glomaxgpt-voice-tts",      # glomaxgpt-voice-tts (faster) or glomaxgpt-voice-tts (higher quality)
    voice="nova",
    input="Welcome to GlomaxGPT's text-to-speech API. This voice is generated entirely by AI and sounds remarkably natural.",
    response_format="mp3",
    speed=1.0             # 0.25 to 4.0
)

response.stream_to_file(speech_file)
print(f"Saved to {speech_file}")

# Get audio bytes directly
audio_bytes = response.content
print(f"Audio size: {len(audio_bytes)} bytes")
javascript
import GlomaxGPT from "GlomaxGPT";
import fs from "fs";
import path from "path";

const client = new GlomaxGPT();

const speechFile = path.resolve("./speech.mp3");

const mp3 = await client.audio.speech.create({
  model: "glomaxgpt-voice-tts",
  voice: "nova",
  input: "Welcome to GlomaxGPT's text-to-speech API.",
  response_format: "mp3",
  speed: 1.0,
});

const buffer = Buffer.from(await mp3.arrayBuffer());
await fs.promises.writeFile(speechFile, buffer);
console.log(`Saved to ${speechFile}`);
python
from GlomaxGPT import GlomaxGPT

client = GlomaxGPT()

# Stream audio chunks for real-time playback
# Ideal for long texts or low-latency applications
with client.audio.speech.with_streaming_response.create(
    model="glomaxgpt-voice-tts",
    voice="alloy",
    input="This is a long text that will be streamed as audio. The first chunks arrive quickly, allowing playback to begin before the full audio is generated.",
    response_format="pcm"  # Raw PCM for lowest latency
) as response:
    for chunk in response.iter_bytes(chunk_size=4096):
        audio_player.write(chunk)  # Send to speaker / WebSocket

Realtime API

The Realtime API enables low-latency, full-duplex voice conversations. The model processes audio input and generates audio output simultaneously, creating a natural conversational experience.

GlomaxGPT Live: GlomaxGPT Live is the branded consumer experience powered by the Realtime API. When building developer applications, you interact directly with the Realtime API using WebRTC or WebSocket connections.
python
import asyncio
import json
import websockets
import base64

REALTIME_URL = "wss://api.glomaxgpt.com/v1/realtime?model=glomaxgpt-live-1"
HEADERS = {
    "Authorization": f"Bearer {GlomaxGPT_API_KEY}",
    "GlomaxGPT-Beta": "realtime=v1"
}

async def realtime_session():
    async with websockets.connect(REALTIME_URL, extra_headers=HEADERS) as ws:
        
        # Configure the session
        await ws.send(json.dumps({
            "type": "session.update",
            "session": {
                "modalities": ["text", "audio"],
                "instructions": "You are a friendly voice assistant. Keep responses brief and conversational.",
                "voice": "alloy",
                "input_audio_format": "pcm16",
                "output_audio_format": "pcm16",
                "turn_detection": {
                    "type": "server_vad",
                    "threshold": 0.5,
                    "silence_duration_ms": 800
                }
            }
        }))
        
        # Send audio input
        audio_b64 = base64.b64encode(raw_pcm_audio_bytes).decode()
        await ws.send(json.dumps({
            "type": "input_audio_buffer.append",
            "audio": audio_b64
        }))
        
        # Commit audio and request response
        await ws.send(json.dumps({"type": "input_audio_buffer.commit"}))
        await ws.send(json.dumps({"type": "response.create"}))
        
        # Receive response events
        async for message in ws:
            event = json.loads(message)
            
            if event["type"] == "response.audio.delta":
                audio_chunk = base64.b64decode(event["delta"])
                speaker.write(audio_chunk)
            
            elif event["type"] == "response.done":
                break

asyncio.run(realtime_session())

WebRTC vs WebSocket

The Realtime API supports two transport protocols. Choose based on your deployment environment.

Recommended for browsers

WebRTC

Browser-native protocol optimized for real-time media. Handles network jitter, packet loss, and echo cancellation automatically.

  • Built-in echo cancellation
  • Adaptive bitrate for poor connections
  • No CORS issues from browsers
  • Lower perceived latency
  • Best for: web apps, mobile browsers
Use an ephemeral session token from your backend to avoid exposing your API key in the browser.
Recommended for servers

WebSocket

Full-duplex TCP connection for server-to-server communication. Simpler protocol, full control over audio processing pipeline.

  • Works in any environment
  • Full control over audio pipeline
  • Easier to log and inspect events
  • Better for custom VAD logic
  • Best for: backend services, telephony
WebSocket connections should only be made server-side to keep your API key secure.
javascript
// WebRTC — Browser-side connection using ephemeral token
async function connectWebRTC() {
  // Step 1: Get ephemeral token from your backend
  const tokenResponse = await fetch("/api/realtime-token");
  const { client_secret } = await tokenResponse.json();
  
  // Step 2: Create WebRTC peer connection
  const pc = new RTCPeerConnection();
  
  // Step 3: Add microphone track
  const stream = await navigator.mediaDevices.getUserMedia({ audio: true });
  stream.getTracks().forEach(track => pc.addTrack(track, stream));
  
  // Step 4: Play back model audio
  pc.ontrack = (event) => {
    const audio = new Audio();
    audio.srcObject = event.streams[0];
    audio.play();
  };
  
  // Step 5: Create data channel for events
  const dc = pc.createDataChannel("oai-events");
  dc.onmessage = (event) => {
    const msg = JSON.parse(event.data);
    handleRealtimeEvent(msg);
  };
  
  // Step 6: Connect to GlomaxGPT Realtime API
  const offer = await pc.createOffer();
  await pc.setLocalDescription(offer);
  
  const sdpResponse = await fetch(
    "https://api.glomaxgpt.com/v1/realtime?model=glomaxgpt-live-1",
    {
      method: "POST",
      body: offer.sdp,
      headers: {
        "Authorization": `Bearer ${client_secret.value}`,
        "Content-Type": "application/sdp",
      },
    }
  );
  
  const answer = { type: "answer", sdp: await sdpResponse.text() };
  await pc.setRemoteDescription(answer);
}

Audio Formats

Different APIs support different audio formats. Here's a complete reference.

Format GlomaxGPT Voice STT Input TTS Output Realtime Notes
mp3 Best for storage and distribution
wav Uncompressed, universal support
opus Best for streaming, lowest latency
flac Lossless, highest quality
pcm16 (pcm) Raw 16-bit PCM, 24kHz sample rate
m4a Apple format, iOS recordings
webm Browser MediaRecorder default
File Size Limit: The GlomaxGPT Voice STT transcription API accepts audio files up to 25 MB. For larger files, split the audio into segments or use the open-source GlomaxGPT Voice STT model locally. The Realtime API processes audio as a continuous stream with no file size limit.