[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/subed a66d2206ee 6/9: New command subed-wpm calculates wor
|
From: |
ELPA Syncer |
|
Subject: |
[nongnu] elpa/subed a66d2206ee 6/9: New command subed-wpm calculates words per minute |
|
Date: |
Sat, 25 Nov 2023 16:00:55 -0500 (EST) |
branch: elpa/subed
commit a66d2206ee93259e939c78acbcc8b8cc28f9780a
Author: Sacha Chua <sacha@sachachua.com>
Commit: Sacha Chua <sacha@sachachua.com>
New command subed-wpm calculates words per minute
* subed/subed-common.el (subed-wpm): New command.
---
subed/subed-common.el | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/subed/subed-common.el b/subed/subed-common.el
index aa8c150fb2..017e3af542 100644
--- a/subed/subed-common.el
+++ b/subed/subed-common.el
@@ -1980,6 +1980,30 @@ if PRINT-MESSAGE is non-nil, display a message."
'after-string
(propertize (format " %.1f CPS" cps) 'face 'shadow 'display '(height
0.9)))))))
+(defun subed-wpm (&optional subtitles)
+ "Display words per minute.
+Use SUBTITILES if specified."
+ (interactive)
+ (setq subtitles (or subtitles (subed-subtitle-list)))
+ (let (word-count
+ (minutes
+ (/ (apply '+ (mapcar (lambda (o) (- (elt o 2) (elt o 1))) subtitles))
+ 60000.0)))
+ (with-temp-buffer
+ (insert
+ (mapconcat (lambda (o)
+ (replace-regexp-in-string "</?[^>]+>" "" (elt o 3)))
+ subtitles
+ " "))
+ (setq word-count (count-words (point-min) (point-max))))
+ (if (called-interactively-p 'any)
+ (message
+ "%d wpm (%d words / %.1f minutes)"
+ (/ (* 1.0 word-count) minutes)
+ word-count
+ minutes)
+ (/ (* 1.0 word-count) minutes))))
+
;;; Trimming overlaps
(defun subed--identify-overlaps ()
- [nongnu] elpa/subed updated (c9e3ec9963 -> 774e5b3f07), ELPA Syncer, 2023/11/25
- [nongnu] elpa/subed b1ad383ea8 5/9: subed-vtt: iterating shouldn't get confused by blank lines at end, ELPA Syncer, 2023/11/25
- [nongnu] elpa/subed a66d2206ee 6/9: New command subed-wpm calculates words per minute,
ELPA Syncer <=
- [nongnu] elpa/subed 774e5b3f07 9/9: subed-vtt: Handle subtitles with short timestamps and comments, ELPA Syncer, 2023/11/25
- [nongnu] elpa/subed 6812364955 1/9: test-subed-common.el: Clean up duplicated sexps, ELPA Syncer, 2023/11/25
- [nongnu] elpa/subed 63bd6a83a4 2/9: Add tests, ELPA Syncer, 2023/11/25
- [nongnu] elpa/subed 10b85e48a0 7/9: subed-vtt: Improve ID and comment handling, ELPA Syncer, 2023/11/25
- [nongnu] elpa/subed cea86bccd0 3/9: New hook: subed-subtitle-merged-hook, ELPA Syncer, 2023/11/25
- [nongnu] elpa/subed 8acbd46e54 8/9: Add subed-jump-to-subtitle-start-pos and related function., ELPA Syncer, 2023/11/25
- [nongnu] elpa/subed 430ba0334f 4/9: subed-for-each-subtitle: handle WebVTT header, ELPA Syncer, 2023/11/25