<p:declare-step xmlns:p="http://www.w3.org/ns/xproc" xmlns:px="http://www.daisy.org/ns/pipeline/xproc" xmlns:cx="http://xmlcalabash.com/ns/extensions" xmlns:xs="http://www.w3.org/2001/XMLSchema" version="1.0" type="px:daisy3-to-mp3.script" name="main"> <p:documentation xmlns="http://www.w3.org/1999/xhtml"> <h1 px:role="name">DAISY 3 to navigable MP3 file-set</h1> <p px:role="desc">Transforms a DAISY 3 publication into a folder structure with MP3 files suitable for playback on MegaVoice Envoy devices.</p> <a px:role="homepage" href="http://daisy.github.io/pipeline/Get-Help/User-Guide/Scripts/daisy3-to-mp3/"> Online documentation </a> </p:documentation> <p:input port="source" px:media-type="application/oebps-package+xml"> <p:documentation xmlns="http://www.w3.org/1999/xhtml"> <h2 px:role="name">DAISY 3</h2> <p px:role="desc">The package file (OPF) of the input DAISY 3.</p> </p:documentation> </p:input> <p:option name="folder-depth" select="'1'"><p:pipeinfo> <px:type> <choice xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0"> <value>1</value> <a:documentation xml:lang="en" xml:space="preserve">1 Produces a folder structure that is one level deep. At the top level there is 1 folder, that contains entire book. This folder can have up to 999 MP3 files. Each MP3 file corresponds with a top-level section of the book. This setting is suited for simple devices of type Envoy Connect/Vine C2.</a:documentation> <value>2</value> <a:documentation xml:lang="en" xml:space="preserve">2 Produces a folder structure that is two levels deep. At the top level there is 1 folder that contains entire book. This folder can have up to 999 sub-folders, each of which can contain up to 999 MP3 files. Each MP3 file corresponds with a level-two section, a top-level section without sub-sections, or the content within a top-level section before the first sub-section.</a:documentation> <value>3</value> <a:documentation xml:lang="en" xml:space="preserve">3 Produces a folder structure that is three levels deep. At the top level there is 1 folder that contains entire book. This folder can have up to 999 sub-folders. The sub-folders can have up to 999 sub-sub-folders, each of which can contain up to 999 MP3 files. Each MP3 file corresponds with a level-three section, a top-level or level-two section without sub-sections, or the content within a top-level or level-two section before the first sub-section.</a:documentation> </choice> </px:type></p:pipeinfo><p:documentation xmlns="http://www.w3.org/1999/xhtml"> <h2 px:role="name">Folder depth</h2> <p px:role="desc" xml:space="preserve">The number of folder levels in the produced folder structure. The book is always, if possible, contained in a single top-level folder with MP3 files or sub-folders (files for folder depth 1, sub-folders for folder depths greater than 1) that correspond with top-level sections of the book. If there are more top-level sections than the maximum number of files/folders that a top-level folder can contain, the book is divided over multiple top-level folders. Similarly, if the number of level-two sections within a top-level section exceeds the maximum number of files/folders that a level-two folder can contain, the top-level section is divided over multiple level-two folders.</p> </p:documentation> </p:option> <p:option name="result" required="true" px:output="result" px:type="anyDirURI" px:media-type="text"> <p:documentation xmlns="http://www.w3.org/1999/xhtml"> <h2 px:role="name">MP3 files</h2> <p px:role="desc">The produced folder structure with MP3 files.</p> </p:documentation> </p:option> <p:import href="http://www.daisy.org/pipeline/modules/daisy3-utils/library.xpl"> <p:documentation> px:daisy3-load </p:documentation> </p:import> <p:import href="http://www.daisy.org/pipeline/modules/fileset-utils/library.xpl"> <p:documentation> px:fileset-create px:fileset-add-entry px:fileset-store px:fileset-delete </p:documentation> </p:import> <p:import href="daisy3-to-mp3.xpl"> <p:documentation> px:daisy3-to-mp3 </p:documentation> </p:import> <px:fileset-create> <p:with-option name="base" select="resolve-uri('./',base-uri(/*))"/> </px:fileset-create> <px:fileset-add-entry media-type="application/oebps-package+xml"> <p:input port="entry"> <p:pipe step="main" port="source"/> </p:input> </px:fileset-add-entry> <px:daisy3-load name="load" px:progress="1/10" px:message="Loading DAISY 3"> <p:documentation>Lists SMILS in spine order.</p:documentation> </px:daisy3-load> <px:daisy3-to-mp3 name="convert" px:progress="8/10" px:message="Rearranging audio into folder structure"> <p:input port="source.in-memory"> <p:pipe step="load" port="result.in-memory"/> </p:input> <p:with-option name="file-limit" select=" if ($folder-depth='1') then [ 1,999] else if ($folder-depth='2') then [ 1,999,999] else (: $folder-depth='3' :) [1,999,999,999]"/> <p:with-option name="level-offset" select="1"/> <p:with-option name="output-dir" select="$result"/> <p:with-option name="temp-dir" select="$temp-dir"/> </px:daisy3-to-mp3> <px:fileset-store px:progress="1/10" name="store" px:message="Storing MP3 files"/> <px:fileset-delete cx:depends-on="store"> <p:input port="source"> <p:pipe step="convert" port="temp-files"/> </p:input> </px:fileset-delete> </p:declare-step>