def process_realtime_word_dict()

in function_app/src/components/speech.py [0:0]


def process_realtime_word_dict(word_dict: Dict, offset_id: int) -> TranscribedWord:
    """
    Processes a word dictionary from the Azure AI Speech Real-time 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.REALTIME]
    return TranscribedWord(
        offset_id=offset_id,
        display_text=word_dict["Word"],
        start_secs=word_dict["Offset"] / time_divisor,
        duration_secs=word_dict["Duration"] / time_divisor,
        end_secs=(word_dict["Offset"] + word_dict["Duration"]) / time_divisor,
    )