private void SpeechToText(ApplicationArguments appArgs) { Logger.Log(string.Empty); Logger.Log($"*** {VersionService.Version} ***"); var options = ApplicationArguments.ToOptions(appArgs); void Cleanup(object sender, UnhandledExceptionEventArgs e) => File.Delete(options.KeyPath); AppDomain.CurrentDomain.UnhandledException += Cleanup; string decrypted = DecryptKey(appArgs); File.WriteAllText(options.KeyPath, decrypted); if (!Directory.Exists(options.Destination)) { Directory.CreateDirectory(options.Destination); } Logger.Log($"Processing audio files {options}"); ProgressIndicator.Busy(); var api = new SpeechToText(); var tasks = api.Transcribe(options); Task.WhenAll(tasks).Wait(); ProgressIndicator.Completed(); ReportResults(tasks); Logger.Log(string.Empty); Logger.Log($"Transcripts saved in \"{options.Destination}\""); Logger.Log(string.Empty); AppDomain.CurrentDomain.UnhandledException -= Cleanup; Cleanup(null, null); }