2
## ====================================================================
4
## Copyright (c) 1996-2000 Carnegie Mellon University. All rights
7
## Redistribution and use in source and binary forms, with or without
8
## modification, are permitted provided that the following conditions
11
## 1. Redistributions of source code must retain the above copyright
12
## notice, this list of conditions and the following disclaimer.
14
## 2. Redistributions in binary form must reproduce the above copyright
15
## notice, this list of conditions and the following disclaimer in
16
## the documentation and/or other materials provided with the
19
## This work was supported in part by funding from the Defense Advanced
20
## Research Projects Agency and the National Science Foundation of the
21
## United States of America, and the CMU Sphinx Speech Consortium.
23
## THIS SOFTWARE IS PROVIDED BY CARNEGIE MELLON UNIVERSITY ``AS IS'' AND
24
## ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
25
## THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
26
## PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY
27
## NOR ITS EMPLOYEES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28
## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29
## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30
## DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31
## THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32
## (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33
## OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35
## ====================================================================
37
## Author: Ricky Houghton
43
use File::Spec::Functions;
46
use lib catdir(dirname($0), updir(), 'lib');
47
use SphinxTrain::Config;
48
use SphinxTrain::Util;
50
#*************************************************************************
51
# This script runs the build_tree script for each state of each basephone
52
#*************************************************************************
54
use vars qw($MLLT_FILE $MODEL_TYPE);
55
$MLLT_FILE = catfile($ST::CFG_MODEL_DIR, "${ST::CFG_EXPTNAME}.mllt");
60
my $logdir = "${ST::CFG_LOG_DIR}/40.buildtrees";
62
Log("MODULE: 40 Build Trees\n");
63
Log("Phase 1: Cleaning up old log files...\n");
67
$| = 1; # Turn on autoflushing
68
if ($ST::CFG_MAKE_QUESTS eq 'no') {
69
die "Question set $ST::CFG_QUESTION_SET not found, but CFG_MAKE_QUESTS is no"
70
unless -e $ST::CFG_QUESTION_SET;
73
Log("Phase 2: Make Questions");
74
if (RunScript('make_questions.pl')) {
80
Log("Phase 3: Tree building\n");
81
my $mdef_file = "${ST::CFG_BASE_DIR}/model_architecture/${ST::CFG_EXPTNAME}.untied.mdef";
82
my $mixture_wt_file = "${ST::CFG_BASE_DIR}/model_parameters/${ST::CFG_EXPTNAME}.${MODEL_TYPE}_${ST::CFG_DIRLABEL}_untied/mixture_weights";
83
my $tree_base_dir = "${ST::CFG_BASE_DIR}/trees";
84
my $unprunedtreedir = "$tree_base_dir/${ST::CFG_EXPTNAME}.unpruned";
85
mkdir ($tree_base_dir,0777);
86
mkdir ($unprunedtreedir,0777);
88
# For every phone submit each possible state
90
if ($ST::CFG_CROSS_PHONE_TREES eq 'yes') {
91
Log("Processing all phones with each state\n", 'result');
92
push @jobs, ['ALLPHONES' => LaunchScript("tree.all", ['buildtree.pl', 'ALLPHONES'])];
94
Log ("Processing each phone with each state\n", 'result');
95
open INPUT,"${ST::CFG_RAWPHONEFILE}";
96
foreach $phone (<INPUT>) {
97
if ($ST::CFG_QUEUE_TYPE eq "Queue::POSIX") {
98
# Use @jobs as a queue (better than nothing for Queue::POSIX)
99
if (@jobs > $ST::CFG_NPART) {
100
my ($p, $j) = @{shift @jobs};
104
$phone = Trim($phone);
105
if (($phone =~ m/^(\+).*(\+)$/) || ($phone =~ m/^SIL$/)) {
106
Log ("Skipping $phone\n", 'result');
110
my $job = LaunchScript("tree.$phone", ['buildtree.pl', $phone]);
111
push @jobs, [$phone => $job];
116
# Wait for all the remaining phones to finish
117
# It doesn't really matter what order we do this in
119
my ($phone,$job) = @$_;