Package edu.cmu.sphinx.linguist.acoustic

Examples of edu.cmu.sphinx.linguist.acoustic.Unit


     */
    HMMNode(HMM hmm, float probablilty) {
        super(probablilty);
        this.hmm = hmm;

        Unit base = getBaseUnit();

        int type = SIMPLE_UNIT;
        if (base.isSilence()) {
            type = SILENCE_UNIT;
        } else if (base.isFiller()) {
            type = FILLER_UNIT;
        } else if (hmm.getPosition().isWordBeginning()) {
            type = WORD_BEGINNING_UNIT;
        }
        setType(type);
View Full Code Here


        HMMNode[] results = endNodeMap.get(endNode.getKey());
        if (results == null) {
            // System.out.println("Filling cache for " + endNode.getKey()
            //        + " size " + endNodeMap.size());
            Map<HMM, HMMNode> resultMap = new HashMap<HMM, HMMNode>();
            Unit baseUnit = endNode.getBaseUnit();
            Unit lc = endNode.getLeftContext();
            for (Unit rc : entryPoints) {
                HMM hmm = hmmPool.getHMM(baseUnit, lc, rc, HMMPosition.END);
                HMMNode hmmNode = resultMap.get(hmm);
                if (hmmNode == null) {
                    hmmNode = new HMMNode(hmm, LogMath.LOG_ONE);
View Full Code Here

    private void collectEntryAndExitUnits() {
        Collection<Word> words = getAllWords();
        for (Word word : words) {
            for (int j = 0; j < word.getPronunciations().length; j++) {
                Pronunciation p = word.getPronunciations()[j];
                Unit first = p.getUnits()[0];
                Unit last = p.getUnits()[p.getUnits().length - 1];
                entryPoints.add(first);
                exitPoints.add(last);
            }
        }
View Full Code Here

     * @param pronunciation the pronunciation
     * @param probability   the unigram probability
     */
    private void addPronunciation(Pronunciation pronunciation,
                                  float probability) {
        Unit baseUnit;
        Unit lc;
        Unit rc;
        Node curNode;
        WordNode wordNode;

        Unit[] units = pronunciation.getUnits();
        baseUnit = units[0];
        EntryPoint ep = entryPointTable.getEntryPoint(baseUnit);

        ep.addProbability(probability);

        if (units.length > 1) {
            curNode = ep.getNode();
            lc = baseUnit;
            for (int i = 1; i < units.length - 1; i++) {
                baseUnit = units[i];
                rc = units[i + 1];
                HMM hmm = hmmPool.getHMM(baseUnit, lc, rc, HMMPosition.INTERNAL);
                if (hmm == null) {
                    logger.severe("Missing HMM for unit " + baseUnit.getName() + " with lc=" + lc.getName() + " rc=" + rc.getName());
                } else {
                    curNode = curNode.addSuccessor(hmm, probability);
                }
                lc = baseUnit;          // next lc is this baseUnit
            }
View Full Code Here

                if (wordNode.getWord() != sentenceEndWord) {
                    int index = 0;
                    List<Node> list = new ArrayList<Node>();
                    Unit[] rc = lastNode.getRC();
                    Unit left = wordNode.getLastUnit();

                    for (Unit unit : rc) {
                        Node[] epList = hmmTree.getEntryPoint(left, unit);
                        for (Node n : epList) {
                            list.add(n);
View Full Code Here

        int[] ids = new int[3];
        ids[1] = symbolTable.get(unit.getName());

        if (unit.isContextDependent()) {
            LeftRightContext context = (LeftRightContext) unit.getContext();
            Unit left = context.getLeftContext()[0];
            Unit right = context.getRightContext()[0];
            ids[0] = symbolTable.get(left.getName());
            ids[2] = symbolTable.get(right.getName());
        } else {
            ids[0] = symbolTable.get("SIL");
            ids[2] = symbolTable.get("SIL");
        }
View Full Code Here

     * @param child       the endNode to add
     * @param probability probability for this transition
     * @return the node that holds the endNode (new or old)
     */
    EndNode addSuccessor(EndNode child, float probability) {
        Unit baseUnit = child.getBaseUnit();
        EndNode matchingChild = (EndNode) getSuccessor(baseUnit);
        if (matchingChild == null) {
            putSuccessor(baseUnit, child);
        } else {
            if (matchingChild.getUnigramProbability() < probability) {
View Full Code Here

        contextIndependentUnits = new HashMap<String, Unit>();
        hmmManager = new LazyHmmManager(parser, transitionModel,
                                        senonePool, symbolTable);

        for (String phone : symbolTable.keySet()) {
            Unit unit = unitManager.getUnit(phone, "SIL".equals(phone));
            contextIndependentUnits.put(unit.getName(), unit);
            // Ensure monophone HMMs are created.
            hmmManager.get(HMMPosition.UNDEFINED, unit);
        }

        loadTransform();
View Full Code Here

            for (int j = 0; j < size; j++, stateIndex++) {
                stid[j] = stateIndex;
            }

            Unit unit = unitManager.getUnit(phone,  phone.equals(SILENCE_CIPHONE));

            contextIndependentUnits.put(unit.getName(), unit);

            if (logger.isLoggable(Level.FINE)) {
                logger.fine("Loaded " + unit + " with " + size + " states");
            }
View Full Code Here

            SenoneHMM hmm = (SenoneHMM)hmm0;
            if (hmm.isContextDependent()) {
                continue;
            }

            Unit unit = hmm.getUnit();

            String name = unit.getName();
            pw.print(name + '\t');
            String left = "-";
            pw.print(left + "   ");
            String right = "-";
            pw.print(right + ' ');
            String position = hmm.getPosition().toString();
            pw.print(position + '\t');
            String attribute = unit.isFiller() ? FILLER : "n/a";
            pw.print(attribute + '\t');
            int tmat = matrixPool.indexOf(hmm.getTransitionMatrix());
            assert tmat < numTiedTransitionMatrices;
            pw.print(tmat + "\t");

            SenoneSequence ss = hmm.getSenoneSequence();
            Senone[] senones = ss.getSenones();
            for (Senone senone : senones) {
                int index = senonePool.indexOf(senone);
                assert index >= 0 && index < numContextIndependentTiedState;
                pw.print(index + "\t");
            }
            pw.println("N");

            if (logger.isLoggable(Level.FINE)) {
                logger.fine("Saved " + unit);
            }

        }

        // Save the context dependent phones.

        for (HMM hmm0 : hmmManager) {
            SenoneHMM hmm = (SenoneHMM)hmm0;
            if (!hmm.isContextDependent()) {
                continue;
            }

            Unit unit = hmm.getUnit();
            LeftRightContext context = (LeftRightContext)unit.getContext();
            Unit[] leftContext = context.getLeftContext();
            Unit[] rightContext = context.getRightContext();
            assert leftContext.length == 1 && rightContext.length == 1;

            String name = unit.getName();
            pw.print(name + '\t');
            String left = leftContext[0].getName();
            pw.print(left + "   ");
            String right = rightContext[0].getName();
            pw.print(right + ' ');
            String position = hmm.getPosition().toString();
            pw.print(position + '\t');
            String attribute = unit.isFiller() ? FILLER : "n/a";
            assert attribute.equals("n/a");
            pw.print(attribute + '\t');
            int tmat = matrixPool.indexOf(hmm.getTransitionMatrix());
            assert tmat < numTiedTransitionMatrices;
            pw.print(tmat + "\t");
View Full Code Here

TOP

Related Classes of edu.cmu.sphinx.linguist.acoustic.Unit

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.