UNPKG

epubjs

Version:

Render ePub documents in the browser, across many devices

81 lines (75 loc) 5.22 kB
<?xml version="1.0" encoding="UTF-8" ?><!DOCTYPE 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]">&lt;lexicon version="1.0" alphabet="x-sampa" xml:lang="en" xmlns="http://www.w3.org/2005/01/pronunciation-lexicon"&gt; &lt;lexeme&gt; &lt;grapheme&gt;bass&lt;/grapheme&gt; &lt;phoneme&gt;beIs&lt;/phoneme&gt; &lt;/lexeme&gt; &lt;/lexicon&gt; &lt;p&gt; The guitarist was playing a bass that was shaped like a &lt;span ssml:alphabet="x-sampa" ssml:ph="b&amp;amp;s"&gt;<span ssml:ph="b&amp;s">bass</span>&lt;/span&gt;. &lt;/p&gt;</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]">&lt;html … ssml:alphabet="x-sampa"&gt;</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]">&lt;p&gt; The guitarist was playing a bass that was shaped like a &lt;span ssml:ph="b&amp;amp;s"&gt;<span ssml:ph="b&amp;s">bass</span>&lt;/span&gt;. &lt;/p&gt;</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]">&lt;p&gt; There are &lt;span ssml:ph="w&amp;quot;Vn T&amp;quot;aUz@n t_hw&amp;quot;En4i f&amp;quot;O:r"&gt;<span ssml:ph="w&quot;Vn T&quot;aUz@n t_hw&quot;En4i f&quot;O:r">1024</span>&lt;/span&gt; bits in a byte, not &lt;span ssml:ph="t_h&amp;quot;En t_hw&amp;quot;En4i f&amp;quot;O:r"&gt;<span ssml:ph="t_h&quot;En t_hw&quot;En4i f&quot;O:r">1024</span>&lt;/span&gt;, as the year is pronounced. &lt;/p&gt; &lt;p&gt; It reached a high of &lt;span ssml:ph="'T3rti s&amp;quot;Ev@n 'sEntI&amp;quot;greId"&gt;<span ssml:ph="'T3rti s&quot;Ev@n 'sEntI&quot;greId">37C</span>&lt;/span&gt; in the sun as I stood outside &lt;span ssml:ph="'T3rti s&amp;quot;Ev@n si"&gt;<span ssml:ph="'T3rti s&quot;Ev@n si">37C</span>&lt;/span&gt; waiting for someone to answer my knocks and let me in. &lt;/p&gt; &lt;p&gt; You'll be an &lt;span ssml:ph="Ekstr@ lArdZ"&gt;<span ssml:ph="Ekstr@ lArdZ">XL</span>&lt;/span&gt; by the end of Super Bowl &lt;span ssml:ph="'fOrti"&gt;<span ssml:ph="'fOrti">XL</span>&lt;/span&gt; at the rate you're eating. &lt;/p&gt;</pre> </body> </html>