Method DetectLanguage
DetectLanguage(WaveFile, CancellationToken)
Synchronously detects the spoken language of the provided audio content.
public SpeechToText.LanguageDetectionResult DetectLanguage(WaveFile audioFile, CancellationToken cancellationToken = default)Parameters
- audioFileWaveFile
- The WAV-format audio content to analyze. 
- cancellationTokenCancellationToken
- Token to cancel the operation. 
Returns
- SpeechToText.LanguageDetectionResult
- A SpeechToText.LanguageDetectionResult containing the detected ISO-639-1 language code (e.g. "en" for English) along with a confidence score between 0.0 and 1.0. 
Examples
var model = LM.LoadFromModelID("whisper-large-turbo3");
var engine = new SpeechToText(model);
var audioFile = new WaveFile("audio.wav");
var lang = engine.DetectLanguage(audioFile);
Console.WriteLine($"Detected language: {lang}");Exceptions
- ArgumentNullException
- Thrown if - audioFileis null.
- NotSupportedException
- Thrown if the model does not support language detection.