Online Book Reader

Home Category

Beautiful Code [332]

By Root 5148 0
output to the speech server:

(defsubst tts-speak-using-voice (voice text)

"Use voice VOICE to speak text TEXT."

(unless (or (eq 'inaudible voice ) ;; not spoken if voice inaudible

(and (listp voice) (member 'inaudible voice)))

(tts-interp-queue

(format

"%s%s %s \n"

(cond

((symbolp voice)

(tts-get-voice-command

(if (boundp voice ) (symbol-value voice ) voice)))

((listp voice)

(mapconcat #'(lambda (v)

(tts-get-voice-command

(if (boundp v ) (symbol-value v ) v)))

voice

" "))

(t ""))

text tts-voice-reset-code))))

The tts-speak-using-voice function returns immediately if the specified voice is inaudible. Here, inaudible is a special personality that Emacspeak uses to prevent pieces of text from being spoken. The inaudible personality can be used to advantage when selectively hiding portions of text to produce more succinct output.

If the specified voice (or list of voices) is not inaudible, the function looks up the speech codes for the voice and queues the result of wrapping the text to be spoken between voice-code and tts-reset-code to the speech server.

31.2.5. Using Aural CSS (ACSS) for Styling Speech Output

I first formalized audio formatting within AsTeR, where rendering rules were written in a specialized language called Audio Formatting Language (AFL). AFL structured the available parameters in auditory space—e.g., the pitch of the speaking voice—into a multidimensional space, and encapsulated the state of the rendering engine as a point in this multidimensional space.

AFL provided a block-structured language that encapsulated the current rendering state by a lexically scoped variable, and provided operators to move within this structured space. When these notions were later mapped to the declarative world of HTML and CSS, dimensions making up the AFL rendering state became Aural CSS parameters, provided as accessibility measures in CSS2 (http://www.w3.org/Press/1998/CSS2-REC).

Though designed for styling HTML (and, in general, XML) markup trees, Aural CSS turned out to be a good abstraction for building Emacspeak's audio formatting layer while keeping the implementation independent of any given TTS engine.

Here is the definition of the data structure that encapsulates ACSS settings:

(defstruct acss

family gain left-volume right-volume

average-pitch pitch-range stress richness punctuations)

Emacspeak provides a collection of predefined voice overlays for use within speech extensions. Voice overlays are designed to cascade in the spirit of Aural CSS. As an example, here is the ACSS setting that corresponds to voice-monotone:

[cl-struct-acss nil nil nil nil nil 0 0 nil all]

Notice that most fields of this acss structure are nil—that is, unset. The setting creates a voice overlay that:

Sets pitch to 0 to create a flat voice.

Sets pitch-range to 0 to create a monotone voice with no inflection.

This setting is used as the value of the personality property for audio formatting comments in all programming language modes. Because its value is an overlay, it can interact effectively with other aural display properties. As an example, if portions of a comment are displayed in a bold font, those portions can have the voice-bolden personality (another predefined overlay) added; this results in setting the personality property to a list of two values: (voice-bolden voice-monotone). The final effect is for the text to get spoken with a distinctive voice that conveys both aspects of the text: namely, a sequence of words that are emphasized within a comment.

Sets punctuations to all so that all punctuation marks are spoken.

31.2.6. Adding Auditory Icons

Rich visual user interfaces contain both text and icons. Similarly, once Emacspeak had the ability to speak intelligently, the next step was to increase the bandwidth of aural communication by augmenting the output with auditory icons.

Auditory icons in Emacspeak are short sound snippets (no more than two seconds in duration) and are used to indicate frequently occurring events in the

Return Main Page Previous Page Next Page

®Online Book Reader