process_frame releases the GIL, streams running in separate threads process in parallel. This tutorial follows multi_stream_example.py, a benchmark that creates one SDK, runs N processors concurrently (one per thread), and reports success/failure counts, peak concurrency, per-stream wall time, and optional memory growth.
Reuse one
Sdk object across all streams — you activate once, then create a processor per thread. Do not create an SDK per stream.Prerequisites
Command-line flags
Step 1: Create and activate one SDK
Step 2: Define a per-stream worker
Each stream builds its ownPipelineWaiter, processor, and cloud params, then feeds the shared samples. Exceptions are caught per stream so one failure doesn’t take down the others. Note collect_output is only turned on when you actually intend to save audio — leaving it off keeps the memory-growth metric honest.
Step 3: Track live statistics
LiveStats is a thread-safe counter aggregated across streams. Its active and peak_concurrent fields reveal how many streams actually overlapped — something per-stream result dicts can’t show on their own.
MemorySampler thread records peak RSS every 0.5 s (a no-op without psutil). Sampling — rather than reading once at the end — captures the true high-water mark while streams overlap, so a leak or transient spike shows up in the report.
Step 4: Launch streams on a thread pool
Use aThreadPoolExecutor sized to --concurrency. Optionally stagger starts with --rate to model a ramp-up instead of a thundering herd.
Step 5: Read the report
--concurrency limit; memory growth should stay flat across a long soak run — steady climbing suggests a leak.
Tuning tips
Use--max-throughput to measure how fast the pipeline can process (no real-time pacing) versus the default real-time feed that models a live call. Raise --concurrency gradually and watch the success rate and memory growth to find a safe ceiling for your hardware and model. Leave --save-wav-out-period at 0 for benchmarking; set it to spot-check output quality on a sample of streams.
Next Steps
Processing a Single Stream
The core flow this benchmark scales up.
API Reference
Full SDK documentation for classes, enums, and callbacks.
Next Steps
Language Translation
Translate speech between languages and receive audio plus transcripts.
Processing Multiple Streams
Run many concurrent processors on one SDK instance.
References
SDK
SDK lifecycle methods including create_sdk, activate_api_key, and create_audio_processor.
AudioProcessor
process_frame method for audio processing.
Need Help?
Email Support
support@sanas.aiResponse time: 1 business day
Support Portal
Raise a support ticket for urgent issues