In Automatic Speech Recognition (ASR) systems, a critical deployment metric is the Real-Time Factor (RTF), which measures how fast the system transcribes audio relative to the audio's actual duration. An RTF below 1.0 means the system transcribes faster than real-time.
A common approach to speed up transcription of long audio files is chunked parallel processing: the audio is divided into sequential chunks, and multiple worker processes transcribe different chunks simultaneously.
Implement a function asr_parallel_rtf(audio_duration, chunk_times, num_workers) that computes transcription performance metrics.
Input:
audio_duration: A float representing the total audio length in secondschunk_times: A list of floats, where each element is the processing time (in seconds) that a given chunk takes to transcribe. Chunks are ordered sequentially.num_workers: An integer specifying the number of parallel transcription workers availableOutput: A dictionary with four keys:
'sequential_rtf': The RTF if all chunks were processed one after another by a single worker'parallel_rtf': The RTF when chunks are dispatched to parallel workers in order, with each batch of workers running concurrently'speedup': The ratio of total sequential processing time to total parallel wall-clock time'is_realtime': A boolean indicating whether the parallel RTF is strictly less than 1.0All float values in the output should be rounded to 4 decimal places.
Notes:
num_workers chunks form the first batch, next num_workers form the second batch, etc.)num_workers