epubjs
Version:
Render ePub documents in the browser, across many devices
105 lines (101 loc) • 8.15 kB
HTML
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Tell It Like It Is: Text-to-Speech (TTS)</title>
<link rel="stylesheet" type="text/css" href="css/epub.css" />
<link rel="stylesheet" media="speech" href="css/synth.css" />
<link rel="pronunciation" href="lexicon/en.pls" type="application/pls+xml" hreflang="en" />
<link rel="pronunciation" href="lexicon/fr.pls" type="application/pls+xml" hreflang="fr" />
<meta name="dat-origPath" value="/html/body/section" /><link rel="prev" href="./ch03s03_7.html" /><link rel="next" href="./ch03s03_9.html" /></head><body>
<p data-origPath="/html/body/section/section[2]/p[18]">But there’s unfortunately no simple guideline to give in terms of finding issues.
It takes an eye for detail and an ear for possible different aural renderings.
Editors and indexers are good starting resources for the process, as they should
be able to quickly flag problem words during production so they don’t have to be
rooted out after the fact. Programs that can analyze books and report on
potentially problematic words, although not generally available, are not just a
fantasy. Their prevalence will hopefully grow now that EPUB 3 incorporates more
facilities to enhance default renderings, as they can greatly reduce the human
burden.</p>
<p data-origPath="/html/body/section/section[2]/p[19]">The only other requirement when using the SSML attributes that I haven’t touched
on is that you always have to declare the SSML namespace. I’ve omitted the
declaration from the previous examples for clarity, and because the namespace is
typically only specified once on the root <code class="literal">html</code>
element as follows:</p>
<pre class="screen" data-origPath="/html/body/section/section[2]/pre[7]"><html … xmlns:ssml="http://www.w3.org/2001/10/synthesis"></pre>
<p data-origPath="/html/body/section/section[2]/p[20]">Similar to the <code class="literal">alphabet</code> attribute, we could have
equally well attached the namespace declaration to each instance where we used
the attributes:</p>
<pre class="screen" data-origPath="/html/body/section/section[2]/pre[8]"><span
xmlns:ssml="http://www.w3.org/2001/10/synthesis"
ssml:ph="x-sampa"
…></pre>
<p data-origPath="/html/body/section/section[2]/p[21]">But that’s a verbose approach to markup, and generally only makes sense when
content is encapsulated and shared across documents, as I just noted, or
expected to be extracted into foreign playback environments where the full
document context is unavailable.</p>
<p data-origPath="/html/body/section/section[2]/p[22]">The question you may still be wondering at this point is what happens if a PLS
file contains a pronunciation rule that matches a word that is also defined by
an SSML pronunciation, how can you be sure which one wins? You don’t have to
worry, however, as the EPUB 3 specification defines a precedence rule that
states that the SSML pronunciation must be honored. There’d be no way to
override the global PLS definitions, otherwise, which would make SSML largely
useless in resolving conflicts.</p>
<p data-origPath="/html/body/section/section[2]/p[23]">But to wrap up, a final note is that there is no reason why you couldn’t make all
your improvements in SSML. It’s not the ideal way to tackle the problem, because
of the text-level recognition and tagging it requires, at least in this author’s
opinion, but it may make more sense to internal production to only use a single
technology and/or support for PLS may not prove universal (it’s too early to
know yet).</p>
<h3 class="title" id="_css3_speech" data-origPath="/html/body/section/section[3]/h3">CSS3 Speech</h3>
<p data-origPath="/html/body/section/section[3]/p[1]">You might be thinking the global definition power of PLS lexicons combined with
the granular override abilities of SSML might be sufficient to cover all cases,
so why a third technology? But you’d be only partly right.</p>
<p data-origPath="/html/body/section/section[3]/p[2]">The CSS3 Speech module is not about word pronunciation, however. It includes no
phonetic capabilities, but defines how you can use CSS style sheet technology to
control such aspects of synthetic speech rendering as the gender of voice to
use, the amount of time to pause before and after elements, when to insert aural
cues, etc.</p>
<p data-origPath="/html/body/section/section[3]/p[3]">The CSS3 Speech module also provides a simpler entry point for some basic voicing
enhancements. The ability to write X-SAMPA or IPA pronunciations requires
specialized knowledge, but the <code class="literal">speak-as</code> property
masks the complexity for some common use cases.</p>
<p data-origPath="/html/body/section/section[3]/p[4]">You could use this property to mark all acronyms that are to be spelled out
letter-by-letter, for example. If we added a class called ‘spell’ to the <code class="literal">abbr</code> elements we want spelled, as in the following
example:</p>
<pre class="screen" data-origPath="/html/body/section/section[3]/pre[1]"><abbr class="spell"><abbr class="spell">IBM</abbr></abbr></pre>
<p data-origPath="/html/body/section/section[3]/p[5]">we could then define a CSS class to indicate that each letter should be voiced
individually using the <code class="literal">spell-out</code> value:</p>
<pre class="screen" data-origPath="/html/body/section/section[3]/pre[2]">.spell {
-epub-speak-as: spell-out
}</pre>
<p data-origPath="/html/body/section/section[3]/p[6]">It’s no longer left to the rendering engine to determine whether the acronym is
“wordy” enough to attempt to voice as a word now.</p>
<aside class="note" title="Note" data-origPath="/html/body/section/section[3]/aside[1]">
<h3 class="title">Note</h3>
<p>Note that the properties are all prefixed with “-epub-” because the Speech
module was not a recommendation at the time that EPUB 3 was finalized. You
must use this prefix until the Speech module is finalized and reading
systems begin supporting the unprefixed versions.</p>
</aside>
<p data-origPath="/html/body/section/section[3]/p[7]">The <code class="literal">speak-as</code> property provides the same
functionality for numbers, ensuring they get spoken one digit at a time instead
of as a single number, something engines will not typically do by default.</p>
<pre class="screen" data-origPath="/html/body/section/section[3]/pre[3]">.digits {
-epub-speak-as: digits
}</pre>
<p data-origPath="/html/body/section/section[3]/p[8]">Adding this class to the following number would ensure that readers understand
you’re referring to the North American emergency line when listening to TTS
playback:</p>
<pre class="screen" data-origPath="/html/body/section/section[3]/pre[4]"><span class="digits"><span class="digits">911</span></span></pre>
<p data-origPath="/html/body/section/section[3]/p[9]">The property also allows you to control whether or not to read out punctuation.
Only some punctuation ever gets announced in normal playback, as it’s generally
used for pause effects, but you could require all punctuation to be voiced using
the <code class="literal">literal-punctuation</code> value:</p>
<pre class="screen" data-origPath="/html/body/section/section[3]/pre[5]">.punctuate {
-epub-speak-as: literal-punctuation
}</pre>
<p data-origPath="/html/body/section/section[3]/p[10]">This setting would be vital for grammar books, for example, where you would want
the entire punctuation for each example to be read out to the student.
Conversely, to turn punctuation off you’d use the <code class="literal">no-punctuation</code> value.</p>
</body>
</html>