~ubuntu-branches/ubuntu/saucy/sphinxtrain/saucy

« back to all changes in this revision

Viewing changes to src/programs/param_cnt/ts_cnt.c

  • Committer: Package Import Robot
  • Author(s): Samuel Thibault
  • Date: 2013-01-02 04:10:21 UTC
  • Revision ID: package-import@ubuntu.com-20130102041021-ynsizmz33fx02hea
Tags: upstream-1.0.8
ImportĀ upstreamĀ versionĀ 1.0.8

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* ====================================================================
 
2
 * Copyright (c) 1994-2000 Carnegie Mellon University.  All rights 
 
3
 * reserved.
 
4
 *
 
5
 * Redistribution and use in source and binary forms, with or without
 
6
 * modification, are permitted provided that the following conditions
 
7
 * are met:
 
8
 *
 
9
 * 1. Redistributions of source code must retain the above copyright
 
10
 *    notice, this list of conditions and the following disclaimer. 
 
11
 *
 
12
 * 2. Redistributions in binary form must reproduce the above copyright
 
13
 *    notice, this list of conditions and the following disclaimer in
 
14
 *    the documentation and/or other materials provided with the
 
15
 *    distribution.
 
16
 *
 
17
 * This work was supported in part by funding from the Defense Advanced 
 
18
 * Research Projects Agency and the National Science Foundation of the 
 
19
 * United States of America, and the CMU Sphinx Speech Consortium.
 
20
 *
 
21
 * THIS SOFTWARE IS PROVIDED BY CARNEGIE MELLON UNIVERSITY ``AS IS'' AND 
 
22
 * ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 
 
23
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 
24
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY
 
25
 * NOR ITS EMPLOYEES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 
26
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
 
27
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
 
28
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 
 
29
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
 
30
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
 
31
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
32
 *
 
33
 * ====================================================================
 
34
 *
 
35
 */
 
36
/*********************************************************************
 
37
 *
 
38
 * File: ts_cnt.c
 
39
 * 
 
40
 * Description: 
 
41
 *      Initialize one Gaussian mixtures for each context independent
 
42
 *      phone state.
 
43
 *
 
44
 * Author: 
 
45
 *      Eric H. Thayer
 
46
 *********************************************************************/
 
47
 
 
48
#include "ts_cnt.h"
 
49
 
 
50
#include <sphinxbase/prim_type.h>
 
51
#include <sphinxbase/ckd_alloc.h>
 
52
 
 
53
#include <s3/cvt2triphone.h>
 
54
#include <s3/mk_sseq.h>
 
55
#include <s3/s3.h>
 
56
 
 
57
#include <stdio.h>
 
58
 
 
59
static int32 did_warn = 0;
 
60
 
 
61
 
 
62
int
 
63
ts_cnt(uint32 *cnt,             /* observation counts */
 
64
 
 
65
       model_def_t *mdef,       /* model definitions */
 
66
 
 
67
       uint16 *seg,             /* Viterbi (CI phone,state) pairs for all frames */
 
68
       uint32 n_frame,
 
69
 
 
70
       acmod_id_t *phone,       /* CI phone sequence (already validated) */
 
71
       char *btw_mark,
 
72
       uint32 n_phone)
 
73
{
 
74
    acmod_set_t *acmod_set;
 
75
    uint32 *ci_sseq = NULL;
 
76
    uint32 *sseq = NULL;
 
77
    uint32 i;
 
78
 
 
79
    acmod_set = mdef->acmod_set;
 
80
 
 
81
    /* make a tied state id sequence from the state segmentation and the
 
82
       phone list */
 
83
    ci_sseq = mk_sseq(seg, n_frame, phone, n_phone, mdef);
 
84
    for (i = 0; i < n_frame; i++) {
 
85
        cnt[ci_sseq[i]]++;
 
86
    }
 
87
 
 
88
    if (cvt2triphone(acmod_set, phone, btw_mark, n_phone) != S3_SUCCESS) {
 
89
        if (!did_warn) {
 
90
            E_WARN("Conversion from CI phones to triphones failed\n");
 
91
        }
 
92
        
 
93
        return S3_SUCCESS;
 
94
    }
 
95
 
 
96
    /* make a tied state id sequence from the state segmentation and the
 
97
       phone list */
 
98
    sseq = mk_sseq(seg, n_frame, phone, n_phone, mdef);
 
99
 
 
100
    for (i = 0; i < n_frame; i++) {
 
101
        if (ci_sseq[i] != sseq[i])
 
102
            cnt[sseq[i]]++;
 
103
    }
 
104
    
 
105
    return S3_SUCCESS;
 
106
}