Beispiel #1
0
static cst_utterance *cg_resynth(cst_utterance *utt)
{
    cst_cg_db *cg_db;
    cst_wave *w;
    cst_track *param_track;
    cst_track *str_track = NULL;
    cst_track *smoothed_track;
    const cst_val *streaming_info_val;
    cst_audio_streaming_info *asi = NULL;

    streaming_info_val=get_param_val(utt->features,"streaming_info",NULL);
    if (streaming_info_val)
        asi = val_audio_streaming_info(streaming_info_val);

    cg_db = val_cg_db(utt_feat_val(utt,"cg_db"));
    param_track = val_track(utt_feat_val(utt,"param_track"));
    if (cg_db->mixed_excitation)
        str_track = val_track(utt_feat_val(utt,"str_track"));

    if (cg_db->do_mlpg)
    {
        smoothed_track = mlpg(param_track, cg_db);
        w = mlsa_resynthesis(smoothed_track,str_track,cg_db,asi);
        delete_track(smoothed_track);
    }
    else
        w=mlsa_resynthesis(param_track,str_track,cg_db,asi);


    utt_set_wave(utt,w);

    return utt;
}
Beispiel #2
0
int main(int argc, char **argv)
{
   FILE *pdffp = stdin, *parfp = stdout;
   int nframe, delay;
   char *coef;
   int coeflen;
   PStream pst;
   int i, j;
   void InitPStream(PStream *);
   double *mlpg(PStream *);

   pst.order = ORDER;
   pst.range = RANGE;
   pst.iType = ITYPE;
   pst.dw.fn = (char **) calloc(sizeof(char *), argc);
   pst.dw.num = 1;
   pst.dw.calccoef = -1;

   if ((cmnd = strrchr(argv[0], '/')) == NULL)
      cmnd = argv[0];
   else
      cmnd++;

   while (--argc) {
      if (**++argv == '-') {
         switch (*(*argv + 1)) {
         case 'd':
            if (pst.dw.calccoef == 1) {
               fprintf(stderr,
                       "%s : Options '-r' and '-d' should not be defined simultaneously!\n",
                       cmnd);
               return (1);
            }
            pst.dw.calccoef = 0;
            if (isfloat(*++argv)) {
               coeflen = 0;
               for (i = 0; (i < argc - 1) && isfloat(argv[i]); i++) {
                  coeflen += strlen(argv[i]) + 1;
               }
               coeflen += 1;
               coef = pst.dw.fn[pst.dw.num] = getmem(coeflen, sizeof(char));
               for (j = 0; j < i; j++) {
                  sprintf(coef, " %s", *argv);
                  coef += strlen(*argv) + 1;
                  if (j < i - 1) {
                     argv++;
                     argc--;
                  }
               }
            } else {
               pst.dw.fn[pst.dw.num] = *argv;
            }
            pst.dw.num++;
            --argc;
            break;
         case 'r':
            if (pst.dw.calccoef == 0) {
               fprintf(stderr,
                       "%s : Options '-r' and '-d' should not be defined simultaneously!\n",
                       cmnd);
               return (1);
            }
            pst.dw.calccoef = 1;
            coeflen = atoi(*++argv);
            --argc;
            if ((coeflen != 1) && (coeflen != 2)) {
               fprintf(stderr,
                       "%s : Number of delta parameter should be 1 or 2!\n",
                       cmnd);
               return (1);
            }
            if (argc <= 1) {
               fprintf(stderr,
                       "%s : Window size for delta parameter required!\n",
                       cmnd);
               return (1);
            }
            pst.dw.fn[pst.dw.num] = *++argv;
            pst.dw.num++;
            --argc;
            if (coeflen == 2) {
               if (argc <= 1) {
                  fprintf(stderr,
                          "%s : Window size for delta-delta parameter required!\n",
                          cmnd);
                  return (1);
               }
               pst.dw.fn[pst.dw.num] = *++argv;
               pst.dw.num++;
               --argc;
            }
            break;
         case 'm':
            pst.order = atoi(*++argv);
            --argc;
            break;
         case 'l':
            pst.order = atoi(*++argv) - 1;
            --argc;
            break;
         case 'i':
            pst.iType = atoi(*++argv);
            --argc;
            break;
         case 's':
            pst.range = atoi(*++argv);
            --argc;
            break;
         case 'h':
            usage(0);
         default:
            fprintf(stderr, "%s : Invalid option '%c'!\n", cmnd, *(*argv + 1));
            usage(1);
         }
      } else
         pdffp = getfp(*argv, "rb");
   }

   InitPStream(&pst);

   delay = pst.range + pst.dw.maxw[WRIGHT];
   nframe = 0;
   while (freadf(pst.mean, sizeof(*(pst.mean)), pst.vSize * 2, pdffp) ==
          pst.vSize * 2) {
      if (pst.dw.num == 1)
         fwritef(pst.mean, sizeof(*pst.mean), pst.order + 1, parfp);
      else {
         if (pst.iType == 0)
            for (i = 0; i < pst.vSize; i++)
               pst.ivar[i] = finv(pst.ivar[i]);
         mlpg(&pst);
         if (nframe >= delay)
            fwritef(pst.par, sizeof(*(pst.par)), pst.order + 1, parfp);
      }
      nframe++;
   }

   if (pst.dw.num > 1) {
      for (i = 0; i < pst.vSize; i++) {
         pst.mean[i] = 0.0;
         pst.ivar[i] = 0.0;
      }
      for (i = 0; i < min(nframe, delay); i++) {
         mlpg(&pst);
         fwritef(pst.par, sizeof(*(pst.par)), pst.order + 1, parfp);
      }
   }

   return (0);
}