Skip to content

Align translated_batch and result.segments #420

Answered by jianfch
Louisfrn asked this question in Q&A
Discussion options

You must be logged in to vote

Which version of Stable-ts are you using?

This line should raise an AttributeError in the latest version:

        segment.text = translated_batch[i]

This is because text is a property of the all the words in the segment for results with word-timestamps.

@property
def text(self) -> str:
if self.has_words:
return ''.join(word.word for word in self.words)
return self._default_text

You have to replace the individual words of the segment in order to change the text of the segment itself:

def replace_text_batch(segments, translated_batch):
    if len(segments) != len(translated_batch):
        r…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Louisfrn
Comment options

Answer selected by Louisfrn
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants