epubjs
Version:
Render ePub documents in the browser, across many devices
81 lines (75 loc) • 5.22 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/section[2]" /><link rel="prev" href="./ch03s03_6.html" /><link rel="next" href="./ch03s03_8.html" /></head><body>
<p data-origPath="/html/body/section/section[2]/p[12]">The upside of the granularity SSML markup provides should be clear now, though:
you can overcome any problem no matter how small (or big) with greater precision
than PLS files offer. The downside, of course, is having to work at the markup
level to correct each instance that has to be overridden.</p>
<p data-origPath="/html/body/section/section[2]/p[13]">To hark back to the discussion of PLS files for a moment, though, we could
further simplify the correction process by moving the more common pronunciation
to our PLS lexicon and only fix the differing heteronym:</p>
<pre class="screen" data-origPath="/html/body/section/section[2]/pre[3]"><lexicon
version="1.0"
alphabet="x-sampa"
xml:lang="en"
xmlns="http://www.w3.org/2005/01/pronunciation-lexicon">
<lexeme>
<grapheme>bass</grapheme>
<phoneme>beIs</phoneme>
</lexeme>
</lexicon>
<p>
The guitarist was playing a bass that was shaped like a
<span ssml:alphabet="x-sampa" ssml:ph="b&amp;s"><span ssml:ph="b&s">bass</span></span>.
</p></pre>
<p data-origPath="/html/body/section/section[2]/p[14]">It’s also not necessary to define the <code class="literal">ssml:alphabet</code>
attribute every time. If we were only using a single alphabet throughout the
document, which would be typical of most ebooks, we could instead define the
alphabet once on the root <code class="literal">html</code> element:</p>
<pre class="screen" data-origPath="/html/body/section/section[2]/pre[4]"><html … ssml:alphabet="x-sampa"></pre>
<p data-origPath="/html/body/section/section[2]/p[15]">So long as the alphabet is defined on an ancestor of the element carrying the
<code class="literal">ssml:ph</code> attribute, a rendering engine will
interpret it correctly (and your document will be valid). (The root element is
the ancestor of all the elements in the document, which is why these kinds of
declarations are invariably found on it, in case you’ve ever wondered but were
afraid to ask.)</p>
<p data-origPath="/html/body/section/section[2]/p[16]">Our markup can now be reduced to the much more legible and easily maintained:</p>
<pre class="screen" data-origPath="/html/body/section/section[2]/pre[5]"><p>
The guitarist was playing a bass that was shaped like a
<span ssml:ph="b&amp;s"><span ssml:ph="b&s">bass</span></span>.
</p></pre>
<aside class="note" title="Note" data-origPath="/html/body/section/section[2]/aside[2]">
<h3 class="title">Note</h3>
<p>If you’re planning to share content across ebooks or across content files
within one, it’s better to keep the attributes paired so that there is no
confusion about which alphabet was used to define the pronunciation. It’s
not a common requirement, however.</p>
</aside>
<p data-origPath="/html/body/section/section[2]/p[17]">But heteronyms are far from the only case for SSML. Any language construct that
can be voiced differently depending on the context in which it is used is a
candidate for SSML. Numbers are always problematic, as are weights and
measures:</p>
<pre class="screen" data-origPath="/html/body/section/section[2]/pre[6]"><p>
There are <span
ssml:ph="w&quot;Vn T&quot;aUz@n t_hw&quot;En4i f&quot;O:r"><span ssml:ph="w"Vn T"aUz@n t_hw"En4i f"O:r">1024</span></span> bits
in a byte, not <span ssml:ph="t_h&quot;En t_hw&quot;En4i f&quot;O:r"><span ssml:ph="t_h"En t_hw"En4i f"O:r">1024</span></span>,
as the year is pronounced.
</p>
<p>
It reached a high of <span
ssml:ph="'T3rti s&quot;Ev@n 'sEntI&quot;greId"><span ssml:ph="'T3rti s"Ev@n 'sEntI"greId">37C</span></span> in the sun as I stood
outside <span ssml:ph="'T3rti s&quot;Ev@n si"><span ssml:ph="'T3rti s"Ev@n si">37C</span></span> waiting for someone
to answer my knocks and let me in.
</p>
<p>
You'll be an <span ssml:ph="Ekstr@ lArdZ"><span ssml:ph="Ekstr@ lArdZ">XL</span></span> by the end of Super Bowl
<span ssml:ph="'fOrti"><span ssml:ph="'fOrti">XL</span></span> at the rate you're eating.
</p></pre>
</body>
</html>