[Subject Prev][Subject Next][Thread Prev][Thread Next][Date Index][Thread Index]

[hts-users:04144] Bug Report on ApplyWindow Function in HMGenS


HTS working group,

   Thank you for your excellent work on HTS.

   I find a moderate bug in ApplyWindow() in HMGenS V2.2 and
V2.3-alpha. This bug is about how to calculate dynamics in a time
sequence at the first frame and last frame. The current ApplyWindow()
implementation produce incorrect observation vector at two ends, which
further results in nearly zero probability density values.

   My analysis and bug fix are supplied in attachments for your reference.

   Will you please let me know if I am not correct? Thank you!

Yang Wang
Email: yangwang@xxxxxxxxxxxxx

Attachment: 2014-10-16 Bug Report on ApplyWindow Function in HMGenS.pdf
Description: Adobe PDF document

/* ----------------------------------------------------------------- */
/*           The HMM-Based Speech Synthesis System (HTS)             */
/*           developed by HTS Working Group                          */
/*           http://hts.sp.nitech.ac.jp/                             */
/* ----------------------------------------------------------------- */
/*                                                                   */
/*  Copyright (c) 2001-2011  Nagoya Institute of Technology          */
/*                           Department of Computer Science          */
/*                                                                   */
/*                2001-2008  Tokyo Institute of Technology           */
/*                           Interdisciplinary Graduate School of    */
/*                           Science and Engineering                 */
/*                                                                   */
/* All rights reserved.                                              */
/*                                                                   */
/* Redistribution and use in source and binary forms, with or        */
/* without modification, are permitted provided that the following   */
/* conditions are met:                                               */
/*                                                                   */
/* - Redistributions of source code must retain the above copyright  */
/*   notice, this list of conditions and the following disclaimer.   */
/* - Redistributions in binary form must reproduce the above         */
/*   copyright notice, this list of conditions and the following     */
/*   disclaimer in the documentation and/or other materials provided */
/*   with the distribution.                                          */
/* - Neither the name of the HTS working group nor the names of its  */
/*   contributors may be used to endorse or promote products derived */
/*   from this software without specific prior written permission.   */
/*                                                                   */
/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND            */
/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,       */
/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF          */
/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE          */
/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS */
/* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,          */
/* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED   */
/* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,     */
/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON */
/* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,   */
/* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY    */
/* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE           */
/* POSSIBILITY OF SUCH DAMAGE.                                       */
/* ----------------------------------------------------------------- */
/*         File: HGen.c: Generate parameter sequence from HMM        */
/* ----------------------------------------------------------------- */



/* Fixed by Yang Wang on 2014.10.16. Email: yangwang@xxxxxxxxxxxxx	*/

/* ApplyWindow: check t-th frame is on switching space boundary */
static float ApplyWindow(PdfStream * pst, const short msdflag, const int absolute_t, const int v)
{
   int j;
   float otsk;

   int t_cut;     /* time cut off of involved time index absolute_t + j, or t + j */

   /* constants */
   const int t = pst->t;        /* time counter in this PdfStream */
   const int T = pst->T;        /* total number of frames in this PdfStream */
   const int i = (v - 1) / pst->order;  /* window for this dimension */
   const int m = (v - 1) % pst->order + 1;      /* static feature for this dimension */

   /* applying window */
   otsk = 0.0;
   for (j = pst->win.width[i][0]; j <= pst->win.width[i][1]; j++) {
      if ( absolute_t + j < 1 )     /* time cut off for absolute_t + j */
         t_cut = 1;
      else if ( absolute_t + j > IntVecSize( pst->ContSpace ) )
         t_cut = IntVecSize( pst->ContSpace );
      else
         t_cut = absolute_t + j;

      if (msdflag && ( (pst->win.coef[i][j] != 0.0 && !pst->ContSpace[ t_cut ]))) {
         otsk = ReturnIgnoreValue();
         break;
      } else {
         if ( t + j < 1 )     /* time cut off for t + j */
            t_cut = 1;
         else if ( t + j > pst->T )
            t_cut = pst->T;
         else
            t_cut = t + j;

         otsk += pst->win.coef[i][j] * pst->C[ t_cut ][m];
      }
   }

   return (otsk);
}


/* Before fixed, i.e., implementation in HTS v2.2 */

/* ApplyWindow: check t-th frame is on swithing space boundary */
static float ApplyWindow(PdfStream * pst, const short msdflag, const int absolute_t, const int v)
{
   int j;
   float otsk;

   /* constants */
   const int t = pst->t;        /* time counter in this PdfStream */
   const int T = pst->T;        /* total number of frames in this PdfStream */
   const int i = (v - 1) / pst->order;  /* window for this dimension */
   const int m = (v - 1) % pst->order + 1;      /* static feature for this dimension */

   /* applying window */
   otsk = 0.0;
   for (j = pst->win.width[i][0]; j <= pst->win.width[i][1]; j++) {
      if (msdflag && (t + j < 1 || t + j > T || (pst->win.coef[i][j] != 0.0 && !pst->ContSpace[absolute_t + j]))) {
         otsk = ReturnIgnoreValue();
         break;
      } else {
         if (t + j >= 1 && t + j <= T)
            otsk += pst->win.coef[i][j] * pst->C[t + j][m];
      }
   }

   return (otsk);
}

Follow-Ups
[hts-users:04145] Re: Bug Report on ApplyWindow Function in HMGenS, Keiichiro Oura
[hts-users:04146] Re: Bug Report on ApplyWindow Function in HMGenS, Matt Shannon