2022-09-28 01:57:08 +01:00
|
|
|
import argparse
|
2024-01-04 23:45:37 +01:00
|
|
|
from faster_whisper import available_models
|
|
|
|
from .main import process
|
|
|
|
from .utils.convert import str2bool, str2timeinterval
|
2022-09-28 01:57:08 +01:00
|
|
|
|
|
|
|
def main():
|
|
|
|
parser = argparse.ArgumentParser(
|
|
|
|
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
|
|
|
|
parser.add_argument("video", nargs="+", type=str,
|
|
|
|
help="paths to video files to transcribe")
|
2024-01-04 23:45:37 +01:00
|
|
|
parser.add_argument("--audio_channel", default="0",
|
|
|
|
type=int, help="audio channel index to use")
|
|
|
|
parser.add_argument("--sample_interval", type=str2timeinterval, default=None,
|
|
|
|
help="generate subtitles for a specific fragment of the video (e.g. 01:02:05-01:03:45)")
|
2022-09-28 01:57:08 +01:00
|
|
|
parser.add_argument("--model", default="small",
|
2024-01-04 23:45:37 +01:00
|
|
|
choices=available_models(), help="name of the Whisper model to use")
|
2022-09-28 01:57:08 +01:00
|
|
|
parser.add_argument("--output_dir", "-o", type=str,
|
|
|
|
default=".", help="directory to save the outputs")
|
2022-10-05 23:55:41 +08:00
|
|
|
parser.add_argument("--output_srt", type=str2bool, default=False,
|
|
|
|
help="whether to output the .srt file along with the video files")
|
|
|
|
parser.add_argument("--srt_only", type=str2bool, default=False,
|
|
|
|
help="only generate the .srt file and not create overlayed video")
|
2024-01-04 23:45:37 +01:00
|
|
|
parser.add_argument("--beam_size", type=int, default=5,
|
|
|
|
help="model parameter, tweak to increase accuracy")
|
|
|
|
parser.add_argument("--no_speech_threshold", type=float, default=0.6,
|
|
|
|
help="model parameter, tweak to increase accuracy")
|
|
|
|
parser.add_argument("--condition_on_previous_text", type=str2bool, default=True,
|
|
|
|
help="model parameter, tweak to increase accuracy")
|
2022-09-28 01:57:08 +01:00
|
|
|
parser.add_argument("--task", type=str, default="transcribe", choices=[
|
|
|
|
"transcribe", "translate"], help="whether to perform X->X speech recognition ('transcribe') or X->English translation ('translate')")
|
2023-03-10 19:55:06 +01:00
|
|
|
parser.add_argument("--language", type=str, default="auto", choices=["auto","af","am","ar","as","az","ba","be","bg","bn","bo","br","bs","ca","cs","cy","da","de","el","en","es","et","eu","fa","fi","fo","fr","gl","gu","ha","haw","he","hi","hr","ht","hu","hy","id","is","it","ja","jw","ka","kk","km","kn","ko","la","lb","ln","lo","lt","lv","mg","mi","mk","ml","mn","mr","ms","mt","my","ne","nl","nn","no","oc","pa","pl","ps","pt","ro","ru","sa","sd","si","sk","sl","sn","so","sq","sr","su","sv","sw","ta","te","tg","th","tk","tl","tr","tt","uk","ur","uz","vi","yi","yo","zh"],
|
|
|
|
help="What is the origin language of the video? If unset, it is detected automatically.")
|
2022-09-28 01:57:08 +01:00
|
|
|
|
|
|
|
args = parser.parse_args().__dict__
|
|
|
|
|
2024-01-04 23:45:37 +01:00
|
|
|
process(args)
|
2022-09-28 01:57:08 +01:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
main()
|