jumon / whisper-finetuning

[WIP] Scripts for fine-tuning Whisper
MIT License
205 stars 28 forks source link

ResultWriter.__call__() missing 1 required positional argument: 'options' #15

Open jaggzh opened 1 year ago

jaggzh commented 1 year ago
    writer(result, str(audio_path))
TypeError: ResultWriter.__call__() missing 1 required positional argument: 'options' ```

From:
(Note: both those paths below are dirs)

python3 transcribe.py \ --audio-dir audio-to-transcribe \ --save-dir audio-transcribed-to-txt \ --language en \ --model models/best_model.pt

jaggzh commented 1 year ago

Oh, and thanks for this project! I'm trying to figure out the problem myself too.

jaggzh commented 1 year ago

from whisper utils.py

class WriteSRT(SubtitlesWriter):
    extension: str = "srt"
    always_include_hours: bool = True
    decimal_marker: str = ","

    def write_result(self, result: dict, file: TextIO, options: dict):
        for i, (start, end, text) in enumerate(
            self.iterate_result(result, options), start=1
        ):
            print(f"{i}\n{start} --> {end}\n{text}\n", file=file, flush=True)

and

class SubtitlesWriter(ResultWriter):
    always_include_hours: bool
    decimal_marker: str

    def iterate_result(self, result: dict, options: dict):
        raw_max_line_width: Optional[int] = options["max_line_width"]
        max_line_count: Optional[int] = options["max_line_count"]
        highlight_words: bool = options["highlight_words"]
        max_line_width = 1000 if raw_max_line_width is None else raw_max_line_width
        preserve_segments = max_line_count is None or raw_max_line_width is None

        def iterate_subtitles():