一月半以上バグ発見!!がなかったのに、なんでこの土壇場でふたつも連続しますかねぇ ;_;
ひとつはなんとかリカバーできたけど、もうひとつは(直し方は完璧にわかっているのだけど)時間切れでアウト。う〜〜、こういうときって、本当にソフト屋さんがうらやましいぞ。
ま、このタイミングで発覚したのは不幸中の幸いというか、ちょーラッキーかも。一週間遅かったら大変な騒ぎだっただろうな。
というわけで、日記書く暇がなかったから今日の日記は今週のまとめ、みたいな感じ。
そういえば、火曜日(1月23日)にダン抜糸済。今週末にはシャンプしないと、すでに毛がへろへろしている。ちょっと臭くなってきたしね。
(defvar my-pronunciation-dir "~/WyabdcRealPeopleTTS"
"*WyabdcRealPeopleTTS を展開したディレクトリ名。")
(defvar my-pronunciation-command 'play-sound-file)
"*音声を出力する関数 or コマンドを指定する。
symbol => 関数 (とりあえず引数なしのみ) (ex. 'play-sound-file)
string => コマンド名 (ex. \"fiber\")
list => '(コマンド名 引数1 引数2 ...) (ex. '(\"play\" \"-v\" \"30\"))")
(defun my-pronunciation-word-at-point-or-region (&optional string)
"カーソル位置の単語、あるいは入力した単語の音声ファイルを再生する。
音声ファイルは \"WyabdcRealPeopleTTS\" のみ対応。
SDIC または lookup があるとなお良い。"
(interactive)
(let* ((original (downcase
(or string
(and (or (and (boundp 'mark-active) mark-active)
(and (fboundp 'region-exists-p) (region-exists-p)))
(let ((word (buffer-substring-no-properties
(region-beginning) (region-end))))
(japanese-hankaku word)
word))
(and (or (fboundp 'sdic-read-from-minibuffer)
(and (locate-library "sdic")
(require 'sdic)))
(sdic-read-from-minibuffer nil "(pronunciation)"))
(progn
(or (fboundp 'lookup-current-word)
(and (locate-library "lookup")
(require 'lookup)))
(read-from-minibuffer "(pronunciation) Input: "
(and (fboundp 'lookup-current-word)
(lookup-current-word))
nil nil
(and (boundp 'lookup-input-history)
'lookup-input-history))))))
stems word file)
(unless (and my-pronunciation-dir
(file-exists-p my-pronunciation-dir)
(file-directory-p my-pronunciation-dir))
(error "Error: illegal my-pronunciation-dir"))
(when (string-match "[ \t]*\\([^ \t]+\\)" original)
(setq original (match-string 1 original)))
(setq stems (cons original
(and (or (fboundp 'stem-english)
(and (or (locate-library "stem")
(locate-library "stem-english"))
(require 'stem)))
(nreverse (delete original (stem-english original))))))
(setq file
(catch 'play
(while (setq word (car stems))
(setq stems (cdr stems))
(setq file (expand-file-name (concat word ".wav")
(expand-file-name (substring word 0 1)
my-pronunciation-dir)))
(when (and (file-exists-p file) (file-readable-p file))
(throw 'play file)))))
(if (not file)
(message "Not exist: %s" original)
(if (string= word original)
(message "Pronunciation Play: %s" word)
(message "Pronunciation Play: %s => %s" original word))
(cond
((symbolp my-pronunciation-command)
(funcall my-pronunciation-command file))
((stringp my-pronunciation-command)
(start-process "*my-pronunciation*" nil my-pronunciation-command file))
((and (listp my-pronunciation-command)
(stringp (car my-pronunciation-command)))
(apply 'start-process "*my-pronunciation*" nil
(car my-pronunciation-command)
(append (cdr my-pronunciation-command) (list file))))
(t
(error "Error: illegal my-pronunciation-command"))))
(cons original word)))
適当に global-map にバインドしたり、sdic-mode-map にバインドしたりして OK。その後も(気分転換のために)おれさま仕様で改造を続けている。大体終わったと思うのでチェックしたら出しますね。特に、自分では設定していない(使っていない)モードは危ないような気がする。