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

Java SpeechResult类代码示例

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

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



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

示例1: transcribe

import edu.cmu.sphinx.api.SpeechResult; //导入依赖的package包/类
/**
 * Tries to predict the speech in a given audio fragment
 * @param audioStream the audio stream on which speech prediction is desired
 * @return the hypotheses of the speech in the given audio fragment
 * as a list of words
 * @throws IOException when the config does not point to correct
 * files needed for the transcription
 */
public ArrayList<WordResult> transcribe(InputStream audioStream)
        throws IOException
{
    StreamSpeechRecognizer recognizer = new StreamSpeechRecognizer(config);
    recognizer.startRecognition(audioStream);

    ArrayList<WordResult> utteredWords = new ArrayList<>();
    SpeechResult result;
    while ((result = recognizer.getResult()) != null)
    {
        utteredWords.addAll(result.getWords());
    }
    recognizer.stopRecognition();

    return utteredWords;
}
 
开发者ID:jitsi,项目名称:Sphinx4-HTTP-server,代码行数:25,代码来源:AudioTranscriber.java


示例2: onRun

import edu.cmu.sphinx.api.SpeechResult; //导入依赖的package包/类
@Override
protected void onRun() {
    while (true) {
        SpeechResult result = recognizer.getResult();
        if (result != null) {
            String resultText = result.getHypothesis();
            setDescription("You said: " + resultText);
            if (!resultText.trim().isEmpty()) {
                Command nlpCommand = new Command();
                nlpCommand.setName("Natuaral language command");
                nlpCommand.setDescription("A free-form text command to be interpreded by an NLP module");
                nlpCommand.setProperty("text", resultText);
                nlpCommand.setReplyTimeout(2000);
                Command reply = notifyCommand(nlpCommand);
                if (reply != null) {
                    setDescription("No valid command similar to '" + resultText + "'");
                }
            }
        } else {
            setDescription("I can't undestand what you said");
        }
    }
}
 
开发者ID:freedomotic,项目名称:freedomotic,代码行数:24,代码来源:SpeechRecognition.java


示例3: hear

import edu.cmu.sphinx.api.SpeechResult; //导入依赖的package包/类
public String hear()
{
  recognizer.startRecognition(true);
  SpeechResult result;
  String output = "";
  while((result = recognizer.getResult()) != null)
  {
    output = result.getHypothesis();
    if(output != null && !output.isEmpty() && !output.equalsIgnoreCase("<unk>"))
      break;
  }
  recognizer.stopRecognition();
  return output;
}
 
开发者ID:ldilley,项目名称:frank,代码行数:15,代码来源:Hearing.java


示例4: transcribeSynchronous

import edu.cmu.sphinx.api.SpeechResult; //导入依赖的package包/类
/**
 * Tries the predict the speech in a given audio fragment. It
 * will offer the result of every predicted word to a SynchronousQueue,
 * to be processed immediately
 * @param audioStream the audio fragment to transcribe
 * @param queue the queue to offer every WordResult to
 * @throws IOException when the config does not point to correct
 * files needed for the transcription
 */
public void transcribeSynchronous(InputStream audioStream,
                                  SynchronousQueue<WordResult> queue)
    throws IOException
{
    StreamSpeechRecognizer recognizer = new StreamSpeechRecognizer(config);
    recognizer.startRecognition(audioStream);

    logger.trace("Started chunked transcription");
    SpeechResult result;
    while( (result = recognizer.getResult()) != null)
    {
        logger.trace("got a word result of length {}",
                result.getWords().size());

        for(WordResult word : result.getWords())
        {
            logger.trace("offering {}", word.toString());
            try
            {
                queue.put(word);
            }
            catch (InterruptedException e)
            {
                e.printStackTrace();
            }
        }
    }
    recognizer.stopRecognition();
}
 
开发者ID:jitsi,项目名称:Sphinx4-HTTP-server,代码行数:39,代码来源:AudioTranscriber.java


示例5: getSpeechResult

import edu.cmu.sphinx.api.SpeechResult; //导入依赖的package包/类
public String getSpeechResult() {
	// Start recognition process pruning previously cached data.

	recognizer.startRecognition(true);

	String speech_text = "";
	SpeechResult result = null;

	System.out.println("Listening...");

	while ((result = recognizer.getResult()) != null) {
		speech_text = result.getHypothesis();
		String org_text = speech_text;
		speech_text = efilter.Filter(speech_text);
		System.out.println(speech_text);
		// System.out.println(cmd_classifier.PredictRawString(speech_text));
		
		System.out.println(dep_parser.getPaser(speech_text));
		System.out.println(urlgen.GetUrl(
				cmd_classifier.PredictRawString(org_text),
				speech_text,
				dep_parser.getSemanticGraph(speech_text)));

		System.out.println("Listening...");
	}

	// Pause recognition process. It can be resumed then with
	// startRecognition(false).
	recognizer.stopRecognition();

	return speech_text;

}
 
开发者ID:hwang033,项目名称:tcvr,代码行数:34,代码来源:SpeechRecognize.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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