Method DetectLanguageAsync
DetectLanguageAsync(WaveFile, CancellationToken)
Asynchronously detects the spoken language of the provided audio content.
public Task<SpeechToText.LanguageDetectionResult> DetectLanguageAsync(WaveFile audioFile, CancellationToken cancellationToken = default)Parameters
- audioFileWaveFile
- The WAV-format audio content to analyze. 
- cancellationTokenCancellationToken
- Token to cancel the operation. 
Returns
- Task<SpeechToText.LanguageDetectionResult>
- A task that produces a SpeechToText.LanguageDetectionResult, containing the detected ISO-639-1 language code and 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 = await engine.DetectLanguageAsync(audioFile);
Console.WriteLine($"Detected language: {lang}");Exceptions
- ArgumentNullException
- Thrown if - audioFileis null.
- NotSupportedException
- Thrown if the model does not support language detection.