UNPKG

epubjs

Version:

Render ePub documents in the browser, across many devices

82 lines (78 loc) 5.73 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" /><link rel="prev" href="./ch03s03_1.html" /><link rel="next" href="./ch03s03_3.html" /></head><body> <p data-origPath="/html/body/section/p[13]">And as I mentioned in the overlays section, there are reading systems that already give word-level text-audio synchronization in synthetic speech playback mode, surpassing what most people would attempt with an overlay and human narration. As each word is fed for rendering it gets highlighted on the screen auto-magically; there’s nothing special you have to do.</p> <p data-origPath="/html/body/section/p[14]">The cost and effort to improve synthetic speech is also one that has the potential to decrease over time as you build re-usable lexicons and processes to enhance your books.</p> <p data-origPath="/html/body/section/p[15]">But enough selling of benefits. You undoubtedly want to know how EPUB 3 helps you, so let’s get on with the task.</p> <p data-origPath="/html/body/section/p[16]">The new specification adds three mechanisms specifically aimed at synthetic speech production: PLS lexicon files, SSML markup, and CSS3 Speech style sheets. We’ll go into each of these in turn and explore how you can now combine them to optimize the quality of your ebooks.</p> <h3 class="title" id="_pls_lexicons" data-origPath="/html/body/section/section[1]/h3">PLS Lexicons</h3> <p data-origPath="/html/body/section/section[1]/p[1]">The first of the new synthetic speech enhancement layers we’ll look at is PLS files, which are xml lexicon files that conform to the <a class="ulink" href="http://www.w3.org/TR/pronunciation-lexicon/" target="_top">W3C Pronunciation Lexicon Specification</a>. The entries in these files identify the word(s) to apply each pronunciation rule to. The entries also include the correct phonetic spelling, which provides the text-to-speech engine with the proper pronunciation to render.</p> <p data-origPath="/html/body/section/section[1]/p[2]">Perhaps a simpler way of thinking about PLS files, though, is as containing globally-applicable pronunciation rules: the entries you define in these files will be used for all matching cases in your content. Instead of having to add the pronunciation over and over every time the word is encountered in your markup, as SSML requires, these lexicons are used as global lookups.</p> <p data-origPath="/html/body/section/section[1]/p[3]">PLS files are consequently the ideal place to define all the proper names and technical terms and other complex words that do not change based on the context in which they are used. Even in the case of heteronyms, it’s good to define the pronunciation you deem the most commonly used in your PLS file, as it may be the only case in your ebook(s). It also ensures that you know how the heteronym will always be pronounced by default, to remove the element of chance.</p> <aside class="note" title="Note" data-origPath="/html/body/section/section[1]/aside[1]"> <h3 class="title">Note</h3> <p>The PLS specification does define a role attribute to enable context-dependent pronunciations (e.g., to differentiate the pronunciation of a word when used as a verb or noun), but support for it is not widespread and no vocabulary is defined for standard use. I’ll defer context-dependent differentiation to SSML, as a result, even though a measure is technically possible in PLS files.</p> </aside> <p data-origPath="/html/body/section/section[1]/p[4]">But let’s take a look at a minimal example of a complete PLS file to see how they work in practice. Here we’ll define a single entry for “acetaminophen” to cure our pronunciation headaches:</p> <pre class="screen" data-origPath="/html/body/section/section[1]/pre[1]">&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;acetaminophen&lt;/grapheme&gt; &lt;phoneme&gt;@"sit@'mIn@f@n&lt;/phoneme&gt; &lt;/lexeme&gt; &lt;/lexicon&gt;</pre> <p data-origPath="/html/body/section/section[1]/p[5]">To start breaking this markup down, the <code class="literal">alphabet</code> attribute on the root <code class="literal">lexicon</code> element defines the phonetic alphabet we’re going to use to write our pronunciations. In this case, I’m indicating that I’m going to write them using X-SAMPA.</p> <aside class="note" title="Note" data-origPath="/html/body/section/section[1]/aside[2]"> <h3 class="title">Note</h3> <p>X-SAMPA is the Extended Speech Assessment Methods Phonetic Alphabet. Being an ASCII-based phonetic alphabet, I’ve chosen to use it here only because it is more easily writable (by mere mortals like this author) than the International Phonetic Alphabet (IPA). It is not clear at this time which alphabet(s) will receive the most widespread support in reading systems, however.</p> </aside> </body> </html>