protected internal virtual void writeFile(string wavName) { AudioFormat audioFormat = new AudioFormat((float)this.sampleRate, this.bitsPerSample, 1, this.isSigned, true); AudioFileFormat.Type targetType = WavWriter.getTargetType("wav"); byte[] array = this.baos.toByteArray(); ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(array); InputStream inputStream = byteArrayInputStream; AudioFormat audioFormat2 = audioFormat; int num = array.Length; int frameSize = audioFormat.getFrameSize(); AudioInputStream audioInputStream = new AudioInputStream(inputStream, audioFormat2, (long)((frameSize != -1) ? (num / frameSize) : (-(long)num))); File file = new File(wavName); if (AudioSystem.isFileTypeSupported(targetType, audioInputStream)) { try { AudioSystem.write(audioInputStream, targetType, file); } catch (IOException ex) { Throwable.instancehelper_printStackTrace(ex); } } }
public override Data getData() { Data data = this.getPredecessor().getData(); if (data is DataStartSignal) { this.sampleRate = ((DataStartSignal)data).getSampleRate(); } if (data is DataStartSignal || (data is SpeechStartSignal && this.captureUtts)) { this.baos = new ByteArrayOutputStream(); this.dos = new DataOutputStream(this.baos); } if ((data is DataEndSignal && !this.captureUtts) || (data is SpeechEndSignal && this.captureUtts)) { string nextFreeIndex; if (this.isCompletePath) { nextFreeIndex = this.outFileNamePattern; } else { nextFreeIndex = WavWriter.getNextFreeIndex(this.outFileNamePattern); } this.writeFile(nextFreeIndex); this.isInSpeech = false; } if (data is SpeechStartSignal) { this.isInSpeech = true; } if ((data is DoubleData || data is FloatData) && (this.isInSpeech || !this.captureUtts)) { DoubleData doubleData = (!(data is DoubleData)) ? DataUtil.FloatData2DoubleData((FloatData)data) : ((DoubleData)data); double[] values = doubleData.getValues(); double[] array = values; int num = array.Length; int i = 0; while (i < num) { double num2 = array[i]; try { this.dos.writeShort((int)new Short((short)ByteCodeHelper.d2i(num2)).shortValue()); } catch (IOException ex) { Throwable.instancehelper_printStackTrace(ex); } i++; continue; } } return(data); }