private async void Transcribe_DoWork(object sender, DoWorkEventArgs e) { List <String> sttResult = _transcriber.Transcribe(); if (sttResult.Count > 0) { //Recognized text: ar un roedd amodau meg amarch //Confidence: -72.9908981323242 //Item count: 29 //Timestep: 37 TimeOffset: 0.74 Char: a //Timestep : 38 TimeOffset: 0.76 Char: r //Timestep : 81 TimeOffset: 1.62 Char: String[] resultLines = sttResult[0].Split(Environment.NewLine.ToCharArray()); this._recognizedText = resultLines[0].Replace("Recognized text:", "").Trim(); e.Result = this._recognizedText; } }
// static void Main(string[] args) { string model = null; string scorer = null; string audio = null; bool extended = true; model = GetArgument(args, "--model"); scorer = GetArgument(args, "--scorer"); audio = GetArgument(args, "--audio"); extended = !string.IsNullOrWhiteSpace(GetArgument(args, "--extended")); DeepSpeechTranscriber _transcriber; try { _transcriber = new DeepSpeechTranscriber(model: model, kenlm_scorer: scorer); } catch (Exception exc) { Console.Out.WriteLine(exc.Message); Console.Out.WriteLine("Pwyswch 'Return' i gau'r rhaglen."); Console.In.ReadLine(); return; } List <string> sttResult; if (!String.IsNullOrEmpty(audio)) { _transcriber.AddRecording(audio); sttResult = _transcriber.Transcribe(); foreach (String r in sttResult) { Console.Out.WriteLine(r); } } else { Console.Out.WriteLine("Adnabod lleferydd o'r microffon"); while (true) { Console.Out.WriteLine(Environment.NewLine); Console.Out.WriteLine("Pwyswch 'Return' i ddechrau recordio..."); Console.In.ReadLine(); Console.Out.WriteLine("Yn recordio... pwyswch 'Return' i stopio'r recordio."); _transcriber.StartRecording(); Console.In.ReadLine(); _transcriber.StopRecording(); sttResult = _transcriber.Transcribe(); foreach (String r in sttResult) { Console.Out.WriteLine(r); } } } }