如何设置声学模型的路径?最后没有工作。请帮我 [英] How can I set path of acoustic model ? last didnt work. Please help me
问题描述
import edu.cmu.sphinx.api.Configuration;
import edu.cmu.sphinx.api.LiveSpeechRecognizer;
import edu.cmu.sphinx.api。 SpeechResult;
import java.io.IOException;
public class VoiceLauncher {
public static void main( String [] args)抛出IOException {
//配置对象
配置配置=新配置();
//设置声学模型的路径。
configuration.setAcousticModelPath(resource:/ edu / cmu / sphinx / models / en-us / en-us);
//设置字典的路径。
configuration.setDictionaryPath(cmudict-en-us.dict);
//设置语言模型的路径。
configuration.setLanguageModelPath(en-us.lm.bin);
//识别器对象,传递配置对象
LiveSpeechRecognizer识别=新的LiveSp eechRecognizer(配置);
//开始识别过程(如果为真,则bool参数清除先前的缓存)
recogn.startRecognition(true );
//创建SpeechResult对象
SpeechResult结果;
//检查识别器是否识别语音
while((result = recogn.getResult())!= null){
//获得认可的演讲
String command = result.getHypothesis();
String work = null;
处理p;
//来自我的语料库文件的一些额外命令
if(command.equalsIgnoreCase(open search)){
work =google-chrome http://www.google.com;
}否则if(command.equalsIgnoreCase(new tab)){
work =google-chrome \\c;
}否则if(command.equalsIgnoreCase(open mail)){
work =google-chrome gmail.com;
}否则if(command.equalsIgnoreCase(open in in)){
work =google-chrome linkedin.com;
} else if(command.equalsIgnoreCase(open blog)){
work =google-chrome procurity.wordpress.com;
} else if(command.equalsIgnoreCase(open git hub)){
work =google-chrome github.com/Ex094;
} else if(command .equalsIgnoreCase(browser)){
work =google-chrome;
} else if(command.equalsIgnoreCase(terminal)){
work =gnome-terminal;
}否则if(command.equalsIgnoreCase(file manager)){
work =nautilu s;
}
if(work!= null){
p = Runtime.getRuntime() .exec(工作);
}
}
}
< br $>
}
错误是: -
import edu.cmu.sphinx.api.Configuration;
import edu.cmu.sphinx.api.LiveSpeechRecognizer;
import edu.cmu.sphinx.api.SpeechResult;
import java.io.IOException;
public class VoiceLauncher {
public static void main(String[] args) throws IOException {
//Configuration Object
Configuration configuration = new Configuration();
// Set path to the acoustic model.
configuration.setAcousticModelPath("resource:/edu/cmu/sphinx/models/en-us/en-us");
// Set path to the dictionary.
configuration.setDictionaryPath("cmudict-en-us.dict");
// Set path to the language model.
configuration.setLanguageModelPath("en-us.lm.bin");
//Recognizer object, Pass the Configuration object
LiveSpeechRecognizer recognize = new LiveSpeechRecognizer(configuration);
//Start Recognition Process (The bool parameter clears the previous cache if true)
recognize.startRecognition(true);
//Creating SpeechResult object
SpeechResult result;
//Check if recognizer recognized the speech
while ((result = recognize.getResult()) != null) {
//Get the recognized speech
String command = result.getHypothesis();
String work = null;
Process p;
//Some Extra Commands from my Corpus File
if(command.equalsIgnoreCase("open search")) {
work = "google-chrome http://www.google.com";
} else if (command.equalsIgnoreCase("new tab")) {
work = "google-chrome \\c";
} else if (command.equalsIgnoreCase("open mail")) {
work = "google-chrome gmail.com";
} else if (command.equalsIgnoreCase("open linked in")) {
work = "google-chrome linkedin.com";
} else if (command.equalsIgnoreCase("open blog")) {
work = "google-chrome procurity.wordpress.com";
} else if (command.equalsIgnoreCase("open git hub")) {
work = "google-chrome github.com/Ex094";
} else if (command.equalsIgnoreCase("browser")) {
work = "google-chrome";
} else if (command.equalsIgnoreCase("terminal")) {
work = "gnome-terminal";
} else if (command.equalsIgnoreCase("file manager")) {
work = "nautilus";
}
if(work != null) {
p = Runtime.getRuntime().exec(work);
}
}
}
}
error is:-
erro is :-
<pre>18:32:41.511 INFO unitManager CI Unit: *+NSN+
18:32:41.518 INFO unitManager CI Unit: *+SPN+
18:32:41.520 INFO unitManager CI Unit: AA
18:32:41.524 INFO unitManager CI Unit: AE
18:32:41.526 INFO unitManager CI Unit: AH
18:32:41.526 INFO unitManager CI Unit: AO
18:32:41.527 INFO unitManager CI Unit: AW
18:32:41.527 INFO unitManager CI Unit: AY
18:32:41.527 INFO unitManager CI Unit: B
18:32:41.528 INFO unitManager CI Unit: CH
18:32:41.528 INFO unitManager CI Unit: D
18:32:41.528 INFO unitManager CI Unit: DH
18:32:41.529 INFO unitManager CI Unit: EH
18:32:41.529 INFO unitManager CI Unit: ER
18:32:41.529 INFO unitManager CI Unit: EY
18:32:41.529 INFO unitManager CI Unit: F
18:32:41.530 INFO unitManager CI Unit: G
18:32:41.530 INFO unitManager CI Unit: HH
18:32:41.530 INFO unitManager CI Unit: IH
18:32:41.531 INFO unitManager CI Unit: IY
18:32:41.531 INFO unitManager CI Unit: JH
18:32:41.531 INFO unitManager CI Unit: K
18:32:41.532 INFO unitManager CI Unit: L
18:32:41.532 INFO unitManager CI Unit: M
18:32:41.532 INFO unitManager CI Unit: N
18:32:41.533 INFO unitManager CI Unit: NG
18:32:41.533 INFO unitManager CI Unit: OW
18:32:41.533 INFO unitManager CI Unit: OY
18:32:41.534 INFO unitManager CI Unit: P
18:32:41.534 INFO unitManager CI Unit: R
18:32:41.534 INFO unitManager CI Unit: S
18:32:41.534 INFO unitManager CI Unit: SH
18:32:41.535 INFO unitManager CI Unit: T
18:32:41.535 INFO unitManager CI Unit: TH
18:32:41.536 INFO unitManager CI Unit: UH
18:32:41.536 INFO unitManager CI Unit: UW
18:32:41.536 INFO unitManager CI Unit: V
18:32:41.536 INFO unitManager CI Unit: W
18:32:41.541 INFO unitManager CI Unit: Y
18:32:41.541 INFO unitManager CI Unit: Z
18:32:41.542 INFO unitManager CI Unit: ZH
18:32:43.514 INFO autoCepstrum Cepstrum component auto-configured as follows: autoCepstrum {MelFrequencyFilterBank, Denoise, DiscreteCosineTransform2, Lifter}
18:32:43.872 INFO dictionary Loading dictionary from: file:cmudict-en-us.dict
Exception in thread "main" java.lang.RuntimeException: Allocation of search manager resources failed
at edu.cmu.sphinx.decoder.search.WordPruningBreadthFirstSearchManager.allocate(WordPruningBreadthFirstSearchManager.java:247)
at edu.cmu.sphinx.decoder.AbstractDecoder.allocate(AbstractDecoder.java:103)
at edu.cmu.sphinx.recognizer.Recognizer.allocate(Recognizer.java:164)
at edu.cmu.sphinx.api.LiveSpeechRecognizer.startRecognition(LiveSpeechRecognizer.java:47)
at voicelauncher.VoiceLauncher.main(VoiceLauncher.java:35)
Caused by: java.io.FileNotFoundException: cmudict-en-us.dict (The system cannot find the file specified)
at java.io.FileInputStream.open0(Native Method)
at java.io.FileInputStream.open(FileInputStream.java:195)
at java.io.FileInputStream.<init>(FileInputStream.java:138)
at java.io.FileInputStream.<init>(FileInputStream.java:93)
at sun.net.www.protocol.file.FileURLConnection.connect(FileURLConnection.java:90)
at sun.net.www.protocol.file.FileURLConnection.getInputStream(FileURLConnection.java:188)
at java.net.URL.openStream(URL.java:1045)
at edu.cmu.sphinx.linguist.dictionary.TextDictionary.allocate(TextDictionary.java:180)
at edu.cmu.sphinx.linguist.lextree.LexTreeLinguist.allocate(LexTreeLinguist.java:332)
at edu.cmu.sphinx.decoder.search.WordPruningBreadthFirstSearchManager.allocate(WordPruningBreadthFirstSearchManager.java:243)
... 4 more
C:\Users\SP\AppData\Local\NetBeans\Cache\8.1\executor-snippets\run.xml:53: Java returned: 1
BUILD FAILED (total time: 6 seconds)
我尝试了什么:
设置路径bt仍然无法正常工作..
What I have tried:
set the path bt still it didnt work..
推荐答案
错误很明显:
The error is quite clear:
java.io.FileNotFoundException: cmudict-en-us.dict
您已指定了纯文件名,但必须指定文件或资源的完整路径。
You have specified a plain file name but you have to specify the full path for a file or resource.
这篇关于如何设置声学模型的路径?最后没有工作。请帮我的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!