in function_app/src/components/speech.py [0:0]
def process_aoai_whisper_transcription(transcription: Dict) -> Transcription:
"""
Processes a transcription response from Azure OpenAI Whisper.
:param transcription: The raw API response from Azure OpenAI Whisper.
:type transcription: Dict
:return: A processed Transcription object.
:rtype: Transcription
"""
processed_phrases: list[TranscribedPhrase] = list()
for phrase_num, raw_phrase in enumerate(transcription["segments"]):
# TODO: Align phrase and segment values
processed_phrases.append(
process_whisper_phrase_dict(raw_phrase, phrase_num, list())
)
return Transcription(
phrases=processed_phrases,
transcription_type=AzureSpeechTranscriptionEnum.AOAI_WHISPER,
duration_secs=round(transcription["duration"], 3),
language=transcription.get("language", None),
raw_api_response=transcription,
)