Skip to content

Commit

Permalink
Remove the capitalize function in favor of str manip
Browse files Browse the repository at this point in the history
  • Loading branch information
evamaxfield committed Feb 17, 2023
1 parent 8b49d32 commit e9517b4
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions cdp_backend/sr_models/whisper.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,20 +240,24 @@ def transcribe(
for sent_index, sentence_with_word_metas in enumerate(
sentences_with_word_metas,
):
# Join all the sentence text
sentence_text = " ".join(
[word_with_meta["text"] for word_with_meta in sentence_with_word_metas]
).strip()

# Make sure the first letter is capitalized
# NOTE: we cannot use the `capitalize` string function
# because it will lowercase the rest of the text
sentence_text = sentence_text[0].upper() + sentence_text[1:]

# Create the sentence object
structured_sentences.append(
transcript_model.Sentence(
index=sent_index,
confidence=self.confidence,
start_time=sentence_with_word_metas[0]["start"],
end_time=sentence_with_word_metas[-1]["end"],
text=" ".join(
[
word_with_meta["text"]
for word_with_meta in sentence_with_word_metas
]
)
.strip()
.capitalize(),
text=sentence_text,
words=[
transcript_model.Word(
index=word_index,
Expand Down

0 comments on commit e9517b4

Please sign in to comment.