in function_app/src/components/speech.py [0:0]
def process_batch_word_dict(word_dict: Dict, offset_id: int) -> TranscribedWord:
"""
Processes a word dictionary from the Azure AI Speech Batch Transcription
API.
:param word_dict: The word dictionary to process.
:type word_dict: Dict
:param offset_id: The ID of the word, offset from the start of the
transcription.
:type offset_id: int
:return: A processed TranscribedWord object.
:rtype: TranscribedWord
"""
time_divisor = TIME_DIVISORS[AzureSpeechTranscriptionEnum.BATCH]
return TranscribedWord(
offset_id=offset_id,
display_text=word_dict["displayText"],
confidence=word_dict.get(
"confidence", None
), # Only returned for mono audio input
start_secs=word_dict["offsetInTicks"] / time_divisor,
duration_secs=word_dict["durationInTicks"] / time_divisor,
end_secs=(word_dict["offsetInTicks"] + word_dict["durationInTicks"])
/ time_divisor,
)