Skip to content

Audio enhancer

The problem. A phone line that hisses, a headset that hums, a cheap microphone: the noise around the voice makes words harder to hear, for a person and for the model. The audio enhancer reduces that noise before the audio is transcribed.

Where it works. Live sessions, on platforms whose operator turned it on (it is off on Gladia’s managed clusters today). It is Gladia’s own option, pre_processing.audio_enhancer: the same body works on Gladia’s cloud API. Pre-recorded jobs do not take it (see Limits and gotchas).

Live APIpre_processing.audio_enhancer
Pre-recorded (batch)Live only
Live modelssolaria-3, trantoria-1 (every live model)
LanguagesEvery language of the model (supported languages)

GET /v2/live/capabilities lists, per model, the add-ons a session may ask for with your key right now. The audio enhancer is there as audio_enhancer when the model’s hosts run it:

Terminal window
curl https://eu1.api.gladia.io/v2/live/capabilities \
-H "x-gladia-key: $GLADIA_API_KEY"
{
"encoding": "wav/pcm",
"sample_rate": 16000,
"bit_depth": 16,
"channels": 1,
"model": "solaria-3",
"pre_processing": { "audio_enhancer": true }
}

In a session, with the SDKs or over HTTP. Each program streams a 16-bit WAV file with the enhancer on and prints the final transcripts. Put your API key in the GLADIA_API_KEY environment variable, then run python audio_enhancer.py call.wav.

audio_enhancer.py
# pip install -U "gladiaio-sdk>=2.2"
import os
import sys
import threading
import wave
from gladiaio_sdk import GladiaClient
API_URL = os.environ.get("GLADIA_API_URL", "https://eu1.api.gladia.io")
API_KEY = os.environ["GLADIA_API_KEY"]
with wave.open(sys.argv[1]) as wav: # a 16-bit PCM WAV file
rate, channels = wav.getframerate(), wav.getnchannels()
audio = wav.readframes(wav.getnframes())
config = {
"encoding": "wav/pcm",
"sample_rate": rate,
"bit_depth": 16,
"channels": channels,
"model": "solaria-3",
"language_config": {"languages": ["en"]},
"pre_processing": {"audio_enhancer": True},
}
client = GladiaClient(api_key=API_KEY, api_url=API_URL)
# a dict is sent as is: the Gladia Enterprise options included
session = client.live_v2().start_session(config)
ended, errors = threading.Event(), []
@session.on("message")
def on_message(message):
if message.type == "transcript" and message.data.is_final:
print(message.data.utterance.text)
session.on("error", errors.append)
session.once("ended", lambda _: ended.set())
# Stream once the socket is open: a stop sent while it opens can pass the audio queued until then.
connected = threading.Event()
session.once("connected", lambda _: connected.set())
session.once("ended", lambda _: connected.set()) # a session that never connects ends
session.on("error", lambda _: connected.set())
if session.status == "connected": # it opened before the listener above
connected.set()
if not connected.wait(timeout=30) or errors or ended.is_set():
sys.exit(1) # no open session to stream to
step = rate * channels * 2 // 10 # 100 ms of audio per chunk
for start in range(0, len(audio), step):
session.send_audio(audio[start : start + step]) # live audio: send each chunk as it is captured
session.stop_recording()
ended.wait(timeout=60)
sys.exit(1 if errors or not ended.is_set() else 0)

Every channel of the session is cleaned the same way. Only the audio the model hears changes: the messages, the transcripts and their words have the same shape as without it, their times still those of the audio you sent.

The option is ignored and the session runs without it, as on Gladia’s cloud API: POST /v2/live answers 201 and the audio is transcribed as sent. Ask your operator to turn it on if you need it.

  • It can make things worse. It helps close-talk audio with line noise, hiss or hum. On distant speech (a meeting room microphone, a speakerphone) it can remove parts of the voice and raise the error rate. Compare a few of your own calls with and without it before you turn it on for everyone.
  • About 340 ms more latency. The enhancer reads a little audio ahead before it passes it on: every partial and final comes that much later.
  • Live only. Gladia’s pre-recorded API has no pre_processing: POST /v2/pre-recorded refuses it with a 400 (pre_processing property should not exist), as it refuses any field it does not know.
  • Off by default. Omitted, or false: the audio is transcribed as sent, and the option is never refused.
symptom cause fix
no noise reduction heard no host of your platform runs it: the option is ignored ask your operator to turn it on
more errors than without it distant or quiet speech turn it off for those calls
finals later than usual the enhancer’s 340 ms expected; turn it off where latency matters more than noise