• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Result类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中edu.cmu.sphinx.result.Result的典型用法代码示例。如果您正苦于以下问题:Java Result类的具体用法?Java Result怎么用?Java Result使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Result类属于edu.cmu.sphinx.result包,在下文中一共展示了Result类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: run

import edu.cmu.sphinx.result.Result; //导入依赖的package包/类
/**
 * Performs a single recognition
 */
public void run() {
    if (recognizer != null && microphone != null) {
        automaton.updateStatus(_LISTENING_FOR_COMMAND);
        microphone.clear();
        microphone.startRecording();
        Result result = recognizer.recognize();
        microphone.stopRecording();

        if (result != null) {
            String resultText = result.getBestFinalResultNoFiller();
            String phrase = resultText.trim().toUpperCase();
            fireListeners(phrase);
        }
    }
}
 
开发者ID:jontsai,项目名称:HomeAutomationJava,代码行数:19,代码来源:SpeechRecognition.java


示例2: newResult

import edu.cmu.sphinx.result.Result; //导入依赖的package包/类
@Override
public void newResult(final Result result) {
    if (result == null)
        return;

    int max = -1;
    for (final String word : result.toString().split(" ")) {
        for (int i = start; i < start + step && i < tokens.size(); i++) {
            if (tokens.get(i).equals(word)) {
                max = i;
                break;
            }
        }
    }
    if (max > 0) {
        start = max;
        newGrammar();
        createGrammar();
        postProcessGrammar();
    }
}
 
开发者ID:juanma2268,项目名称:jumbertoTeia2600,代码行数:22,代码来源:TextAlignerGrammar.java


示例3: decode

import edu.cmu.sphinx.result.Result; //导入依赖的package包/类
public void decode() {

        try {
            utteranceId = 0;
            DataOutputStream ctm = new DataOutputStream(new FileOutputStream(ctmFile));
            recognizer.allocate();

            for (Iterator<CTLUtterance> i = new CTLIterator(); i.hasNext();) {
                CTLUtterance utt = i.next();
                setInputStream(utt);
                Result result = recognizer.recognize();
                System.out.println("Utterance " + utteranceId + ": " + utt.getName());
                System.out.println("Reference: " + utt.getRef());
                System.out.println("Result   : " + result);
                logger.info("Utterance " + utteranceId + ": " + utt.getName());
                logger.info("Result   : " + result);
                handleResult(ctm, utt, result);
                utteranceId++;
            }

            recognizer.deallocate();
        } catch (IOException io) {
            logger.severe("I/O error during decoding: " + io.getMessage());
        }
        logger.info("BatchCTLDecoder: " + utteranceId + " utterances decoded");
    }
 
开发者ID:juanma2268,项目名称:jumbertoTeia2600,代码行数:27,代码来源:BatchNISTRecognizer.java


示例4: process

import edu.cmu.sphinx.result.Result; //导入依赖的package包/类
/**
 * Ranks the given set of tokens
 *
 * @param result the result to process
 */
private void process(Result result) {
    if (result.isFinal()) {
        collectStatistics(result);
    } else {
        List<Token> tokenList = result.getActiveTokens().getTokens();
        if (!tokenList.isEmpty()) {
            Collections.sort(tokenList, Scoreable.COMPARATOR);
            Token bestToken = tokenList.get(0);
            int rank = 0;
            for (Token token : tokenList) {
                float scoreDiff = bestToken.getScore() -
                        token.getScore();
                assert scoreDiff >= 0;

                token.getTokenProps().put(TOKEN_RANK, new TokenRank(rank++, scoreDiff));
                assert tokenIsRanked(token);
            }
        }
    }
}
 
开发者ID:juanma2268,项目名称:jumbertoTeia2600,代码行数:26,代码来源:BeamFinder.java


示例5: newResult

import edu.cmu.sphinx.result.Result; //导入依赖的package包/类
@Override
public void newResult(Result result) {
    String ref = result.getReferenceText();
    if (result.isFinal() && ref != null) {
        Lattice lattice = new Lattice(result);
        LatticeOptimizer optimizer = new LatticeOptimizer(lattice);
        optimizer.optimize();           
        lattice.computeNodePosteriors(languageModelWeight);
        SausageMaker sausageMaker = new SausageMaker(lattice);
        Sausage sausage = sausageMaker.makeSausage();
        sausage.removeFillers();
            
        getAligner().alignSausage(ref, sausage);
        showFullPath(result);
        showDetails(result.toString());
    }
}
 
