david
commited on
Commit
·
fa46942
1
Parent(s):
813ffab
fix seg id error
Browse files- transcribe/strategy.py +9 -6
transcribe/strategy.py
CHANGED
|
@@ -218,12 +218,15 @@ class TranscriptStabilityAnalyzer:
|
|
| 218 |
self._transcript_history.add(current)
|
| 219 |
|
| 220 |
prev = self._transcript_history.previous_chunk()
|
| 221 |
-
|
| 222 |
if not prev:
|
| 223 |
-
yield TranscriptResult(
|
|
|
|
|
|
|
|
|
|
| 224 |
return
|
| 225 |
|
| 226 |
-
|
| 227 |
|
| 228 |
if buffer_duration <= 12:
|
| 229 |
yield from self._handle_short_buffer(current, prev)
|
|
@@ -253,7 +256,7 @@ class TranscriptStabilityAnalyzer:
|
|
| 253 |
stable_str = self.merge_chunks(stable)
|
| 254 |
remaining_str = self.merge_chunks(remaining)
|
| 255 |
yield from self._yield_commit_results(
|
| 256 |
-
stable
|
| 257 |
)
|
| 258 |
else:
|
| 259 |
yield TranscriptResult(
|
|
@@ -285,9 +288,9 @@ class TranscriptStabilityAnalyzer:
|
|
| 285 |
)
|
| 286 |
|
| 287 |
# 如果还有挂起的文本
|
| 288 |
-
if (
|
| 289 |
yield TranscriptResult(
|
| 290 |
seg_id=self._transcript_buffer.get_seg_id(),
|
| 291 |
cut_index=frame_cut_index,
|
| 292 |
-
context=
|
| 293 |
)
|
|
|
|
| 218 |
self._transcript_history.add(current)
|
| 219 |
|
| 220 |
prev = self._transcript_history.previous_chunk()
|
| 221 |
+
self._transcript_buffer.update_pending_text(current.join())
|
| 222 |
if not prev:
|
| 223 |
+
yield TranscriptResult(
|
| 224 |
+
context=self._transcript_buffer.current_not_commit_text,
|
| 225 |
+
seg_id=self._transcript_buffer.get_seg_id()
|
| 226 |
+
)
|
| 227 |
return
|
| 228 |
|
| 229 |
+
|
| 230 |
|
| 231 |
if buffer_duration <= 12:
|
| 232 |
yield from self._handle_short_buffer(current, prev)
|
|
|
|
| 256 |
stable_str = self.merge_chunks(stable)
|
| 257 |
remaining_str = self.merge_chunks(remaining)
|
| 258 |
yield from self._yield_commit_results(
|
| 259 |
+
stable, remaining, is_end_sentence=True # 暂时硬编码为True
|
| 260 |
)
|
| 261 |
else:
|
| 262 |
yield TranscriptResult(
|
|
|
|
| 288 |
)
|
| 289 |
|
| 290 |
# 如果还有挂起的文本
|
| 291 |
+
if (current_not_commit_text := self._transcript_buffer.current_not_commit_text.strip()):
|
| 292 |
yield TranscriptResult(
|
| 293 |
seg_id=self._transcript_buffer.get_seg_id(),
|
| 294 |
cut_index=frame_cut_index,
|
| 295 |
+
context=current_not_commit_text
|
| 296 |
)
|