(app: Application, parser: QCommandLineParser)
| 50 | return all([parsed.scheme, parsed.netloc]) |
| 51 | |
| 52 | def parse(app: Application, parser: QCommandLineParser): |
| 53 | parser.addPositionalArgument("<command>", "One of the following commands:\n- add") |
| 54 | parser.parse(app.arguments()) |
| 55 | |
| 56 | args = parser.positionalArguments() |
| 57 | if len(args) == 0: |
| 58 | parser.addHelpOption() |
| 59 | parser.addVersionOption() |
| 60 | |
| 61 | parser.process(app) |
| 62 | return |
| 63 | |
| 64 | command = args[0] |
| 65 | if command == "add": |
| 66 | parser.clearPositionalArguments() |
| 67 | |
| 68 | parser.addPositionalArgument("files", "Input file paths", "[file file file...]") |
| 69 | |
| 70 | task_option = QCommandLineOption( |
| 71 | ["t", "task"], |
| 72 | f"The task to perform. Allowed: {join_values(Task)}. Default: {Task.TRANSCRIBE.value}.", |
| 73 | "task", |
| 74 | Task.TRANSCRIBE.value, |
| 75 | ) |
| 76 | model_type_option = QCommandLineOption( |
| 77 | ["m", "model-type"], |
| 78 | f"Model type. Allowed: {join_values(CommandLineModelType)}. Default: {CommandLineModelType.WHISPER.value}.", |
| 79 | "model-type", |
| 80 | CommandLineModelType.WHISPER.value, |
| 81 | ) |
| 82 | model_size_option = QCommandLineOption( |
| 83 | ["s", "model-size"], |
| 84 | f"Model size. Use only when --model-type is whisper, whispercpp, or fasterwhisper. Allowed: {join_values(WhisperModelSize)}. Default: {WhisperModelSize.TINY.value}.", |
| 85 | "model-size", |
| 86 | WhisperModelSize.TINY.value, |
| 87 | ) |
| 88 | hugging_face_model_id_option = QCommandLineOption( |
| 89 | ["hfid"], |
| 90 | 'Hugging Face model ID. Use only when --model-type is huggingface. Example: "openai/whisper-tiny"', |
| 91 | "id", |
| 92 | ) |
| 93 | language_option = QCommandLineOption( |
| 94 | ["l", "language"], |
| 95 | f'Language code. Allowed: {", ".join(sorted([k + " (" + LANGUAGES[k].title() + ")" for k in LANGUAGES]))}. Leave empty to detect language.', |
| 96 | "code", |
| 97 | "", |
| 98 | ) |
| 99 | initial_prompt_option = QCommandLineOption( |
| 100 | ["p", "prompt"], "Initial prompt.", "prompt", "" |
| 101 | ) |
| 102 | word_timestamp_option = QCommandLineOption( |
| 103 | ["w", "word-timestamps"], "Generate word-level timestamps." |
| 104 | ) |
| 105 | extract_speech_option = QCommandLineOption( |
| 106 | ["e", "extract-speech"], "Extract speech from audio before transcribing." |
| 107 | ) |
| 108 | open_ai_access_token_option = QCommandLineOption( |
| 109 | "openai-token", |
no test coverage detected