mirror of
https://github.com/karl0ss/bazarr-ai-sub-generator.git
synced 2025-04-26 22:59:23 +01:00
cleanup
This commit is contained in:
parent
cf3e4acc43
commit
fc1e05fce1
@ -2,8 +2,6 @@ import argparse
|
|||||||
from faster_whisper import available_models
|
from faster_whisper import available_models
|
||||||
from utils.constants import LANGUAGE_CODES
|
from utils.constants import LANGUAGE_CODES
|
||||||
from main import process
|
from main import process
|
||||||
from utils.convert import str2bool, str2timeinterval
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
"""
|
"""
|
||||||
@ -12,15 +10,20 @@ def main():
|
|||||||
Parses command line arguments, processes the inputs using the specified options,
|
Parses command line arguments, processes the inputs using the specified options,
|
||||||
and performs transcription or translation based on the specified task.
|
and performs transcription or translation based on the specified task.
|
||||||
"""
|
"""
|
||||||
|
# Create an ArgumentParser object with a specific formatter for default values
|
||||||
parser = argparse.ArgumentParser(
|
parser = argparse.ArgumentParser(
|
||||||
formatter_class=argparse.ArgumentDefaultsHelpFormatter
|
formatter_class=argparse.ArgumentDefaultsHelpFormatter
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Add argument for selecting the Whisper model
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--model",
|
"--model",
|
||||||
default="small",
|
default="small",
|
||||||
choices=available_models(),
|
choices=available_models(),
|
||||||
help="name of the Whisper model to use",
|
help="name of the Whisper model to use",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Add argument for specifying the device to use (CPU, CUDA, or auto-detect)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--device",
|
"--device",
|
||||||
type=str,
|
type=str,
|
||||||
@ -28,35 +31,24 @@ def main():
|
|||||||
choices=["cpu", "cuda", "auto"],
|
choices=["cpu", "cuda", "auto"],
|
||||||
help='Device to use for computation ("cpu", "cuda", "auto")',
|
help='Device to use for computation ("cpu", "cuda", "auto")',
|
||||||
)
|
)
|
||||||
# parser.add_argument(
|
|
||||||
# "--compute_type",
|
# Add argument for processing a single file
|
||||||
# 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.",
|
|
||||||
# )
|
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--file",
|
"--file",
|
||||||
type=str,
|
type=str,
|
||||||
default=None,
|
default=None,
|
||||||
help="Process a single file"
|
help="Process a single file"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Add argument for processing all videos in a folder
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--folder",
|
"--folder",
|
||||||
type=str,
|
type=str,
|
||||||
default=None,
|
default=None,
|
||||||
help="Process all videos in folder"
|
help="Process all videos in folder"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Add argument for specifying the task: transcribe or translate
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--show",
|
"--show",
|
||||||
type=str,
|
type=str,
|
||||||
@ -64,6 +56,8 @@ def main():
|
|||||||
help="whether to perform X->X speech recognition ('transcribe') \
|
help="whether to perform X->X speech recognition ('transcribe') \
|
||||||
or X->English translation ('translate')",
|
or X->English translation ('translate')",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Add argument for setting the origin language of the video, with auto-detection as default
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--language",
|
"--language",
|
||||||
type=str,
|
type=str,
|
||||||
@ -72,16 +66,20 @@ def main():
|
|||||||
help="What is the origin language of the video? \
|
help="What is the origin language of the video? \
|
||||||
If unset, it is detected automatically.",
|
If unset, it is detected automatically.",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Add argument for selecting the backend: whisper or faster_whisper
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--backend",
|
"--backend",
|
||||||
type=str,
|
type=str,
|
||||||
default="whisper",
|
default="whisper",
|
||||||
choices=["whisper", "faster_whisper"],
|
choices=["whisper", "faster_whisper"],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Parse the command line arguments into a dictionary
|
||||||
args = parser.parse_args().__dict__
|
args = parser.parse_args().__dict__
|
||||||
|
|
||||||
|
# Call the process function with the parsed arguments
|
||||||
process(args)
|
process(args)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user