fix: Improve TranscriptProcessor detection for transcript type

This commit is contained in:
Mark Backman
2025-07-28 19:56:36 -04:00
parent c9dda5251c
commit 50242f4ad8
2 changed files with 7 additions and 2 deletions

View File

@@ -140,11 +140,13 @@ class AssistantTranscriptProcessor(BaseTranscriptProcessor):
Result: "Hello there how are you"
"""
if self._current_text_parts and self._aggregation_start_time:
# Check specifically for space characters, previously isspace() was used
# but that includes all whitespace characters (e.g. \n), not just spaces.
has_leading_spaces = any(
part and part[0].isspace() for part in self._current_text_parts[1:]
part and part[0] == " " for part in self._current_text_parts[1:]
)
has_trailing_spaces = any(
part and part[-1].isspace() for part in self._current_text_parts[:-1]
part and part[-1] == " " for part in self._current_text_parts[:-1]
)
# If there are embedded spaces in the fragments, use direct concatenation