public virtual Map load() { try { try { try { SAXParserFactory saxparserFactory = SAXParserFactory.newInstance(); XMLReader xmlreader = saxparserFactory.newSAXParser().getXMLReader(); ConfigHandler contentHandler = new ConfigHandler(this.rpdMap, this.globalProperties, this.replaceDuplicates, this.url); xmlreader.setContentHandler(contentHandler); xmlreader.parse(this.url.toString()); } catch (SAXParseException ex) { throw new IOException(new StringBuilder().append("Error while parsing line ").append(ex.getLineNumber()).append(" of ").append(this.url).append(": ").append(ex.getMessage()).toString()); } } catch (SAXException ex3) { throw new IOException(new StringBuilder().append("Problem with XML: ").append(ex3).toString()); } } catch (ParserConfigurationException ex5) { throw new IOException(Throwable.instancehelper_getMessage(ex5)); } return(this.rpdMap); }
protected internal virtual void loadXML() { try { try { try { SAXParserFactory saxparserFactory = SAXParserFactory.newInstance(); XMLReader xmlreader = saxparserFactory.newSAXParser().getXMLReader(); this.rules = new HashMap(); GrXMLHandler grXMLHandler = new GrXMLHandler(this.baseURL, this.rules, this.logger); xmlreader.setContentHandler(grXMLHandler); xmlreader.setErrorHandler(grXMLHandler); InputStream inputStream = this.baseURL.openStream(); xmlreader.parse(new InputSource(inputStream)); inputStream.close(); } catch (SAXParseException ex) { throw new IOException(new StringBuilder().append("Error while parsing line ").append(ex.getLineNumber()).append(" of ").append(this.baseURL).append(": ").append(ex.getMessage()).toString()); } } catch (SAXException ex3) { throw new IOException(new StringBuilder().append("Problem with XML: ").append(ex3).toString()); } } catch (ParserConfigurationException ex5) { throw new IOException(Throwable.instancehelper_getMessage(ex5)); } }
private int getNextChar() { if (this.reader != null) { try { int num = this.reader.read(); if (num == EOF) { this.currentChar = EOF; } else { this.currentChar = (int)((ushort)num); } } catch (IOException ex) { this.currentChar = EOF; this.errorDescription = Throwable.instancehelper_getMessage(ex); } } else if (this.inputText != null) { if (this.currentPosition < String.instancehelper_length(this.inputText)) { this.currentChar = (int)String.instancehelper_charAt(this.inputText, this.currentPosition); } else { this.currentChar = EOF; } } if (this.currentChar != EOF) { this.currentPosition++; } if (this.currentChar == 10) { this.lineNumber++; } return(this.currentChar); }
private BatchNISTRecognizer.CTLUtterance nextUtterance() { BatchNISTRecognizer.CTLUtterance result; try { string text = this.ctlReader.readLine(); string text2 = this.refReader.readLine(); if (text != null && text2 != null) { return(new BatchNISTRecognizer.CTLUtterance(this.this_0, text, text2)); } result = null; } catch (System.Exception ex) { throw new Error(Throwable.instancehelper_getMessage(ex)); } return(result); }
protected internal virtual void ExpandBuff(bool wrapAround) { char[] array = new char[this.bufsize + 2048]; int[] array2 = new int[this.bufsize + 2048]; int[] array3 = new int[this.bufsize + 2048]; try { if (wrapAround) { ByteCodeHelper.arraycopy_primitive_2(this.buffer, this.tokenBegin, array, 0, this.bufsize - this.tokenBegin); ByteCodeHelper.arraycopy_primitive_2(this.buffer, 0, array, this.bufsize - this.tokenBegin, this.bufpos); this.buffer = array; ByteCodeHelper.arraycopy_primitive_4(this.bufline, this.tokenBegin, array2, 0, this.bufsize - this.tokenBegin); ByteCodeHelper.arraycopy_primitive_4(this.bufline, 0, array2, this.bufsize - this.tokenBegin, this.bufpos); this.bufline = array2; ByteCodeHelper.arraycopy_primitive_4(this.bufcolumn, this.tokenBegin, array3, 0, this.bufsize - this.tokenBegin); ByteCodeHelper.arraycopy_primitive_4(this.bufcolumn, 0, array3, this.bufsize - this.tokenBegin, this.bufpos); this.bufcolumn = array3; this.bufpos += this.bufsize - this.tokenBegin; } else { ByteCodeHelper.arraycopy_primitive_2(this.buffer, this.tokenBegin, array, 0, this.bufsize - this.tokenBegin); this.buffer = array; ByteCodeHelper.arraycopy_primitive_4(this.bufline, this.tokenBegin, array2, 0, this.bufsize - this.tokenBegin); this.bufline = array2; ByteCodeHelper.arraycopy_primitive_4(this.bufcolumn, this.tokenBegin, array3, 0, this.bufsize - this.tokenBegin); this.bufcolumn = array3; this.bufpos -= this.tokenBegin; } } catch (System.Exception ex) { throw new Error(Throwable.instancehelper_getMessage(ex), ex); } int num = this.bufsize + 2048; int num2 = num; this.bufsize = num; this.available = num2; this.tokenBegin = 0; }
public string execute(CommandInterpreter commandInterpreter, string[] array) { Result result = null; if (array.Length < 2) { commandInterpreter.putResponse("Usage: recognize audio [transcript]"); } else { string inputStream = array[1]; string referenceText = null; if (array.Length > 2) { referenceText = array[2]; } try { this.this_0.setInputStream(inputStream); result = this.this_0.recognizer.recognize(referenceText); } catch (IOException ex) { commandInterpreter.putResponse(new StringBuilder().append("I/O error during decoding: ").append(Throwable.instancehelper_getMessage(ex)).toString()); } } return((result == null) ? "" : result.getBestResultNoFiller()); }
public virtual void shell(string batchfile) { try { CommandInterpreter commandInterpreter = new CommandInterpreter(); commandInterpreter.setPrompt("s4> "); this.addCommands(commandInterpreter); this.setBatchFile(batchfile); this.recognizer.allocate(); commandInterpreter.run(); this.batchManager.stop(); if (this.recognizer.getState() == Recognizer.State.__READY) { this.recognizer.deallocate(); } } catch (IOException ex) { this.logger.severe(new StringBuilder().append("I/O error during decoding: ").append(Throwable.instancehelper_getMessage(ex)).toString()); throw ex; } }
public virtual void decode(string batchFile) { int num = 0; try { this.recognizer.allocate(); this.setBatchFile(batchFile); this.batchManager.start(); this.logger.info(new StringBuilder().append("BatchDecoder: decoding files in ").append(this.batchManager.getFilename()).toString()); BatchItem nextItem; while (num < this.utteranceId && (nextItem = this.batchManager.getNextItem()) != null) { this.setInputStream(nextItem.getFilename()); Result result = this.recognizer.recognize(nextItem.getTranscript()); this.logger.info(new StringBuilder().append("File : ").append(nextItem.getFilename()).toString()); this.logger.info(new StringBuilder().append("Result: ").append(result).toString()); num++; } this.batchManager.stop(); this.recognizer.deallocate(); } catch (IOException ex) { this.logger.severe(new StringBuilder().append("I/O error during decoding: ").append(Throwable.instancehelper_getMessage(ex)).toString()); throw ex; } this.logger.info(new StringBuilder().append("BatchDecoder: ").append(num).append(" files decoded").toString()); }
internal CTLUtterance(BatchNISTRecognizer batchNISTRecognizer, string text, string text2) { this_0 = batchNISTRecognizer; this.@ref = text2; string[] array = String.instancehelper_split(text, " "); if (array.Length != 4) { string text3 = new StringBuilder().append("CTL Syntax Error: ").append(text).toString(); throw new BatchNISTRecognizer.CTLException(batchNISTRecognizer, text3); } this.startOffset = Integer.parseInt(array[1]); this.endOffset = Integer.parseInt(array[2]); this.name = array[3]; this.data = new byte[(this.endOffset - this.startOffset) * batchNISTRecognizer.bytesPerFrame]; int num = String.instancehelper_indexOf(array[0], 46); this.file = array[0]; if (num >= 0) { this.file = String.instancehelper_substring(this.file, 0, num); } this.file = new StringBuilder().append(batchNISTRecognizer.dataDir).append('/').append(this.file).append(".raw").toString(); try { FileInputStream fileInputStream = new FileInputStream(this.file); fileInputStream.skip((long)(this.startOffset * batchNISTRecognizer.bytesPerFrame)); if (fileInputStream.read(this.data) != this.data.Length) { fileInputStream.close(); string text4 = new StringBuilder().append("Unable to read ").append(this.data.Length).append(" bytes of utterance ").append(this.name).toString(); throw new BatchNISTRecognizer.CTLException(batchNISTRecognizer, text4); } fileInputStream.close(); } catch (IOException ex) { throw new BatchNISTRecognizer.CTLException(batchNISTRecognizer, new StringBuilder().append("Unable to read utterance ").append(this.name).append(": ").append(Throwable.instancehelper_getMessage(ex)).toString()); } }
private bool open() { TargetDataLine targetDataLine = this.getAudioLine(); if (targetDataLine != null) { if (!targetDataLine.isOpen()) { this.logger.info("open"); try { targetDataLine.open(this.finalFormat, this.audioBufferSize); } catch (LineUnavailableException ex) { this.logger.severe(new StringBuilder().append("Can't open microphone ").append(Throwable.instancehelper_getMessage(ex)).toString()); return(false); } this.audioStream = new AudioInputStream(targetDataLine); if (this.doConversion) { this.audioStream = AudioSystem.getAudioInputStream(this.desiredFormat, this.audioStream); if (!Microphone.assertionsDisabled && this.audioStream == null) { throw new AssertionError(); } } float num = (float)this.msecPerRead / 1000f; this.frameSizeInBytes = this.audioStream.getFormat().getSampleSizeInBits() / 8 * ByteCodeHelper.f2i(num * this.audioStream.getFormat().getSampleRate()) * this.desiredFormat.getChannels(); this.logger.info(new StringBuilder().append("Frame size: ").append(this.frameSizeInBytes).append(" bytes").toString()); return(true); } return(true); } this.logger.severe("Can't find microphone"); return(false); }
public virtual void decode() { try { this.utteranceId = 0; DataOutputStream @out = new DataOutputStream(new FileOutputStream(this.ctmFile)); this.recognizer.allocate(); BatchNISTRecognizer.CTLIterator ctliterator = new BatchNISTRecognizer.CTLIterator(this); while (ctliterator.hasNext()) { BatchNISTRecognizer.CTLUtterance ctlutterance = (BatchNISTRecognizer.CTLUtterance)ctliterator.next(); this.setInputStream(ctlutterance); Result result = this.recognizer.recognize(); [email protected](new StringBuilder().append("Utterance ").append(this.utteranceId).append(": ").append(ctlutterance.getName()).toString()); [email protected](new StringBuilder().append("Reference: ").append(ctlutterance.getRef()).toString()); [email protected](new StringBuilder().append("Result : ").append(result).toString()); this.logger.info(new StringBuilder().append("Utterance ").append(this.utteranceId).append(": ").append(ctlutterance.getName()).toString()); this.logger.info(new StringBuilder().append("Result : ").append(result).toString()); this.handleResult(@out, ctlutterance, result); this.utteranceId++; } this.recognizer.deallocate(); } catch (IOException ex) { this.logger.severe(new StringBuilder().append("I/O error during decoding: ").append(Throwable.instancehelper_getMessage(ex)).toString()); } this.logger.info(new StringBuilder().append("BatchCTLDecoder: ").append(this.utteranceId).append(" utterances decoded").toString()); }
public static void main(string[] argv) { if (argv.Length != 1) { [email protected]("Usage: LiveModeRecognizer config-file.xml "); java.lang.System.exit(1); } string text = argv[0]; LiveModeRecognizer liveModeRecognizer; try { try { URL url = new File(text).toURI().toURL(); ConfigurationManager configurationManager = new ConfigurationManager(url); liveModeRecognizer = (LiveModeRecognizer)configurationManager.lookup("live"); } catch (IOException ex) { java.lang.System.err.println(new StringBuilder().append("I/O error during initialization: \n ").append(ex).toString()); return; } } catch (PropertyException ex3) { Throwable.instancehelper_printStackTrace(ex3); return; } if (liveModeRecognizer == null) { java.lang.System.err.println(new StringBuilder().append("Can't find liveModeRecognizer in ").append(text).toString()); return; } try { liveModeRecognizer.decode(); } catch (IOException ex5) { java.lang.System.err.println(new StringBuilder().append("I/O error during decoding: ").append(Throwable.instancehelper_getMessage(ex5)).toString()); } }
public override string toString() { return(new StringBuilder().append("Property exception component:'").append(this.instanceName).append("' property:'").append(this.propertyName).append("' - ").append(Throwable.instancehelper_getMessage(this)).append('\n').append(base.toString()).toString()); }
public override void run() { this.totalSamplesRead = 0L; Microphone.access_200(this.this_0).info("started recording"); if (Microphone.access_300(this.this_0)) { Microphone.access_402(this.this_0, new Utterance("Microphone", Microphone.access_500(this.this_0).getFormat())); } Microphone.access_700(this.this_0).add(new DataStartSignal(Microphone.access_600(this.this_0))); Microphone.access_800(this.this_0).info("DataStartSignal added"); IOException ex2; try { Microphone.access_100(this.this_0).start(); while (!this.done) { Data data = this.readData(Microphone.access_400(this.this_0)); if (data == null) { this.done = true; break; } Microphone.access_700(this.this_0).add(data); } Microphone.access_100(this.this_0).flush(); if (Microphone.access_900(this.this_0)) { Microphone.access_500(this.this_0).close(); Microphone.access_100(this.this_0).close(); java.lang.System.err.println("set to null"); Microphone.access_102(this.this_0, null); } } catch (IOException ex) { ex2 = ex; goto IL_138; } goto IL_173; IL_138: IOException ex3 = ex2; Microphone.access_1000(this.this_0).warning(new StringBuilder().append("IO Exception ").append(Throwable.instancehelper_getMessage(ex3)).toString()); Throwable.instancehelper_printStackTrace(ex3); IL_173: long duration = ByteCodeHelper.d2l((double)this.totalSamplesRead / (double)Microphone.access_500(this.this_0).getFormat().getSampleRate() * 1000.0); Microphone.access_700(this.this_0).add(new DataEndSignal(duration)); Microphone.access_1100(this.this_0).info("DataEndSignal ended"); Microphone.access_1200(this.this_0).info("stopped recording"); lock (this.@lock) { Object.instancehelper_notify(this.@lock); } }
public string execute(CommandInterpreter commandInterpreter, string[] array) { Result result = null; if (array.Length != 1 && array.Length != 2) { commandInterpreter.putResponse("Usage: batchNext [norec]"); } else { try { if (this.this_0.curBatchItem == null) { this.this_0.batchManager.start(); } this.this_0.curBatchItem = this.this_0.batchManager.getNextItem(); if (this.this_0.curBatchItem == null) { this.this_0.batchManager.start(); this.this_0.curBatchItem = this.this_0.batchManager.getNextItem(); } string filename = this.this_0.curBatchItem.getFilename(); string transcript = this.this_0.curBatchItem.getTranscript(); if (array.Length == 2) { commandInterpreter.putResponse(new StringBuilder().append("Skipping: ").append(transcript).toString()); } else { this.this_0.setInputStream(filename); result = this.this_0.recognizer.recognize(transcript); } } catch (IOException ex) { commandInterpreter.putResponse(new StringBuilder().append("I/O error during decoding: ").append(Throwable.instancehelper_getMessage(ex)).toString()); } } return((result == null) ? "" : result.getBestResultNoFiller()); }
public static URL getResource(string name, PropertySheet ps) { string @string = ps.getString(name); if (@string == null) { string instanceName = ps.getInstanceName(); string text = new StringBuilder().append("Required resource property '").append(name).append("' not set").toString(); throw new InternalConfigurationException(instanceName, name, text); } URL result; try { URL url = ConfigurationManagerUtils.resourceToURL(@string); result = url ?? throw new InternalConfigurationException(ps.getInstanceName(), name, new StringBuilder().append("Can't locate ").append(@string).toString()); } catch (MalformedURLException ex) { throw new InternalConfigurationException(ex, ps.getInstanceName(), name, new StringBuilder().append("Bad URL ").append(@string).append(Throwable.instancehelper_getMessage(ex)).toString()); } return(result); }
private TargetDataLine getAudioLine() { if (this.audioLine != null) { return(this.audioLine); } try { this.logger.info(new StringBuilder().append("Final format: ").append(this.finalFormat).toString()); DataLine.Info info = new DataLine.Info(ClassLiteral <TargetDataLine> .Value, this.finalFormat); Mixer selectedMixer = this.getSelectedMixer(); if (selectedMixer == null) { this.audioLine = (TargetDataLine)AudioSystem.getLine(info); } else { this.audioLine = (TargetDataLine)selectedMixer.getLine(info); } this.audioLine.addLineListener(new Microphone_1(this)); } catch (LineUnavailableException ex) { this.logger.severe(new StringBuilder().append("microphone unavailable ").append(Throwable.instancehelper_getMessage(ex)).toString()); } return(this.audioLine); }