(self, config, input_info, has_vfi_model, has_vsr_model)
| 36 | self.init_recorder() |
| 37 | self.init_reader(model_runner) |
| 38 | |
| 39 | def init_base(self, config, input_info, has_vsr_model): |
| 40 | self.stream_config = input_info.stream_config |
| 41 | logger.info(f"VAController init base with stream config: {self.stream_config}") |
| 42 | self.audio_path = input_info.audio_path |
| 43 | self.output_video_path = input_info.save_result_path |
| 44 | if isinstance(self.output_video_path, dict): |
| 45 | self.output_video_path = self.output_video_path["data"] |
| 46 | |
| 47 | self.audio_sr = config.get("audio_sr", 16000) |
| 48 | self.target_fps = config.get("fps", 16) |
| 49 | self.max_num_frames = get_input_value(config, "num_frames", 81) |
| 50 | self.prev_frame_length = config.get("prev_frame_length", 5) |
| 51 | |
| 52 | self.record_fps = config.get("record_fps", self.target_fps) |
| 53 | |
| 54 | self.tgt_h = input_info.size[0] |
| 55 | self.tgt_w = input_info.size[1] |
| 56 | self.record_h, self.record_w = self.tgt_h, self.tgt_w |
| 57 | if "video_super_resolution" in config and has_vsr_model: |
| 58 | _, _, self.record_w, self.record_h = compute_scaled_and_target_dims( |
| 59 | self.record_w, |
| 60 | self.record_h, |
| 61 | scale=config["video_super_resolution"]["scale"], |
| 62 | multiple=128, |
| 63 | ) |
| 64 | |
| 65 | # how many frames to publish stream as a batch |
| 66 | self.slice_frame = config.get("slice_frame", self.prev_frame_length) |
| 67 | # estimate the max infer seconds, for immediate switch with local omni |
| 68 | slice_interval = max(1e-5, self.slice_frame / self.record_fps) |
| 69 | |
| 70 | est_max_infer_secs = config.get("est_max_infer_secs", 0.6) |
| 71 | est_max_switch_image_secs = config.get("est_max_switch_image_secs", 0) |
| 72 | est_max_switch_action_secs = config.get("est_max_switch_action_secs", 0) |
| 73 | |
| 74 | self.est_infer_end_idx = math.ceil(est_max_infer_secs / slice_interval) |
| 75 | self.est_switch_image_end_idx = math.ceil(est_max_switch_image_secs / slice_interval) |
| 76 | self.est_switch_action_end_idx = math.ceil(est_max_switch_action_secs / slice_interval) |
| 77 | |
| 78 | max_end_idx = max(self.est_infer_end_idx, self.est_switch_image_end_idx, self.est_switch_action_end_idx) |
| 79 | self.min_stay_queue_num = max_end_idx * 2 + 1 |
| 80 | |
| 81 | # for seko_talk_ar, the audio_sr is the same as the sample_rate |
| 82 | self.is_seko_talk_ar = config.get("model_cls") == "seko_talk_ar" |
| 83 | if self.is_seko_talk_ar: |
| 84 | self.latent_per_chunk = config["ar_config"]["num_frame_per_chunk"] |
| 85 | self.audio_window_secs = config.get("audio_window", 1.0) |
no test coverage detected