Package: release.debian.org
Severity: normal
User: release.debian....@packages.debian.org
Usertags: unblock

Hello,

A user reported on #856895 that the speech-dispatcher-flite module
systematically strips the end of speech syntheses, while other modules
do work fine.  That makes the flite module barely usable since some
important information may then be missing, which is more than important
when used by a screen reader for a blind user.

Digging a bit, I found that the flite module intentionally strips part
of the synthesis, to drop the silence at beginning and end of the
synthesis (which is indeed not neglectable). This is done with an ad-hoc
cryptic sloppy formula. In the patch I have uploaded, I replaced it with
a mere loop that simply looks for heading and trailing silence (detected
as being less than 0.1% volume). The result is as snappy as user expect,
and way more robust.

Samuel

unblock speech-dispatcher/0.8.6-4

-- System Information:
Debian Release: 9.0
  APT prefers testing
  APT policy: (990, 'testing'), (500, 'unstable-debug'), (500, 
'testing-debug'), (500, 'buildd-unstable'), (500, 'unstable'), (500, 'stable'), 
(500, 'oldstable'), (1, 'experimental-debug'), (1, 'buildd-experimental'), (1, 
'experimental')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 4.10.0 (SMP w/4 CPU cores)
Locale: LANG=fr_FR.UTF-8, LC_CTYPE=fr_FR.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)

-- 
Samuel
"...Unix, MS-DOS, and Windows NT (also known as the Good, the Bad, and
the Ugly)."
(By Matt Welsh)
diff -Nru speech-dispatcher-0.8.6/debian/changelog 
speech-dispatcher-0.8.6/debian/changelog
--- speech-dispatcher-0.8.6/debian/changelog    2017-02-04 10:59:22.000000000 
+0100
+++ speech-dispatcher-0.8.6/debian/changelog    2017-03-05 23:13:08.000000000 
+0100
@@ -1,3 +1,9 @@
+speech-dispatcher (0.8.6-4) unstable; urgency=medium
+
+  * Fix stripped audio output of flite module (Closes: #856895).
+
+ -- Samuel Thibault <sthiba...@debian.org>  Sun, 05 Mar 2017 23:13:08 +0100
+
 speech-dispatcher (0.8.6-3) unstable; urgency=medium
 
   [ Samuel Thibault ]
diff -Nru speech-dispatcher-0.8.6/debian/patches/flite-strip-silence 
speech-dispatcher-0.8.6/debian/patches/flite-strip-silence
--- speech-dispatcher-0.8.6/debian/patches/flite-strip-silence  1970-01-01 
01:00:00.000000000 +0100
+++ speech-dispatcher-0.8.6/debian/patches/flite-strip-silence  2017-03-05 
23:12:16.000000000 +0100
@@ -0,0 +1,45 @@
+--- a/src/modules/flite.c
++++ b/src/modules/flite.c
+@@ -238,21 +238,29 @@ int module_close(void)
+ 
+ void flite_strip_silence(AudioTrack * track)
+ {
+-      int playlen, skip;
++      assert(track->bits == 16);
++      unsigned i;
++      float silence_limit = 0.001;
+ 
+-      float stretch =
+-          get_param_float(flite_voice->features, "duration_stretch", 1.);
+-      int speed = (int)(1000. / stretch);
+-      skip = (187 * track->sample_rate) / speed;
+-      playlen = track->num_samples - skip * 2;
+-      if (playlen > 0 && playlen < 500)
+-              playlen += (skip * 2) / 3;
+-      if (playlen < 0)
+-              playlen = 0;
++      while (track->num_samples >= track->num_channels) {
++              for (i = 0; i < track->num_channels; i++)
++                      if (abs(track->samples[i])
++                          >= silence_limit * (1L<<(track->bits-1)))
++                              goto stripped_head;
++              track->samples += track->num_channels;
++              track->num_samples -= track->num_channels;
++      }
++stripped_head:
+ 
+-      track->num_samples = playlen;
+-      assert(track->bits == 16);
+-      track->samples += skip * track->num_channels;
++      while (track->num_samples >= track->num_channels) {
++              for (i = 0; i < track->num_channels; i++)
++                      if (abs(track->samples[track->num_samples - i - 1])
++                          >= silence_limit * (1L<<(track->bits-1)))
++                              goto stripped_tail;
++              track->num_samples -= track->num_channels;
++      }
++stripped_tail:
++      ;
+ }
+ 
+ void *_flite_speak(void *nothing)
diff -Nru speech-dispatcher-0.8.6/debian/patches/series 
speech-dispatcher-0.8.6/debian/patches/series
--- speech-dispatcher-0.8.6/debian/patches/series       2017-02-04 
08:13:39.000000000 +0100
+++ speech-dispatcher-0.8.6/debian/patches/series       2017-03-05 
22:50:12.000000000 +0100
@@ -1,3 +1,4 @@
 pulse-default-latency.patch
 doc-figures
 change-default-module.patch
+flite-strip-silence

Reply via email to