Voice synthesis, part 1
Posted: Tue Mar 29, 2011 5:18 am
Some commercial dedicated chess computers first offered voice output of moves some thirty years ago and this feature can be found on some of today's units.
Naturally, I had to have this feature in my program. But first I had to code a routine that generated the long text form of the move suitable for input to a voice synthesizer.
At the time back in 1987 or so, I bought a dedicated voice synthesizer based on a 2 MHz Mosfet 6502 microprocessor with an 8 KB program. The unit connected via a 9,600 bps serial link to the machine running the chess program. The synthesizer wasn't very sophisticated, so the long text form of a move had to be encoded using phoneme codes instead of pure ASCII English text. Today's synthesizers are much better and the phoneme codes aren't needed for casual work.
Here's the main long text move encoding routine form the new CIL toolkit:
For the position BWTC.0907:
[D]6n1/5P1k/7p/np4b1/3B4/1pP4P/5PP1/1b4K1 w - - 0 1
Naturally, I had to have this feature in my program. But first I had to code a routine that generated the long text form of the move suitable for input to a voice synthesizer.
At the time back in 1987 or so, I bought a dedicated voice synthesizer based on a 2 MHz Mosfet 6502 microprocessor with an 8 KB program. The unit connected via a 9,600 bps serial link to the machine running the chess program. The synthesizer wasn't very sophisticated, so the long text form of a move had to be encoded using phoneme codes instead of pure ASCII English text. Today's synthesizers are much better and the phoneme codes aren't needed for casual work.
Here's the main long text move encoding routine form the new CIL toolkit:
Code: Select all
(defun encode-move-longtext-aux (my-stream my-move)
"Encode the long text form of a non-null, non-void chess move on a stream."
(let*
(
(frsq (move-frsq my-move))
(tosq (move-tosq my-move))
(frman (move-frman my-move))
(toman (move-toman my-move))
(msc (move-msc my-move))
(good (move->mover my-move))
(evil (other-color good))
)
(cond
;
; Regular move
;
((is-msc-regular? msc)
(fmt-strings my-stream "The " (man->longtext frman) " at square " (sq->string frsq))
(if (is-man-vacant? toman)
(fmt-strings my-stream " moves to square " (sq->string tosq))
(fmt-strings my-stream " captures the " (man->longtext toman) " at square " (sq->string tosq))))
;
; En passant move
;
((is-msc-en-passant? msc)
(fmt-strings my-stream
"The " (man->longtext frman) " at square " (sq->string frsq)
" moves to square " (sq->string tosq)
" and captures the " (man->longtext (color->pawn evil))
" at square " (sq->string (calc-ep-victim-sq good tosq))
" en passant"))
;
; Castling move
;
((is-msc-castling? msc)
(fmt-strings my-stream (player->string good) " castles " (flank->string (msc->castling-flank msc))))
;
; Promotion move
;
((is-msc-promotion? msc)
(fmt-strings my-stream "The " (man->longtext frman) " at square " (sq->string frsq))
(if (is-man-vacant? toman)
(fmt-strings my-stream " moves to square " (sq->string tosq))
(fmt-strings my-stream " captures the " (man->longtext toman) " at square " (sq->string tosq)))
(fmt-strings my-stream " and promotes to a " (piece->string (prom->piece (msc->prom msc)))))
;
(t
(error "encode-move-longtext-aux: bad msc: ~S" msc)))
;
; Stalemates, checkmates, and checks
;
(cond
((is-move-marked-stalemate? my-move)
(fmt-string my-stream " giving stalemate"))
((is-move-marked-checkmate? my-move)
(fmt-string my-stream " giving checkmate"))
((is-move-marked-check? my-move)
(fmt-string my-stream " giving check"))
(t
nil))
;
; Final stop
;
(fmt-string my-stream "."))
(values))
[D]6n1/5P1k/7p/np4b1/3B4/1pP4P/5PP1/1b4K1 w - - 0 1
Code: Select all
* (setf p (string->pos "6n1/5P1k/7p/np4b1/3B4/1pP4P/5PP1/1b4K1 w - - 0 1"))
6n1/5P1k/7p/np4b1/3B4/1pP4P/5PP1/1b4K1 w - - 0 1
* (setf ml (generate-canonical p))
(Ba7 Bb6 Bc5 Be3 Be5 Bf6 Bg7 Bh8 Kf1 Kh1 Kh2 c4 f3 f4 f8=B f8=N# f8=Q f8=R fxg8=B+ fxg8=N fxg8=Q+ fxg8=R g3 g4 h4)
* (dolist (move ml) (format t "~A~%" (move->longtext move)))
The white bishop at square d4 moves to square a7.
The white bishop at square d4 moves to square b6.
The white bishop at square d4 moves to square c5.
The white bishop at square d4 moves to square e3.
The white bishop at square d4 moves to square e5.
The white bishop at square d4 moves to square f6.
The white bishop at square d4 moves to square g7.
The white bishop at square d4 moves to square h8.
The white king at square g1 moves to square f1.
The white king at square g1 moves to square h1.
The white king at square g1 moves to square h2.
The white pawn at square c3 moves to square c4.
The white pawn at square f2 moves to square f3.
The white pawn at square f2 moves to square f4.
The white pawn at square f7 moves to square f8 and promotes to a bishop.
The white pawn at square f7 moves to square f8 and promotes to a knight giving checkmate.
The white pawn at square f7 moves to square f8 and promotes to a queen.
The white pawn at square f7 moves to square f8 and promotes to a rook.
The white pawn at square f7 captures the black knight at square g8 and promotes to a bishop giving check.
The white pawn at square f7 captures the black knight at square g8 and promotes to a knight.
The white pawn at square f7 captures the black knight at square g8 and promotes to a queen giving check.
The white pawn at square f7 captures the black knight at square g8 and promotes to a rook.
The white pawn at square g2 moves to square g3.
The white pawn at square g2 moves to square g4.
The white pawn at square h3 moves to square h4.