Fix endpointing with microphone (#64)
This commit is contained in:
@@ -232,6 +232,8 @@ static void sherpa_decode_frame(const AVFrame *frame, SherpaOnnxOnlineRecognizer
|
|||||||
fprintf(stderr, "%s\n", r->text);
|
fprintf(stderr, "%s\n", r->text);
|
||||||
}
|
}
|
||||||
DestroyOnlineRecognizerResult(r);
|
DestroyOnlineRecognizerResult(r);
|
||||||
|
|
||||||
|
Reset(recognizer, stream);
|
||||||
}
|
}
|
||||||
nb_samples = 0;
|
nb_samples = 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -68,8 +68,9 @@ def main():
|
|||||||
last_result = result
|
last_result = result
|
||||||
print(f"{segment_id}: {result}")
|
print(f"{segment_id}: {result}")
|
||||||
|
|
||||||
if result and is_endpoint:
|
if is_endpoint:
|
||||||
segment_id += 1
|
if result:
|
||||||
|
segment_id += 1
|
||||||
recognizer.reset(stream)
|
recognizer.reset(stream)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -132,8 +132,11 @@ as the device_name.
|
|||||||
display.Print(segment_index, text);
|
display.Print(segment_index, text);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!text.empty() && is_endpoint) {
|
if (is_endpoint) {
|
||||||
++segment_index;
|
if (!text.empty()) {
|
||||||
|
++segment_index;
|
||||||
|
}
|
||||||
|
|
||||||
recognizer.Reset(stream.get());
|
recognizer.Reset(stream.get());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -147,8 +147,11 @@ for a list of pre-trained models to download.
|
|||||||
display.Print(segment_index, text);
|
display.Print(segment_index, text);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!text.empty() && is_endpoint) {
|
if (is_endpoint) {
|
||||||
++segment_index;
|
if (!text.empty()) {
|
||||||
|
++segment_index;
|
||||||
|
}
|
||||||
|
|
||||||
recognizer.Reset(s.get());
|
recognizer.Reset(s.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user