fixed a bug
This commit is contained in:
@@ -99,7 +99,8 @@ class MossTranscriber:
|
|||||||
segments = _parse_json_segments(payload.get("segments"))
|
segments = _parse_json_segments(payload.get("segments"))
|
||||||
if not segments:
|
if not segments:
|
||||||
segments = _parse_compact_segments(raw_text)
|
segments = _parse_compact_segments(raw_text)
|
||||||
plain_text = " ".join(segment.text for segment in segments).strip() or raw_text
|
plain_text = " ".join(segment.text for segment in segments).strip()
|
||||||
|
plain_text = _strip_speaker_tags(plain_text) or _strip_speaker_tags(raw_text)
|
||||||
return Transcript(text=plain_text, segments=segments)
|
return Transcript(text=plain_text, segments=segments)
|
||||||
|
|
||||||
def _transcribe_chunked(
|
def _transcribe_chunked(
|
||||||
@@ -142,7 +143,9 @@ class MossTranscriber:
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
segments.sort(key=lambda item: (item.start_seconds, item.end_seconds))
|
segments.sort(key=lambda item: (item.start_seconds, item.end_seconds))
|
||||||
plain_text = " ".join(segment.text for segment in segments).strip()
|
plain_text = _strip_speaker_tags(
|
||||||
|
" ".join(segment.text for segment in segments).strip()
|
||||||
|
)
|
||||||
return Transcript(text=plain_text, segments=segments)
|
return Transcript(text=plain_text, segments=segments)
|
||||||
|
|
||||||
def _post_audio(
|
def _post_audio(
|
||||||
@@ -249,6 +252,11 @@ _ABBREVIATION_RE = re.compile(
|
|||||||
_SPEAKER_TAG_RE = re.compile(r"\[(S\d+)\]")
|
_SPEAKER_TAG_RE = re.compile(r"\[(S\d+)\]")
|
||||||
|
|
||||||
|
|
||||||
|
def _strip_speaker_tags(text: str) -> str:
|
||||||
|
"""Remove inline ``[S01]`` speaker tags from a text string."""
|
||||||
|
return _SPEAKER_TAG_RE.sub("", text).strip()
|
||||||
|
|
||||||
|
|
||||||
def _expand_speaker_segments(
|
def _expand_speaker_segments(
|
||||||
segment: TranscriptionSegment,
|
segment: TranscriptionSegment,
|
||||||
) -> List[TranscriptionSegment]:
|
) -> List[TranscriptionSegment]:
|
||||||
|
|||||||
Reference in New Issue
Block a user