| 37 | logging.info(f"Done Init model in {time.time() - tic:.1f} sec") |
| 38 | |
| 39 | def run(self): |
| 40 | for input in self.args.inputs: |
| 41 | logging.info(f"Transcribing {input}") |
| 42 | name, _ = os.path.splitext(input) |
| 43 | if utils.check_exists(name + ".md", self.args.force): |
| 44 | continue |
| 45 | |
| 46 | audio = utils.load_audio(input, sr=self.sampling_rate) |
| 47 | speech_array_indices = self._detect_voice_activity(audio) |
| 48 | transcribe_results = self._transcribe(input, audio, speech_array_indices) |
| 49 | |
| 50 | output = name + ".srt" |
| 51 | self._save_srt(output, transcribe_results) |
| 52 | logging.info(f"Transcribed {input} to {output}") |
| 53 | self._save_md(name + ".md", output, input) |
| 54 | logging.info(f'Saved texts to {name + ".md"} to mark sentences') |
| 55 | |
| 56 | def _detect_voice_activity(self, audio) -> List[SPEECH_ARRAY_INDEX]: |
| 57 | """Detect segments that have voice activities""" |