//  [python]
def infer_from_audio_for_realtime(self, audio, sr, key, spk_id=1, spk_mix_dict=None, aug_shift=0,
                                      infer_speedup=10, method='dpm-solver', k_step=None, use_tqdm=True,
                                      spk_emb=None, silence_front=0, diff_jump_silence_front=False, threhold=-60,
                                      index_ratio=0, use_hubert_mask=False):

        start_frame = int(silence_front * self.vocoder.vocoder_sample_rate / self.vocoder.vocoder_hop_size)
        audio_t = torch.from_numpy(audio).float().unsqueeze(0).to(self.device)

        if self.naive_model is None:
            print(" [INFO] No combo_model or naive_model, diffusion without shallow-model.")
        else:
            assert k_step is not None
            print(" [INFO] Shallow Diffusion mode!")

        key_str = str(sr)
        if key_str not in self.resample_dict_16000:
            self.resample_dict_16000[key_str] = Resample(sr, 16000, lowpass_filter_width=128).to(self.device)
        if int(sr) != 16000:
            audio_t_16k = self.resample_dict_16000[key_str](audio_t)
        else:
            audio_t_16k = audio_t

        volume, mask = self.extract_volume_and_mask(audio, sr, threhold=float(threhold))
        if use_hubert_mask:
            mask16k = mask.clone().unsqueeze(0).unsqueeze(0)
            mask16k = torch.nn.functional.interpolate(mask16k, size=tuple(audio_t_16k.shape), mode='nearest')
            mask16k = ~(mask16k.squeeze(0).squeeze(0).bool())
        else:
            mask16k = None
        units = self.encode_units(audio_t_16k, sr=16000, padding_mask=mask16k)
        if index_ratio > 0:
            units = self.units_indexer(units_t=units, spk_id=spk_id, ratio=index_ratio)
        f0 = self.extract_f0(audio, key=key, sr=sr, silence_front=silence_front)

        if diff_jump_silence_front:
            audio_t = audio_t[:, start_frame * self.vocoder.vocoder_hop_size:]
            f0 = f0[:, start_frame:, :]
            units = units[:, start_frame:, :]
            volume = volume[:, start_frame:, :]

        if k_step is not None:
            k_step = int(k_step)
            if (k_step >= 1000) or (k_step <= 0):
                k_step = 300
                print(f" [WARN] k_step must < 1000 and > 0, now set to {k_step}")
            if self.args.model.k_step_max is not None:
                k_step_max = int(self.args.model.k_step_max)
                if k_step > k_step_max:
                    print(f" [WARN] k_step must <= k_step_max={k_step_max}, not k_step set to{k_step_max}.")
                    k_step = k_step_max
            if int(k_step/infer_speedup) < 3:
                infer_speedup = int(k_step/4)
                print(f" [WARN] diffusion step must > 4 (3 when qndm), not set to{infer_speedup}")
            if self.naive_model is not None:
                gt_spec = self.naive_model_call(units, f0, volume, spk_id=spk_id, spk_mix_dict=spk_mix_dict,
                                                aug_shift=aug_shift, spk_emb=spk_emb)
            else:
                gt_spec = self.vocoder.extract(audio_t, self.args.data.sampling_rate)
                gt_spec = torch.cat((gt_spec, gt_spec[:, -1:, :]), 1)

        else:
            gt_spec = None

        out_mel = self.__call__(units, f0, volume, spk_id=spk_id, spk_mix_dict=spk_mix_dict, aug_shift=aug_shift,
                                gt_spec=gt_spec, infer_speedup=infer_speedup, method=method, k_step=k_step,
                                use_tqdm=use_tqdm, spk_emb=spk_emb)

        if diff_jump_silence_front:
            out_wav = self.mel2wav(out_mel, f0)
        else:
            out_wav = self.mel2wav(out_mel, f0, start_frame=start_frame)
            out_wav *= mask
        return out_wav.squeeze(), self.args.data.sampling_rate