开发者ID:juanma2268,项目名称:jumbertoTeia2600,代码行数:18,代码来源:SausageAccuracyTracker.java


示例6: newResult

import edu.cmu.sphinx.result.Result; //导入依赖的package包/类
@Override
public void newResult(Result result) {
    String ref = result.getReferenceText();
    if (result.isFinal() && ref != null) {
        numUtterances++;
        String hyp = result.getBestResultNoFiller();
        if (ref.equals("<unk>")) {
            numOutOfGrammarUtterances++;
            if (hyp.equals("<unk>")) {
                numCorrectOutOfGrammarUtterances++;
            } else {
                numFalseInGrammarUtterances++;
            }
        } else {
            if (hyp.equals("<unk>")) {
                numFalseOutOfGrammarUtterances++;
            } else {
                numCorrectInGrammarUtterances++;
            }
        }
        printStats();
    }
}
 
开发者ID:juanma2268,项目名称:jumbertoTeia2600,代码行数:24,代码来源:RejectionTracker.java


示例7: run

import edu.cmu.sphinx.result.Result; //导入依赖的package包/类
@Override
public void run()
{
  logger.info("Starting speech recognition");
  startMicrophone();

  while (!threadComponent.isStopped())
  {
    try
    {
      Result result = recognizer.recognize();

      if (result != null)
      {
        processResult(result);
      }
    } catch (RuntimeException e)
    {
      // This happens when the recognizer is deallocated (which only happens when the stop() method was called)
    }
  }

  logger.info("Ending speech recognition");
}
 
开发者ID:theone1984,项目名称:parroteer,代码行数:25,代码来源:SpeechDetector.java


示例8: getTagString

import edu.cmu.sphinx.result.Result; //导入依赖的package包/类
/**
 * Gets a space delimited string of tags representing the result
 * 
 * @param result
 *            the recognition result
 * @return the tag string
 * @throws GrammarException
 *             if there is an error while parsing the result
 */
String getTagString(Result result) throws GrammarException {
	RuleParse ruleParse = getRuleParse(result);
	if (ruleParse == null)
		return null;
	String[] tags = ruleParse.getTags();
	if (tags == null)
		return "";
	StringBuilder sb = new StringBuilder();
	for (String tag : tags)
		sb.append(tag).append(' ');
	return sb.toString().trim();
}
 
开发者ID:glaudiston,项目名称:project-bianca,代码行数:22,代码来源:DialogManager.java


示例9: run

import edu.cmu.sphinx.result.Result; //导入依赖的package包/类
public void run()
{
	Utils.log("debug", "Recognition thread starting");

	while (true == mRecognitionThreadEnabled)
	{
		if (!mMicrophone.isRecording())
		{
			Utils.log("warning", "Recognition thread is running, but " 
				+ "the microphone is disabled.");
		}
		else
		{
               Result result = null;
               try
               {
                   result = mRecognizer.recognize();
               } catch (Throwable t) {}

               if (result != null)
               {
                   String s = result.getBestFinalResultNoFiller();

                   // Only save non-empty strings.
                   if (!s.equals(""))
                   {
                       Utils.log("debug", "Finished recognizing");
                       mRecognizedStringQueue.addLast(s);
                   }
               }

           }

	}

	Utils.log("debug", "Recognition thread finished");
}
 
开发者ID:CreeperHost,项目名称:ModJam4,代码行数:38,代码来源:SpeechRecognizer.java


示例10: recognize

import edu.cmu.sphinx.result.Result; //导入依赖的package包/类
/**
 * Performs recognition for the given number of input frames, or until a 'final' result is generated. This method
 * should only be called when the recognizer is in the <code>allocated</code> state.
 *
 * @param referenceText what was actually spoken
 * @return a recognition result
 * @throws IllegalStateException if the recognizer is not in the <code>ALLOCATED</code> state
 */
