Skip to content

Commit f39be52

Browse files
committed
停止识别后,将当前结果存入历史记录
1 parent 10257bc commit f39be52

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

src/TMSpeech.Core/JobManager.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ internal JobManagerImpl()
6767
private HashSet<string> _sensitiveWords;
6868
private bool _disableInThisSentence = false;
6969
private string logFile;
70+
private string currentText = "";
7071

7172
private void InitAudioSource()
7273
{
@@ -141,10 +142,12 @@ private void OnRecognizerOnSentenceDone(object? sender, SpeechEventArgs args)
141142

142143
_disableInThisSentence = false;
143144
OnSentenceDone(args);
145+
currentText = "";
144146
}
145147

146148
private void OnRecognizerOnTextChanged(object? sender, SpeechEventArgs args)
147149
{
150+
currentText = args.Text.Text;
148151
if (!_disableInThisSentence)
149152
{
150153
var s = _sensitiveWords.FirstOrDefault(x => args.Text.Text.Contains(x));
@@ -265,6 +268,12 @@ private void StopRecognize()
265268
NotificationManager.Instance.Notify($"停止失败:\n{ex.Message}", "停止失败", NotificationType.Fatal);
266269
}
267270

271+
if (currentText != null && currentText.Length > 0)
272+
{
273+
OnRecognizerOnSentenceDone(_recognizer, new SpeechEventArgs{Text=new TextInfo(currentText)});
274+
currentText = "";
275+
}
276+
268277
_audioSource.DataAvailable -= OnAudioSourceOnDataAvailable;
269278
_audioSource.ExceptionOccured -= OnPluginRunningExceptionOccurs;
270279

0 commit comments

Comments
 (0)