An Azure service that integrates speech processing into apps and services.
Segmentation fault during WebM → OGG/PCM conversion using GStreamer in Azure AI Speech integrationWe’re facing segmentation fault crashes while performing real-time audio conversion using GStreamer before streaming audio to Azure AI Speech for transcripti
We’re facing segmentation fault crashes while performing real-time audio conversion using GStreamer before streaming audio to Azure AI Speech for transcription.
Environment details
Azure Speech SDK: azure-cognitiveservices-speech
GStreamer versions tested: 1.20.3 and 1.24.2
Containerized app: Runs inside AKS (Azure Kubernetes Service)
OS: Ubuntu (container base)
- Language: Python 3.10 and 3.12
Use case
Incoming audio is in WebM format (Opus encoded), which we convert to either:
OGG Opus for compressed transcription
PCM (16-bit, mono, 16 kHz) for uncompressed real-time transcription
We use a PushAudioInputStream to send the converted data to Azure Speech’s ConversationTranscriber.
Code summary
Below is the relevant GStreamer conversion logic (simplified):
import
import
import
from
import
# Ensure Gst is imported first
gi
from
from
# Initialize GStreamer once
Gst.init(
class
Thread-safe converter: WebM audio chunks -> (ogg/opus or raw pcm)
- Runs GLib.MainLoop on a background thread
- Uses appsink callbacks to push converted chunks into a thread-safe Queue
- Uses an Event to signal finished/closed state (safer than peeking internal queue)
"""
GLib.idle_add(
GLib.idle_add(
def
)
def
)
and for PCM:
appsrc name=src is-live=true format=time do-timestamp=true !
matroskademux name=demux ! queue ! opusdec ! audioconvert ! audioresample !
audio/x-raw,format=S16LE,channels=1,rate=16000 !
appsink name=sink emit-signals=true sync=false
The full converter class uses:
Thread-safe queue (queue.Queue) between GLib and asyncio threads
Dedicated GLib MainLoop thread
Bus error handling with _bus_call() for EOS/ERROR/WARNING messages
Graceful shutdown using EOS + state NULL transition
Despite these protections, we still observe segmentation faults during active conversions — often after a few minutes of streaming.
Error pattern
The Python process terminates with exit code 139 (segmentation fault).
No GStreamer Python exception is raised — the fault occurs inside native GStreamer libs.
The issue persists across GStreamer versions 1.20.3 and 1.24.2.
What we’ve tried
Ensured all buffers are unmapped properly (buf.unmap(map_info))
Added thread-safe data handling between GLib and asyncio
Explicitly stopped the pipeline and joined threads
Tried both OGG and PCM pipelines
Verified that no uninitialized GStreamer element is being accessed
Goal
To achieve production-grade stability in an application that performs:
Real-time WebM → OGG/PCM conversion
Continuous push-stream transcription using Azure Speech’s ConversationTranscriber
Would appreciate any guidance, best practices, or references from Microsoft/Azure or GStreamer maintainers.
We’re facing segmentation fault crashes while performing real-time audio conversion using GStreamer before streaming audio to Azure AI Speech for transcription.