Created
February 6, 2013 11:05
-
-
Save DeaR/4721934 to your computer and use it in GitHub Desktop.
このxyzzy…しゃべるぞ!
This file contains hidden or 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
; Shaberu.l | |
; 元ネタ: http://blog.supermomonga.com/articles/vim/shaberu-vim.html | |
; 棒読みちゃんを起動しておいてください | |
; http://chi.usamimi.info/Program/Application/BouyomiChan/ | |
(defconstant *shaberu-addr* "127.0.0.1") | |
(defconstant *shaberu-port* 50001) | |
(defun shaberu-say (str) | |
(with-open-stream (stream (connect *shaberu-addr* *shaberu-port*)) | |
; command | |
(write-char #\x01 stream) | |
(write-char #\x00 stream) | |
; speed | |
(write-char #\xff stream) | |
(write-char #\xff stream) | |
; tone | |
(write-char #\xff stream) | |
(write-char #\xff stream) | |
; volume | |
(write-char #\xff stream) | |
(write-char #\xff stream) | |
; voice | |
(write-char #\x00 stream) | |
(write-char #\x00 stream) | |
; encode | |
(write-char #\x02 stream) | |
; length | |
(let ((len (+ (length str) (count #\xff str :test #'char<=)))) | |
(write-char (code-char (logand #xff (ash len 0))) stream) | |
(write-char (code-char (logand #xff (ash len -8))) stream) | |
(write-char (code-char (logand #xff (ash len -16))) stream) | |
(write-char (code-char (logand #xff (ash len -24))) stream)) | |
; data | |
(format stream str))) | |
(shaberu-say "このxyzzy…しゃべるぞ!") |
Author
DeaR
commented
Feb 6, 2013
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment