语音项目记录写实2
2019獨(dú)角獸企業(yè)重金招聘Python工程師標(biāo)準(zhǔn)>>>
經(jīng)過一天的查找,實(shí)驗(yàn),對(duì)比,最終決定使用sphinx-4作為此項(xiàng)目的核心組件,一切聲音數(shù)據(jù)都交由其處理,在sphinx-4的官網(wǎng)上看了一下sphinx-4主要構(gòu)成,用一張圖解釋:接下來用一個(gè)helloworld來解釋一下各個(gè)組件的作用: package edu.cmu.sphinx.demo.helloworld;import edu.cmu.sphinx.frontend.util.Microphone; import edu.cmu.sphinx.recognizer.Recognizer; import edu.cmu.sphinx.result.Result; import edu.cmu.sphinx.util.props.ConfigurationManager;/*** A simple HelloWorld demo showing a simple speech application built using Sphinx-4. This application uses the Sphinx-4* endpointer, which automatically segments incoming audio into utterances and silences.*/ public class HelloWorld {public static void main(String[] args) {ConfigurationManager cm;if (args.length > 0) {cm = new ConfigurationManager(args[0]);} else {cm = new ConfigurationManager(HelloWorld.class.getResource("helloworld.config.xml"));}Recognizer recognizer = (Recognizer) cm.lookup("recognizer");recognizer.allocate();// start the microphone or exit if the programm if this is not possibleMicrophone microphone = (Microphone) cm.lookup("microphone");if (!microphone.startRecording()) {System.out.println("Cannot start microphone.");recognizer.deallocate();System.exit(1);}System.out.println("Say: (Good morning | Hello) ( Bhiksha | Evandro | Paul | Philip | Rita | Will )");// loop the recognition until the programm exits.while (true) {System.out.println("Start speaking. Press Ctrl-C to quit.\n");Result result = recognizer.recognize();if (result != null) {String resultText = result.getBestFinalResultNoFiller();System.out.println("You said: " + resultText + '\n');} else {System.out.println("I can't hear what you said.\n");}}} }
當(dāng)然sphinx-4自身還帶有很多有趣的sample有興趣的讀者可以去運(yùn)行一下,由于本人沒有麥,只能看在眼攙了。 接下來就要規(guī)劃以下my project了,明天繼續(xù),功能分析。
轉(zhuǎn)載于:https://my.oschina.net/pkm2012/blog/75740
總結(jié)
- 上一篇: 通过PXE启动rescue模式修复丢失的
- 下一篇: 【原創】WinMo之移動今日插件