Created
March 31, 2012 07:26
-
-
Save ryseto/2260412 to your computer and use it in GitHub Desktop.
Speaking a selected region in Japanese (Emacs+OSX)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun MyTool-speech-region-Kyoko () | |
"Convert text to audible speech by /usr/bin/say of OSX." | |
(interactive) | |
(let ((str (concat (buffer-substring-no-properties (point) (mark))))) | |
(setq str (replace-regexp-in-string "\\\\%" "percent" str)) | |
(setq str (replace-regexp-in-string "%\n" "" str)) | |
(setq str (replace-regexp-in-string "\\%[^\n]+" "" str)) | |
(setq str (replace-regexp-in-string "%" "" str)) | |
(setq str (replace-regexp-in-string "\\\\[a-zA-Z]+" " " str)) | |
(setq str (replace-regexp-in-string "[$_^\n()~{}|;]" " " str)) | |
(setq str (replace-regexp-in-string "\\ +" " " str)) | |
(message str) | |
(if (eq (process-status "speech") 'run) | |
(delete-process "speech")) | |
(process-kill-without-query | |
(start-process-shell-command "speech" nil | |
"/usr/bin/say -v Kyoko" (concat "\"" str "\"" ))))) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment