From d9d7189bd9305c35fc3f5946bf4aac5664056c6a Mon Sep 17 00:00:00 2001 From: WyattBlue Date: Tue, 27 Feb 2024 17:08:24 -0500 Subject: [PATCH] audio #:stream don't allow string literal --- auto_editor/help.py | 11 +++++------ auto_editor/lang/palet.py | 8 ++++---- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/auto_editor/help.py b/auto_editor/help.py index f67455376..e55cb23fe 100644 --- a/auto_editor/help.py +++ b/auto_editor/help.py @@ -25,16 +25,19 @@ If timebase is 30, 400 ticks to 800 means 13.33 to 26.66 seconds """.strip(), "--edit-based-on": """ -Evalutes a palet expression that returns a bool-array?. The array is then used for +Evaluates a palet expression that returns a bool-array?. The array is then used for editing. Editing Methods: - audio ; Audio silence/loudness detection - threshold threshold? : 4% - - stream (or/c nat? 'all "all") : 0 + - stream (or/c nat? 'all) : 'all - mincut nat? : 6 - minclip nat? : 3 + ; mincut is more significant, there it has a larger default value. + ; minclip gets applied first, then mincut + - motion ; Motion detection specialized for noisy real-life videos - threshold threshold? : 2% - stream nat? : 0 @@ -150,10 +153,6 @@ """.strip(), "--video-bitrate": """ `--video-bitrate` sets the target bitrate for the video encoder. It accepts the same format as `--audio-bitrate` and the special `unset` value is allowed. -""".strip(), - "--silent-threshold": """ -Silent threshold is a percentage where 0% represents absolute silence and 100% represents the highest volume in the media file. -Setting the threshold to `0%` will cut only out areas where area is absolutely silence. """.strip(), "--margin": """ Default value: 0.2s,0.2s diff --git a/auto_editor/lang/palet.py b/auto_editor/lang/palet.py index 12d759765..f93f93967 100644 --- a/auto_editor/lang/palet.py +++ b/auto_editor/lang/palet.py @@ -1470,7 +1470,7 @@ def edit_all() -> np.ndarray: def edit_audio( - threshold: float = 0.04, stream: object = "all", mincut: int = 6, minclip: int = 3 + threshold: float = 0.04, stream: object = Sym("all"), mincut: int = 6, minclip: int = 3 ) -> np.ndarray: if "@levels" not in env or "@filesetup" not in env: raise MyError("Can't use `audio` if there's no input media") @@ -1480,7 +1480,7 @@ def edit_audio( strict = env["@filesetup"].strict stream_data: NDArray[np.bool_] | None = None - if stream == "all" or stream == Sym("all"): + if stream == Sym("all"): stream_range = range(0, len(src.audios)) else: assert isinstance(stream, int) @@ -1502,7 +1502,7 @@ def edit_audio( return stream_data - stream = 0 if stream == "all" or stream == Sym("all") else stream + stream = 0 if stream == Sym("all") else stream return raise_(f"audio stream '{stream}' does not exist") if strict else levels.all() @@ -1615,7 +1615,7 @@ def my_eval(env: Env, node: object) -> Any: "none": Proc("none", edit_none, (0, 0)), "all/e": Proc("all/e", edit_all, (0, 0)), "audio": Proc("audio", edit_audio, (0, 4), - is_threshold, orc(is_nat, Sym("all"), "all"), is_nat, + is_threshold, orc(is_nat, Sym("all")), is_nat, {"threshold": 0, "stream": 1, "minclip": 2, "mincut": 2} ), "motion": Proc("motion", edit_motion, (0, 4),