Skip to content

Commit

Permalink
Add script option to enable TTS log
Browse files Browse the repository at this point in the history
to epub3-to-epub3, dtbook-to-daisy3, dtbook-to-epub3 and
zedai-to-epub3.
  • Loading branch information
bertfrees committed May 18, 2021
1 parent a5c455f commit 8f2e371
Show file tree
Hide file tree
Showing 14 changed files with 100 additions and 9 deletions.
6 changes: 3 additions & 3 deletions bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@
<dependency>
<groupId>org.daisy.pipeline.modules</groupId>
<artifactId>dtbook-to-daisy3</artifactId>
<version>3.1.1</version>
<version>3.1.2-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.daisy.pipeline.modules</groupId>
Expand Down Expand Up @@ -374,7 +374,7 @@
<dependency>
<groupId>org.daisy.pipeline.modules</groupId>
<artifactId>html-to-epub3</artifactId>
<version>2.1.1</version>
<version>2.1.2-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.daisy.pipeline.modules.braille</groupId>
Expand All @@ -389,7 +389,7 @@
<dependency>
<groupId>org.daisy.pipeline.modules</groupId>
<artifactId>zedai-to-epub3</artifactId>
<version>2.2.1</version>
<version>2.2.2-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.daisy.pipeline.modules</groupId>
Expand Down
16 changes: 15 additions & 1 deletion scripts/common-options.xpl
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,18 @@
</p:documentation>
</p:input>

<!--
dtbook-to-daisy3
dtbook-to-epub3
zedai-to-epub3
-->
<p:option name="include-tts-log" select="'false'">
<p:documentation xmlns="http://www.w3.org/1999/xhtml">
<h2 px:role="name">Enable TTS log</h2>
<p px:role="desc">Whether or not to make the TTS log available.</p>
</p:documentation>
</p:option>

<!--
dtbook-to-daisy3
dtbook-to-epub3
Expand All @@ -80,7 +92,9 @@
<h2 px:role="name">TTS log</h2>
<p px:role="desc" xml:space="preserve">Log file with information about text-to-speech process.