public Result recognize(String referenceText) throws IllegalStateException {
    Result result = null;
    checkState(State.READY);
    try {
        setState(State.RECOGNIZING);
        result = decoder.decode(referenceText);
    } finally {
        setState(State.READY);
    }
    return result;
}
 
开发者ID:juanma2268,项目名称:jumbertoTeia2600,代码行数:20,代码来源:Recognizer.java


示例11: decode

import edu.cmu.sphinx.result.Result; //导入依赖的package包/类
/**
 * Decodes the batch of audio files
 */
public void decode(String batchFile) throws IOException {
    BatchItem batchItem;
    int count = 0;
    try {
        recognizer.allocate();
        setBatchFile(batchFile);

        batchManager.start();
        logger.info("BatchDecoder: decoding files in "
                + batchManager.getFilename());

        while (count < utteranceId &&
                (batchItem = batchManager.getNextItem()) != null) {
            setInputStream(batchItem.getFilename());
            Result result = recognizer.recognize(batchItem.getTranscript());
            logger.info("File  : " + batchItem.getFilename());
            logger.info("Result: " + result);
            count++;
        }
        batchManager.stop();
        recognizer.deallocate();
    } catch (IOException io) {
        logger.severe("I/O error during decoding: " + io.getMessage());
        throw io;
    }
    logger.info("BatchDecoder: " + count + " files decoded");
}
 
开发者ID:juanma2268,项目名称:jumbertoTeia2600,代码行数:31,代码来源:BatchModeRecognizer.java


示例12: recognize

import edu.cmu.sphinx.result.Result; //导入依赖的package包/类
public Result recognize() throws IOException {
    Result result = null;
    BatchItem batchItem;
    if (count < utteranceId &&
            (batchItem = batchManager.getNextItem()) != null) {
        setInputStream(batchItem.getFilename());
        result = recognizer.recognize(batchItem.getTranscript());
        logger.info("File  : " + batchItem.getFilename());
        logger.info("Result: " + result);
        count++;
    }
    logger.info("BatchDecoder: " + count + " files decoded");
    return result;
}
 
开发者ID:juanma2268,项目名称:jumbertoTeia2600,代码行数:15,代码来源:BatchModeRecognizer.java


示例13: newResult

import edu.cmu.sphinx.result.Result; //导入依赖的package包/类
@Override
public void newResult(Result result) {
    if (result.isFinal()) {
        processingTime = (getTime() - startTime) / 1000.0f;
        totalAudioTime += audioTime;
        totalProcessingTime += processingTime;
        if (showDetails) {
            showAudioUsage();
        }
    }
}
 
开发者ID:juanma2268,项目名称:jumbertoTeia2600,代码行数:12,代码来源:SpeedTracker.java


示例14: newResult

import edu.cmu.sphinx.result.Result; //导入依赖的package包/类
@Override
public void newResult(Result result) {
    if (enabled) {
        process(result);
        if (result.isFinal() && showDetails) {
            showLatestResult();
        }
    }
}
 
开发者ID:juanma2268,项目名称:jumbertoTeia2600,代码行数:10,代码来源:BeamFinder.java


示例15: collectAbsoluteBeamStatistics

import edu.cmu.sphinx.result.Result; //导入依赖的package包/类
/**
 * Collects the absolute beam statistics
 *
 * @param result the result of interest
 */
private void collectAbsoluteBeamStatistics(Result result) {
    Token token = result.getBestToken();
    int count = 0;
    int sumBeam = 0;
    maxAbsoluteBeam = 0;
    while (token != null) {
        if (token.isEmitting()) {
            TokenRank rank = (TokenRank) token.getTokenProps().get(TOKEN_RANK);
            if (rank != null) {
                if (rank.getAbsoluteRank() > maxAbsoluteBeam) {
                    maxAbsoluteBeam = rank.getAbsoluteRank();
                }
                sumBeam += rank.getAbsoluteRank();
                count++;
            } else {
                if (token.getFrameNumber() > 0) {
                    System.out.println("Null rank! for " + token);
                }
            }
        }
        token = token.getPredecessor();
    }

    if (count > 0) {
        avgAbsoluteBeam = sumBeam / count;
        if (maxAbsoluteBeam > totMaxAbsoluteBeam) {
            totMaxAbsoluteBeam = maxAbsoluteBeam;
        }
        sumAbsoluteBeam += avgAbsoluteBeam;
    }
}
 
