|
@@ -1,9 +1,17 @@
|
|
import argparse
|
|
import argparse
|
|
from faster_whisper import available_models
|
|
from faster_whisper import available_models
|
|
|
|
+from .utils.constants import LANGUAGE_CODES
|
|
from .main import process
|
|
from .main import process
|
|
from .utils.convert import str2bool, str2timeinterval
|
|
from .utils.convert import str2bool, str2timeinterval
|
|
|
|
|
|
|
|
+
|
|
def main():
|
|
def main():
|
|
|
|
+ """
|
|
|
|
+ Main entry point for the script.
|
|
|
|
+
|
|
|
|
+ Parses command line arguments, processes the inputs using the specified options,
|
|
|
|
+ and performs transcription or translation based on the specified task.
|
|
|
|
+ """
|
|
parser = argparse.ArgumentParser(
|
|
parser = argparse.ArgumentParser(
|
|
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
|
|
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
|
|
parser.add_argument("video", nargs="+", type=str,
|
|
parser.add_argument("video", nargs="+", type=str,
|
|
@@ -11,15 +19,18 @@ def main():
|
|
parser.add_argument("--audio_channel", default="0",
|
|
parser.add_argument("--audio_channel", default="0",
|
|
type=int, help="audio channel index to use")
|
|
type=int, help="audio channel index to use")
|
|
parser.add_argument("--sample_interval", type=str2timeinterval, default=None,
|
|
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)")
|
|
|
|
|
|
+ help="generate subtitles for a specific \
|
|
|
|
+ fragment of the video (e.g. 01:02:05-01:03:45)")
|
|
parser.add_argument("--model", default="small",
|
|
parser.add_argument("--model", default="small",
|
|
choices=available_models(), help="name of the Whisper model to use")
|
|
choices=available_models(), help="name of the Whisper model to use")
|
|
- parser.add_argument("--device", type=str, default="auto", choices=[
|
|
|
|
- "cpu", "cuda", "auto"], help="Device to use for computation (\"cpu\", \"cuda\", \"auto\")")
|
|
|
|
|
|
+ parser.add_argument("--device", type=str, default="auto",
|
|
|
|
+ choices=["cpu", "cuda", "auto"],
|
|
|
|
+ help="Device to use for computation (\"cpu\", \"cuda\", \"auto\")")
|
|
parser.add_argument("--compute_type", type=str, default="default", choices=[
|
|
parser.add_argument("--compute_type", type=str, default="default", choices=[
|
|
- "int8", "int8_float32", "int8_float16",
|
|
|
|
- "int8_bfloat16", "int16", "float16",
|
|
|
|
- "bfloat16", "float32"], help="Type to use for computation. See https://opennmt.net/CTranslate2/quantization.html.")
|
|
|
|
|
|
+ "int8", "int8_float32", "int8_float16", "int8_bfloat16",
|
|
|
|
+ "int16", "float16", "bfloat16", "float32"],
|
|
|
|
+ help="Type to use for computation. \
|
|
|
|
+ See https://opennmt.net/CTranslate2/quantization.html.")
|
|
parser.add_argument("--output_dir", "-o", type=str,
|
|
parser.add_argument("--output_dir", "-o", type=str,
|
|
default=".", help="directory to save the outputs")
|
|
default=".", help="directory to save the outputs")
|
|
parser.add_argument("--output_srt", type=str2bool, default=False,
|
|
parser.add_argument("--output_srt", type=str2bool, default=False,
|
|
@@ -32,10 +43,14 @@ def main():
|
|
help="model parameter, tweak to increase accuracy")
|
|
help="model parameter, tweak to increase accuracy")
|
|
parser.add_argument("--condition_on_previous_text", type=str2bool, default=True,
|
|
parser.add_argument("--condition_on_previous_text", type=str2bool, default=True,
|
|
help="model parameter, tweak to increase accuracy")
|
|
help="model parameter, tweak to increase accuracy")
|
|
- 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')")
|
|
|
|
- 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.")
|
|
|
|
|
|
+ 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')")
|
|
|
|
+ parser.add_argument("--language", type=str, default="auto",
|
|
|
|
+ choices=LANGUAGE_CODES,
|
|
|
|
+ help="What is the origin language of the video? \
|
|
|
|
+ If unset, it is detected automatically.")
|
|
|
|
|
|
args = parser.parse_args().__dict__
|
|
args = parser.parse_args().__dict__
|
|
|
|
|