正在显示
4 个修改的文件
包含
15 行增加
和
6 行删除
| @@ -232,6 +232,8 @@ static void sherpa_decode_frame(const AVFrame *frame, SherpaOnnxOnlineRecognizer | @@ -232,6 +232,8 @@ static void sherpa_decode_frame(const AVFrame *frame, SherpaOnnxOnlineRecognizer | ||
| 232 | fprintf(stderr, "%s\n", r->text); | 232 | fprintf(stderr, "%s\n", r->text); |
| 233 | } | 233 | } |
| 234 | DestroyOnlineRecognizerResult(r); | 234 | DestroyOnlineRecognizerResult(r); |
| 235 | + | ||
| 236 | + Reset(recognizer, stream); | ||
| 235 | } | 237 | } |
| 236 | nb_samples = 0; | 238 | nb_samples = 0; |
| 237 | } | 239 | } |
| @@ -68,8 +68,9 @@ def main(): | @@ -68,8 +68,9 @@ def main(): | ||
| 68 | last_result = result | 68 | last_result = result |
| 69 | print(f"{segment_id}: {result}") | 69 | print(f"{segment_id}: {result}") |
| 70 | 70 | ||
| 71 | - if result and is_endpoint: | ||
| 72 | - segment_id += 1 | 71 | + if is_endpoint: |
| 72 | + if result: | ||
| 73 | + segment_id += 1 | ||
| 73 | recognizer.reset(stream) | 74 | recognizer.reset(stream) |
| 74 | 75 | ||
| 75 | 76 |
| @@ -132,8 +132,11 @@ as the device_name. | @@ -132,8 +132,11 @@ as the device_name. | ||
| 132 | display.Print(segment_index, text); | 132 | display.Print(segment_index, text); |
| 133 | } | 133 | } |
| 134 | 134 | ||
| 135 | - if (!text.empty() && is_endpoint) { | ||
| 136 | - ++segment_index; | 135 | + if (is_endpoint) { |
| 136 | + if (!text.empty()) { | ||
| 137 | + ++segment_index; | ||
| 138 | + } | ||
| 139 | + | ||
| 137 | recognizer.Reset(stream.get()); | 140 | recognizer.Reset(stream.get()); |
| 138 | } | 141 | } |
| 139 | } | 142 | } |
| @@ -147,8 +147,11 @@ for a list of pre-trained models to download. | @@ -147,8 +147,11 @@ for a list of pre-trained models to download. | ||
| 147 | display.Print(segment_index, text); | 147 | display.Print(segment_index, text); |
| 148 | } | 148 | } |
| 149 | 149 | ||
| 150 | - if (!text.empty() && is_endpoint) { | ||
| 151 | - ++segment_index; | 150 | + if (is_endpoint) { |
| 151 | + if (!text.empty()) { | ||
| 152 | + ++segment_index; | ||
| 153 | + } | ||
| 154 | + | ||
| 152 | recognizer.Reset(s.get()); | 155 | recognizer.Reset(s.get()); |
| 153 | } | 156 | } |
| 154 | 157 |
-
请 注册 或 登录 后发表评论