Emacs Part 39at UNIX
Emacs Part 39 - 暇つぶし2ch437:名無しさん@お腹いっぱい。
12/01/02 20:06:07.02
emacs に喋らせたくて google 翻訳使ったのを作ったんだけど、日本語含むのがちゃんと動かない。
url-hexify-string の中で encode-coding-string utf-8 してるから問題ないと思ったんだけど何が不味いんだろう。
助言をください・・・

(require 'url-http)
(defvar speech-default-language "en"
"デフォルトの言語。")
(defvar speech-sound-player "cmd /c start %s"
"mp3音声再生プログラム。%s にファイル名が入る。") ;; windows 向け設定

(defun speech-message (text &optional lang)
"指定された文章を音声再生する。"
(interactive "sMessage: ")
(let ((coding-system-for-read 'binary)
(coding-system-for-write 'binary)
temp-file)
(with-current-buffer
(url-retrieve-synchronously
(format "URLリンク(translate.google.com)"
(or lang speech-default-language)
(url-hexify-string text)))
(set-buffer-multibyte nil)
(setq temp-file (make-temp-file "speech-" nil ".mp3"))
(write-region (point-min) (point-max) temp-file nil 'silent)
(apply 'start-process "player" nil
(split-string (format speech-sound-player temp-file))))))

;; 以下を評価でしゃべる
(speech-message "a happy new year!")
(speech-message "a happy new year!" "ja") ;; 言語指定
(speech-message "あけましておめでとうございます" "ja") ;; 動作がおかしい...


次ページ
続きを表示
1を表示
最新レス表示
レスジャンプ
類似スレ一覧
スレッドの検索
話題のニュース
おまかせリスト
オプション
しおりを挟む
スレッドに書込
スレッドの一覧
暇つぶし2ch