Implement a function that calculates the maximum number of concurrent real-time Text-to-Speech (TTS) audio streams a serving system can support, given hardware and network constraints.
A TTS server must generate audio at least as fast as it is consumed (played back). The system is constrained by three resources: compute (GPU processing power), memory (GPU VRAM), and network bandwidth.
Your function receives:
rtf (float): Real-Time Factor per stream on one GPU. This is the ratio of compute time to audio duration. For example, rtf=0.4 means generating 1 second of audio requires 0.4 seconds of GPU compute.num_gpus (int): Number of GPUs available for serving.mem_per_stream_mb (float): GPU memory required per active concurrent stream (model state, decoder buffers, etc.) in megabytes.total_gpu_mem_mb (float): Total GPU memory available across all GPUs in megabytes.audio_bitrate_kbps (float): Output audio bitrate per stream in kilobits per second.total_bandwidth_mbps (float): Total available outbound network bandwidth in megabits per second (1 Mbps = 1000 kbps).Return a dictionary with:
compute_capacity (int): Maximum streams supportable by compute alonememory_capacity (int): Maximum streams supportable by memory alonebandwidth_capacity (int): Maximum streams supportable by bandwidth alonemax_concurrent_streams (int): The actual maximum concurrent streams (limited by the tightest constraint)bottleneck (str): The name of the limiting resource - one of "compute", "memory", or "bandwidth". If multiple resources tie, report the one that appears first in the order: compute, memory, bandwidth.