src/Backend/src/api/adapters/google/speech_to_text_v2.py [158:268]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
                    if result.alternatives and (alternative := result.alternatives[0]):
                        for word_obj in alternative.words:
                            start_time = word_obj.start_offset
                            last_time = word_obj.end_offset
                            if (
                                depth < 2
                                and (last_time - start_time).total_seconds() >= 5.0
                            ):
                                new_transcript = await self._rerun_audio(
                                    path=path,
                                    desired=desired,
                                    start_time=start_time,
                                    last_time=last_time,
                                    phrases=phrases_id,
                                    words=words,
                                    duration=duration,
                                    i=i,
                                    depth=depth + 1,
                                    sample_rate=sample_rate,
                                    channels=channels,
                                )
                                transcript_arr.extend(new_transcript.split(" "))
                                i += 1
                            else:
                                word_data = word_obj.word
                                transcript_arr.extend(
                                    util.convert_number_to_written_text(
                                        word_data, self.language
                                    )
                                    if word_data.isdecimal()
                                    else [word_data]
                                )
                    if depth < 2 and (total_time - last_time).total_seconds() >= 5.0:
                        new_transcript = await self._rerun_audio(
                            path,
                            desired,
                            start_time=last_time,
                            last_time=total_time,
                            phrases=phrases_id,
                            words=words,
                            duration=duration,
                            i=i,
                            depth=depth + 1,
                            sample_rate=sample_rate,
                            channels=channels,
                        )
                        transcript_arr.extend(new_transcript.split(" "))
            result_transc = " ".join(transcript_arr)
        except IndexError:
            return ""
        return result_transc

    async def create_phrase_set(self, phrases: list[dict[str, typing.Any]]) -> str:
        """
        Method to build phrase set that will be used as context.
        """
        return ""

    async def delete_phrase_set(self, phrase_set_id: str) -> None:
        return

    # pylint: disable=too-many-arguments
    async def _rerun_audio(
        self,
        path: str,
        desired: str,
        start_time: datetime.timedelta,
        last_time: datetime.timedelta,
        phrases: str,
        words: list[str],
        duration: int,
        i: int,
        depth: int,
        sample_rate: int | None = None,
        channels: int | None = None,
    ) -> str:
        """
        Method to rerun portion of audio.
        """
        temp_path = await self.storage.download(path, desired)
        temp_path = await self._cut_audio(
            temp_path, desired, start_time.total_seconds(), last_time.total_seconds()
        )
        desired_name = f"{desired.replace('.wav', '')}-{i}.wav"

        new_uri = await self.storage.upload_by_file(f"cutted/{desired_name}", temp_path)
        process_result = await self.process(
            phrases_id=phrases,
            path=f"gs://{new_uri}",
            desired=desired,
            words=words,
            duration=duration,
            depth=depth,
            sample_rate=sample_rate,
            channels=channels,
            model_type="latest_short",
        )
        return process_result

    async def _cut_audio(
        self, audio_path: str, file_name: str, start_time: float, end_time: float
    ) -> str:
        """
        Cut portion of the audio.
        """
        audio_cutted = f"/{self.audio_tmp}/cutted_{file_name}"
        ffmpeg.input(audio_path).output(
            audio_cutted, **{"ss": start_time, "to": end_time}
        ).run(overwrite_output=True, quiet=True)
        os.remove(audio_path)
        return audio_cutted
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



