Hi,

Here's a funny codelet.
When you call M-x mac-speak-buffer (region), Emacs speaks buffer  
contents.

Cheers,
Seiji


;; Text-to-Speech functions

(defvar mac-speech-process nil
   "The process object for text-to-speech subprocess.")

(defun mac-speak-buffer ()
   "Speak buffer contents."
   (interactive)
   (mac-speak-region (point-min)(point-max)))

(defun mac-speak-region (beg end)
   "Speak the region contents."
   (interactive "r")
   (mac-stop-speaking)
   (let ((buffer-file-coding-system 'utf-8-unix)
         (tmp-file (expand-file-name
                    "speech.text"
                    (if (featurep 'carbon-emacs-package)
                        (carbon-emacs-package-tmpdir) "/tmp")
                    )))
     (write-region beg end tmp-file nil)
     (message "Invoking text-to-speech...")
     (setq mac-speech-process
           (start-process "text-to-speech" "*Text-to-Speech Output*"
                          "/usr/bin/say" "-f" tmp-file))
     ))

(defun mac-stop-speaking ()
   "Terminate the text-to-speech subprocess."
   (interactive)
   (let ((mybuffer (and mac-speech-process
                        (process-buffer mac-speech-process))))
     (when (buffer-live-p mybuffer)
       (kill-buffer mybuffer)
       (beep))
     ))


;; end


--~--~---------~--~----~------------~-------~--~----~
"Carbon Emacs" group mailing list.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/carbon-emacs?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to