Can be enabled or disabled with the [`org.daisy.pipeline.tts.log`](http://daisy.github.io/pipeline/Get-Help/User-Guide/Text-To-Speech/#common-settings) property.
Can be enabled with the "Include TTS log" option or the
[`org.daisy.pipeline.tts.log`](http://daisy.github.io/pipeline/Get-Help/User-Guide/Text-To-Speech/#common-settings)
property.
</p>
</p:documentation>
</p:output>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,13 @@
<p:pipe step="validation-status" port="result"/>
</p:output>

<p:option name="include-tts-log" select="'false'">
<p:documentation xmlns="http://www.w3.org/1999/xhtml">
<p>Whether or not to make the TTS log available on the "tts-log" port.</p>
<p>Note that if this option is set to false, it can still be overwritten by the
"org.daisy.pipeline.tts.log" property.</p>
</p:documentation>
</p:option>
<p:output port="tts-log" sequence="true">
<p:pipe step="tts" port="log"/>
</p:output>
Expand Down Expand Up @@ -188,6 +195,7 @@
<p:pipe step="main" port="tts-config"/>
</p:input>
<p:with-option name="audio" select="$audio"/>
<p:with-option name="include-log" select="$include-tts-log"/>
</px:tts-for-dtbook>
<px:fileset-load media-types="application/x-dtbook+xml" name="tts-enriched-dtbook">
<p:input port="in-memory">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ When text-to-speech is enabled, the conversion may output a (incomplete) DAISY 3
<p:pipe step="convert" port="validation-status"/>
</p:output>

<p:option name="include-tts-log" select="'false'">
<!-- defined in common-options.xpl -->
</p:option>
<p:output port="tts-log" sequence="true">
<!-- defined in common-options.xpl -->
<p:pipe step="convert" port="tts-log"/>
Expand Down Expand Up @@ -107,6 +110,7 @@ When text-to-speech is enabled, the conversion may output a (incomplete) DAISY 3
</p:with-option>
<p:with-option name="audio" select="$audio"/>
<p:with-option name="audio-only" select="$with-text = 'false'"/>
<p:with-option name="include-tts-log" select="$include-tts-log"/>
</px:dtbook-to-daisy3>

<px:fileset-store name="store">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
<d:validation-status result="ok"/>
</p:inline>
</p:output>


<p:option name="include-log" select="'false'"/>
<p:output port="log" sequence="true">
<p:empty/>
</p:output>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,13 @@
</p:documentation>
<p:pipe step="add-mediaoverlays" port="temp-audio.fileset"/>
</p:output>
<p:option name="include-tts-log" select="'false'">
<p:documentation xmlns="http://www.w3.org/1999/xhtml">
<p>Whether or not to make the TTS log available on the "tts-log" port.</p>
<p>Note that if this option is set to false, it can still be overwritten by the
"org.daisy.pipeline.tts.log" property.</p>
</p:documentation>
</p:option>
<p:output port="tts-log" sequence="true">
<p:pipe step="add-mediaoverlays" port="log"/>
</p:output>
Expand Down Expand Up @@ -552,6 +559,7 @@
<p:input port="config">
<p:pipe step="main" port="tts-config"/>
</p:input>
<p:with-option name="include-log" select="$include-tts-log"/>
<p:with-option name="temp-dir" select="$temp-dir"/>
</px:tts-for-epub3>
<p:sink/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,9 @@ elements that represent the sentences.</p>
</p:documentation>
</p:option>

<p:option name="include-tts-log" select="'false'">
<!-- defined in common-options.xpl -->
</p:option>
<p:output port="tts-log" sequence="true">
<!-- defined in common-options.xpl -->
<p:pipe step="convert" port="tts-log"/>
Expand Down Expand Up @@ -288,6 +291,7 @@ elements that represent the sentences.</p>
<p:with-option name="ensure-pagenum-text" select="$ensure-pagenum-text"/>
<p:with-option name="ensure-section-headings" select="$ensure-section-headings"/>
<p:with-option name="sentence-class" select="$sentence-class"/>
<p:with-option name="include-tts-log" select="$include-tts-log"/>
<p:input port="tts-config">
<p:pipe step="main" port="tts-config"/>
</p:input>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,13 @@
</p:documentation>
<p:pipe step="add-mediaoverlays" port="temp-audio.fileset"/>
</p:output>
<p:option name="include-tts-log" select="'false'">
<p:documentation xmlns="http://www.w3.org/1999/xhtml">
<p>Whether or not to make the TTS log available on the "tts-log" port.</p>
<p>Note that if this option is set to false, it can still be overwritten by the
"org.daisy.pipeline.tts.log" property.</p>
</p:documentation>
</p:option>
<p:output port="tts-log" sequence="true">
<p:pipe step="tts" port="log"/>
</p:output>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@
</p:documentation>
<p:pipe step="html-to-epub3" port="temp-audio-files"/>
</p:output>
<p:option name="include-tts-log" select="'false'">
<p:documentation xmlns="http://www.w3.org/1999/xhtml">
<p>Whether or not to make the TTS log available on the "tts-log" port.</p>
<p>Note that if this option is set to false, it can still be overwritten by the
"org.daisy.pipeline.tts.log" property.</p>
</p:documentation>
</p:option>
<p:output port="tts-log" sequence="true">
<p:pipe step="html-to-epub3" port="tts-log"/>
</p:output>
Expand Down Expand Up @@ -195,6 +202,7 @@
<p:pipe step="main" port="tts-config"/>
</p:input>
<p:with-option name="audio" select="$audio"/>
<p:with-option name="include-tts-log" select="$include-tts-log"/>
<p:with-option name="output-dir" select="concat($output-dir,'epub/')"/>
<p:with-option name="temp-dir" select="$temp-dir"/>
</px:html-to-epub3>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ When text-to-speech is enabled, the conversion may output a (incomplete) EPUB 3
<p:pipe step="load-convert-store" port="validation-status"/>
</p:output>

<p:option name="include-tts-log" select="'false'">
<!-- defined in common-options.xpl -->
</p:option>
<p:output port="tts-log" sequence="true">
<!-- defined in common-options.xpl -->
<p:pipe step="load-convert-store" port="tts-log"/>
Expand Down Expand Up @@ -114,6 +117,7 @@ When text-to-speech is enabled, the conversion may output a (incomplete) EPUB 3
</p:input>
<p:with-option name="output-dir" select="$temp-dir"/>
<p:with-option name="audio" select="$audio"/>
<p:with-option name="include-tts-log" select="$include-tts-log"/>
</px:zedai-to-epub3>

<px:epub3-store>
Expand Down
10 changes: 10 additions & 0 deletions tts/dtbook-tts/src/main/resources/xml/tts-for-dtbook.xpl
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@
<p:pipe step="synthesize" port="status"/>
</p:output>

<p:option name="include-log" select="'false'">
<p:documentation xmlns="http://www.w3.org/1999/xhtml">
<p>Whether or not to make the TTS log available on the "log" port.</p>
<p>Note that if this option is set to false, it can still be overwritten by the
"org.daisy.pipeline.tts.log" property.</p>
</p:documentation>
</p:option>
<p:output port="log" sequence="true">
<p:pipe step="synthesize" port="log"/>
</p:output>
Expand Down Expand Up @@ -216,6 +223,9 @@
</px:dtbook-to-ssml>
</p:for-each>
<px:ssml-to-audio name="to-audio" px:progress="1">
<p:with-option name="include-log" select="$include-log">
<p:empty/>
</p:with-option>
<p:input port="config">
<p:pipe port="config" step="main"/>
</p:input>
Expand Down
10 changes: 10 additions & 0 deletions tts/epub3-tts/src/main/resources/xml/tts-for-epub3.xpl
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,13 @@
<p:pipe step="synthesize" port="status"/>
</p:output>

<p:option name="include-log" select="'false'">
<p:documentation xmlns="http://www.w3.org/1999/xhtml">
<p>Whether or not to make the TTS log available on the "log" port.</p>
<p>Note that if this option is set to false, it can still be overwritten by the
"org.daisy.pipeline.tts.log" property.</p>
</p:documentation>
</p:option>
<p:output port="log" sequence="true">
<p:pipe step="synthesize" port="log"/>
</p:output>
Expand Down Expand Up @@ -297,6 +304,9 @@
<p:input port="config">
<p:pipe port="config" step="main"/>
</p:input>
<p:with-option name="include-log" select="$include-log">
<p:empty/>
</p:with-option>
<p:with-option name="temp-dir" select="if ($temp-dir!='') then concat($temp-dir,'audio/') else ''">
<p:empty/>
</p:with-option>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public class SynthesizeStep extends DefaultStep implements FormatSpecifications,
private AudioBufferTracker mAudioBufferTracker;
private URIResolver mURIresolver;
private String mTempDirOpt;
private boolean mIncludeLogOpt;
private int mSentenceCounter = 0;
private int mErrorCounter = 0;

Expand Down Expand Up @@ -126,6 +127,8 @@ public void setOutput(String port, WritablePipe pipe) {
public void setOption(QName name, RuntimeValue value) {
if ("temp-dir".equals(name.getLocalName())) {
mTempDirOpt = value.getString();
} else if ("include-log".equals(name.getLocalName())) {
mIncludeLogOpt = value.getBoolean();
} else
super.setOption(name, value);
}
Expand Down Expand Up @@ -165,10 +168,13 @@ public void run() throws SaxonApiException {
VoiceConfigExtension configExt = new VoiceConfigExtension();
ConfigReader cr = new ConfigReader(mRuntime.getProcessor(), config.read(), configExt);

String logEnabledProp = cr.getDynamicProperties().get("org.daisy.pipeline.tts.log");
if (logEnabledProp == null)
logEnabledProp = cr.getStaticProperties().get("org.daisy.pipeline.tts.log");
boolean logEnabled = "true".equalsIgnoreCase(logEnabledProp);
boolean logEnabled = mIncludeLogOpt;
if (!logEnabled) {
String logEnabledProp = cr.getDynamicProperties().get("org.daisy.pipeline.tts.log");
if (logEnabledProp == null)
logEnabledProp = cr.getStaticProperties().get("org.daisy.pipeline.tts.log");
logEnabled = "true".equalsIgnoreCase(logEnabledProp);
}
TTSLog log;
if (logEnabled) {
log = new TTSLogImpl();
Expand Down
7 changes: 7 additions & 0 deletions tts/tts-common/src/main/resources/xml/xproc/ssml-to-audio.xpl
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@
</p>
</p:documentation>
</p:output>
<p:option name="include-log" select="'false'">
<p:documentation xmlns="http://www.w3.org/1999/xhtml">
<p>Whether or not to make the TTS log available on the "log" port.</p>
<p>Note that if this option is set to false, it can still be overwritten by the
"org.daisy.pipeline.tts.log" property.</p>
</p:documentation>
</p:option>
<p:output port="log" sequence="true"/>
<p:option name="temp-dir" select="''">
<p:documentation xmlns="http://www.w3.org/1999/xhtml">
Expand Down

0 comments on commit 8f2e371

Please sign in to comment.