OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.


Help: OASIS Mailing Lists Help | MarkMail Help

docbook message

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]

Subject: Re: [docbook] audio epubs

Thanks. I look forward to giving this a go.


On 23/09/2014 11:15, Jirka Kosek wrote:
[Replying to docbook-apps where this belongs...]
On 18.9.2014 15:38, Peter Fleck wrote:
Is it possible to do a lot of the work to make audio epubs using
Everything is possible, it depends on effort you can put into it :-)

First, how to auto generate ids for each <para>? I'm sure that is
straightforward. (Or if more granularity is needed then id's at the
sentence or word level as needed).
Putting following into your customization layer should do the trick:

<xsl:param name="generate.id.attributes" select="1"/>
<xsl:param name="generate.consistent.ids" select="1"/>

<xsl:template name="id.attribute">
  <xsl:param name="node" select="."/>
  <xsl:param name="conditional" select="0"/>
    <xsl:when test="$generate.id.attributes = 0">
      <!-- No id attributes when this param is zero -->
    <xsl:when test="$conditional = 0 or $node/@id or $node/@xml:id">
      <xsl:attribute name="id">
        <xsl:call-template name="object.id">
          <xsl:with-param name="object" select="$node"/>

However if you change your DocBook source autogenerated IDs will change.

Second, populate the smil file with the ids

<smil xmlns="http://www.w3.org/ns/SMIL"
xmlns:epub="http://www.idpf.org/2007/ops" version="3.0">
        <seq id="id1" epub:textref="index.xhtml" epub:type="bodymatter
            <par id="paragraph1">
                <text src=""/>
                <audio src="" clipBegin="0:00:02.000"
            <par id="paragraph2">
                <text src=""/>
                <audio src="" clipBegin="0:00:15.000"

The smil file would need manually editing for the clipBegin and clipEnd
for each but that's fine. The audio src could be passed as a parameter.
Then add something like .-epub-media-overlay-active {background-color:
#abc;} to the css.
Have you considered generating this SMIL file automatically? I can
imagine putting custom attributes into DocBook document, something like:

<chapter my:audio="file.mp3">
  <para my:begin="0:00:02.000" my:end="0:00:15.000">...</para>
  <para my:begin="0:00:15.000" my:end="0:00:25.000">...</para>

From such markup you can quite easily generate SMIL file automatically.

Finally modify the package.opf to add

    <meta property="media:duration"
    <meta property="media:duration"
    <meta property="media:duration">0:08:00.000</meta>
    <meta property="media:narrator">Narrator Name</meta>
    <meta property="media:active-class">-epub-media-overlay-active</meta>
    <item id="ncx" href="" media-type="application/x-dtbncx+xml"/>
    <item id="htmltoc" properties="nav"
media-type="application/xhtml+xml" href=""/>
    <item media-type="text/css" id="docbook-css" href=""/>
    <item id="id-idm21776" href=""
media-type="application/xhtml+xml" media-overlay="chapter1_overlay"/>
    <item id="chapter1_overlay" href=""

Is something like this doable?
Yes, generation of OPF file is split into set of relative small
templates which you can easily override. Look into
epub3/epu3-element-mods.xsl file. For example metadata part is generated
by the following template:

<xsl:template name="package.metadata">

  <xsl:element name="metadata" namespace="{$opf.namespace}">

    <xsl:call-template name="metadata.identifier"/>
    <xsl:call-template name="metadata.title"/>
    <xsl:call-template name="metadata.language"/>
    <xsl:call-template name="metadata.modified"/>
    <xsl:call-template name="metadata.cover"/>
    <xsl:call-template name="metadata.other.info"/>


You can generate this template manually, or put your custom elements
inside <info> elements and handle them in special opf.metadata mode.

  <media:narrator>Narrator Name</media:narrator>

<xsl:template match="media:*" mode="opf.metadata">
  <meta property="media:{local-name(.)}"><xsl:value-of select="."/></meta>



[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]