Real-Time Speech Recognition and Translation in C# with Whisper
The application captures audio streams from platforms like Teams, splits them into phrases based on voice amplitude and pauses, then uses Whisper for speech-to-text (STT) in Russian, English, or French, followed by translation. The C# implementation relies on about 20% custom code, with the rest built through integrations. It supports a dictation mode when a single language is selected—just transcription with optional audio saving.
Settings allow calibration of:
- Voice amplitude thresholds for speech detection.
- Pause duration between phrases.
Statistics displayed in the bottom-right corner show current audio levels and detection flags—ideal for fine-tuning. Audio capture works only with the system mixer (headphones/speakers); direct microphone input is not supported.
Choosing Whisper Models and Performance
Local STT solutions were tested:
- Sherpa (ONNX): streaming French version didn’t fit the architecture.
- Foundry Local (Microsoft): raw, file-based communication, based on Whisper.
We chose Whisper:
| Model | Speed | Logic | Notes |
|-------|-------|-------|-------|
| Base | Fast | None | Minimal, no context |
| Small | Medium | Yes | Optimal balance, temperature 0.1–0.2 |
| Medium | Slow | Good | Chunk queue grows during live meetings |
Without NPU/GPU, RAM usage increases, but results remain acceptable with high-quality meeting audio.
Integrating Translation Services
Two options available:
- OpenAI: API key, model, and URL configured in settings.
- Azure Translator: Free tier includes 2 million characters/month; requires an account.
The ITranslationService interface simplifies adding new providers (Yandex API possible with billing). No local translators matched the quality benchmarks.
Example Azure configuration:
public class AzureTranslationService : ITranslationService
{
private readonly string _key;
// ...
}
Practical Use Cases and Limitations
This utility solves real-time multilingual meeting needs without recording. Tested with French, English, and Russian. Not a universal recorder—only system audio output is captured.
For mid-to-senior developers: modular architecture focused on streaming chunk processing. Extensible via replacing STT/translation engines or adding new VAD algorithms.
Key takeaways:
- System audio capture with phrase splitting using VAD-like parameters.
- Whisper Small is optimal for real-time use: temperature 0.1–0.2, no GPU required.
- Simple translator interface; Azure offers 2M free characters/month.
- STT-only mode for transcription without translation.
- Real-time statistics for tuning speech detection accuracy.
— Editorial Team
No comments yet.