[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/subed 0da75a60d6 2/3: subed-align: Add subed-align-options
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/subed 0da75a60d6 2/3: subed-align: Add subed-align-options variable |
Date: |
Wed, 16 Nov 2022 18:59:29 -0500 (EST) |
branch: elpa/subed
commit 0da75a60d637d883cfe4896c90803591e7f1b979
Author: Sacha Chua <sacha@sachachua.com>
Commit: Sacha Chua <sacha@sachachua.com>
subed-align: Add subed-align-options variable
* subed/subed-align.el (subed-common): Add require.
(subed-align-options): New variable.
(subed-align): Use subed-align-options if specified. Trim overlaps if
needed.
---
subed/subed-align.el | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/subed/subed-align.el b/subed/subed-align.el
index 2ef76c3961..b096d59323 100644
--- a/subed/subed-align.el
+++ b/subed/subed-align.el
@@ -28,12 +28,18 @@
;;
;;; Code:
+(require 'subed-common)
+
(defvar subed-align-command '("python3" "-m" "aeneas.tools.execute_task")
"Command to run aeneas.")
(defvar subed-align-language "eng"
"Language code.")
+(defvar subed-align-options nil
+ "Other options to include in the aeneas invocation.
+Ex:
task_adjust_boundary_nonspeech_min=0.500|task_adjust_boundary_nonspeech_string=REMOVE")
+
;;;###autoload
(defun subed-align (audio-file text-file format)
"Align AUDIO-FILE with TEXT-FILE to get timestamps.
@@ -72,17 +78,19 @@ Return a buffer with FORMAT."
(append (cdr subed-align-command)
(list (expand-file-name audio-file)
(or temp-file (expand-file-name text-file))
- (format
"task_language=%s|os_task_file_format=%s|is_text_type=%s"
+ (format
"task_language=%s|os_task_file_format=%s|is_text_type=%s%s"
subed-align-language
(downcase format)
(if temp-file
"subtitles"
- "plain"))
+ "plain")
+ (if subed-align-options (concat "|"
subed-align-options) ""))
new-file)))
(when temp-file (delete-file temp-file))
(find-file new-file)
- (when (string= format "VTT")
- (goto-char (point-min))
+ (when (derived-mode-p 'subed-mode)
+ (subed-trim-overlaps))
+ (when (derived-mode-p 'subed-vtt-mode)
(flush-lines "^[0-9]+$")))))
(provide 'subed-align)