def process_fast_word_dict()

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


def process_fast_word_dict(word_dict: Dict, offset_id: int) -> TranscribedWord:
    """
    Processes a word dictionary from the Azure AI Speech Fast 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.FAST]
    return TranscribedWord(
        offset_id=offset_id,
        display_text=word_dict["text"],
        start_secs=word_dict["offset"] / time_divisor,
        duration_secs=word_dict["duration"] / time_divisor,
        end_secs=(word_dict["offset"] + word_dict["duration"]) / time_divisor,
    )