开发者ID:juanma2268,项目名称:jumbertoTeia2600,代码行数:37,代码来源:BeamFinder.java


示例16: collectRelativeBeamStatistics

import edu.cmu.sphinx.result.Result; //导入依赖的package包/类
/**
 * Returns the maximum relative beam for a the chain of tokens reachable from the given token
 *
 * @param result the result of interest
 */
private void collectRelativeBeamStatistics(Result result) {
    Token token = result.getBestToken();
    int count = 0;
    double sumBeam = 0.0;

    maxRelativeBeam = -Float.MAX_VALUE;

    while (token != null) {
        if (token.isEmitting()) {
            TokenRank rank = (TokenRank) token.getTokenProps().get(TOKEN_RANK);
            if (rank != null) {
                if (rank.getRelativeRank() > maxRelativeBeam) {
                    maxRelativeBeam = rank.getRelativeRank();
                }
                sumBeam += rank.getRelativeRank();
                count++;
            } else {
                if (token.getFrameNumber() > 0) {
                    System.out.println("Null rank! for " + token);
                }
            }
        }
        token = token.getPredecessor();
    }

    if (count > 0) {
        avgRelativeBeam = (float) (sumBeam / count);
        if (maxRelativeBeam > totMaxRelativeBeam) {
            totMaxRelativeBeam = maxRelativeBeam;
        }
        sumRelativeBeam += avgRelativeBeam;
    }
}
 
开发者ID:juanma2268,项目名称:jumbertoTeia2600,代码行数:39,代码来源:BeamFinder.java


示例17: showFullPath

import edu.cmu.sphinx.result.Result; //导入依赖的package包/类
/**
 * Dumps the best path
 *
 * @param result the result to dump
 */
private void showFullPath(Result result) {
    if (showFullPath) {
        System.out.println();
        Token bestToken = result.getBestToken();
        if (bestToken != null) {
            bestToken.dumpTokenPath();
        } else {
            System.out.println("Null result");
        }
        System.out.println();
    }
}
 
开发者ID:juanma2268,项目名称:jumbertoTeia2600,代码行数:18,代码来源:SausageAccuracyTracker.java


示例18: newResult

import edu.cmu.sphinx.result.Result; //导入依赖的package包/类
@Override
public void newResult(Result result) {
    String ref = result.getReferenceText();
    if (result.isFinal() && ref != null) {
        String hyp = result.getBestResultNoFiller();
        getAligner().align(ref, hyp);
        showFullPath(result);
        showDetails(result.toString());
    }
}
 
开发者ID:juanma2268,项目名称:jumbertoTeia2600,代码行数:11,代码来源:BestPathAccuracyTracker.java


示例19: fireResultListeners

import edu.cmu.sphinx.result.Result; //导入依赖的package包/类
/**
 * Fires new results as soon as they become available.
 *
 * @param result the new result
 */
protected void fireResultListeners(Result result) {
    if (fireNonFinalResults || result.isFinal()) {
        for (ResultListener resultListener : resultListeners) {
            resultListener.newResult(result);
        }
    }else {
        logger.finer("skipping non-final result " + result);
    }
}
 
开发者ID:juanma2268,项目名称:jumbertoTeia2600,代码行数:15,代码来源:AbstractDecoder.java


示例20: decode

import edu.cmu.sphinx.result.Result; //导入依赖的package包/类
/**
 * Decode frames until recognition is complete.
 *
 * @param referenceText the reference text (or null)
 * @return a result
 */
@Override
public Result decode(String referenceText) {
    searchManager.startRecognition();
    Result result;
    do {
        result = searchManager.recognize(featureBlockSize);
        if (result != null) {
            result.setReferenceText(referenceText);
            fireResultListeners(result);
        }
    } while (result != null && !result.isFinal());
    searchManager.stopRecognition();
    return result;
}
 
开发者ID:juanma2268,项目名称:jumbertoTeia2600,代码行数:21,代码来源:Decoder.java



注:本文中的edu.cmu.sphinx.result.Result类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java PitchDetectionHandler类代码示例发布时间:2022-05-22
下一篇:
Java ItemDeleteListener类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap