Пример #1
0
 protected internal virtual void computeSpectrogram()
 {
     try
     {
         AudioDataInputStream audioDataInputStream = new AudioDataInputStream(this.audio);
         this.dataSource.setInputStream(audioDataInputStream);
         ArrayList arrayList = new ArrayList();
         double    num       = double.Epsilon;
         Data      data      = this.frontEnd.getData();
         int       i;
         while (!(data is DataEndSignal))
         {
             if (data is DoubleData)
             {
                 double[] values = ((DoubleData)data).getValues();
                 double[] array  = new double[values.Length];
                 for (i = 0; i < array.Length; i++)
                 {
                     array[i] = Math.max(Math.log(values[i]), (double)0f);
                     if (array[i] > num)
                     {
                         num = array[i];
                     }
                 }
                 arrayList.add(array);
             }
             data = this.frontEnd.getData();
         }
         audioDataInputStream.close();
         int num2 = arrayList.size();
         int num3 = ((double[])arrayList.get(0)).Length;
         i = num3 - 1;
         Dimension dimension = new Dimension(num2, num3);
         this.setMinimumSize(dimension);
         this.setMaximumSize(dimension);
         this.setPreferredSize(dimension);
         this.spectrogram = new BufferedImage(num2, num3, 1);
         double num4 = (255.0 + this.offsetFactor) / num;
         for (int j = 0; j < num2; j++)
         {
             double[] array2 = (double[])arrayList.get(j);
             for (int k = i; k >= 0; k--)
             {
                 int num5 = ByteCodeHelper.d2i(array2[k] * num4 - this.offsetFactor);
                 num5 = Math.max(num5, 0);
                 num5 = 255 - num5;
                 int num6 = (num5 << 16 & 16711680) | (num5 << 8 & 65280) | (num5 & 255);
                 this.spectrogram.setRGB(j, i - k, num6);
             }
         }
         ReplicateScaleFilter replicateScaleFilter = new ReplicateScaleFilter(ByteCodeHelper.f2i(this.zoom * (float)num2), num3);
         this.scaledSpectrogram = this.createImage(new FilteredImageSource(this.spectrogram.getSource(), replicateScaleFilter));
         Dimension size = this.getSize();
         this.repaint(0L, 0, 0, size.width - 1, size.height - 1);
     }
     catch (System.Exception ex)
     {
         Throwable.instancehelper_printStackTrace(ex);
     }
 }
Пример #2
0
        public Picture(File f)
        {
            this.isOriginUpperLeft = true;
            IOException ex;

            try
            {
                this.image = ImageIO.read(f);
            }
            catch (IOException arg_20_0)
            {
                ex = ByteCodeHelper.MapException <IOException>(arg_20_0, ByteCodeHelper.MapFlags.NoRemapping);
                goto IL_2A;
            }
            if (this.image == null)
            {
                string arg_82_0 = new StringBuilder().append("Invalid image file: ").append(f).toString();

                throw new RuntimeException(arg_82_0);
            }
            this.width    = this.image.getWidth(null);
            this.height   = this.image.getHeight(null);
            this.filename = f.getName();
            return;

IL_2A:
            IOException this2 = ex;

            Throwable.instancehelper_printStackTrace(this2);
            string arg_55_0 = new StringBuilder().append("Could not open file: ").append(f).toString();

            throw new RuntimeException(arg_55_0);
        }
        public override void initialize()
        {
            base.initialize();
            try
            {
                File file = new File(this.silenceFileName);
                this.silenceFileLength = file.length();
                if (this.transcriptFile != null)
                {
                    this.transcript = new FileWriter(this.transcriptFile);
                }
                if (this.batchFile == null)
                {
                    string text = "BatchFile cannot be null!";

                    throw new Error(text);
                }
                this.setInputStream(new SequenceInputStream(new ConcatFileDataSource.InputStreamEnumeration(this, this.batchFile, this.startFile, this.totalFiles)));
                this.referenceList = new LinkedList();
            }
            catch (IOException ex)
            {
                Throwable.instancehelper_printStackTrace(ex);
            }
        }
Пример #4
0
        public override Set getVocabulary()
        {
            HashSet hashSet = new HashSet();

            try
            {
                BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(this.location.openStream()));
                for (;;)
                {
                    string text = bufferedReader.readLine();
                    if (text == null)
                    {
                        break;
                    }
                    if (String.instancehelper_length(text) != 0)
                    {
                        hashSet.add(String.instancehelper_trim(text));
                    }
                }
                bufferedReader.close();
            }
            catch (IOException ex)
            {
                Throwable.instancehelper_printStackTrace(ex);
            }
            return(hashSet);
        }
Пример #5
0
        internal virtual void buildWordConversion(string text)
        {
            IOException ex2;

            try
            {
                BufferedReader bufferedReader = new BufferedReader(new FileReader(text));
                for (;;)
                {
                    string text2 = bufferedReader.readLine();
                    if (text2 == null)
                    {
                        break;
                    }
                    StringTokenizer stringTokenizer = new StringTokenizer(text2);
                    if (stringTokenizer.hasMoreTokens())
                    {
                        string text3 = stringTokenizer.nextToken();
                        this.addInConv(text3, this.wordConv);
                    }
                }
                bufferedReader.close();
            }
            catch (IOException ex)
            {
                ex2 = ex;
                goto IL_53;
            }
            return;

IL_53:
            IOException ex3 = ex2;

            Throwable.instancehelper_printStackTrace(ex3);
        }
Пример #6
0
 public virtual void save(string name)
 {
     try
     {
         PrintWriter printWriter = new PrintWriter(new FileWriter(name));
         printWriter.println(new StringBuilder().append(this.ngauss).append(" ").append(this.ncoefs).toString());
         for (int i = 0; i < this.ngauss; i++)
         {
             printWriter.println(new StringBuilder().append("gauss ").append(i).append(' ').append(this.getWeight(i)).toString());
             for (int j = 0; j < this.ncoefs; j++)
             {
                 printWriter.print(new StringBuilder().append(this.means[i][j]).append(" ").toString());
             }
             printWriter.println();
             for (int j = 0; j < this.ncoefs; j++)
             {
                 printWriter.print(new StringBuilder().append(this.getVar(i, j)).append(" ").toString());
             }
             printWriter.println();
         }
         printWriter.println(this.nT);
         printWriter.close();
     }
     catch (IOException ex)
     {
         Throwable.instancehelper_printStackTrace(ex);
     }
 }
        internal HypothesisUtterance(string text)
        {
            this.words = new LinkedList();
            StringTokenizer stringTokenizer = new StringTokenizer(text, " \t\n\r\f(),");

            while (stringTokenizer.hasMoreTokens())
            {
                string text2 = stringTokenizer.nextToken();
                try
                {
                    float          num            = Float.parseFloat(stringTokenizer.nextToken());
                    float          num2           = Float.parseFloat(stringTokenizer.nextToken());
                    HypothesisWord hypothesisWord = new HypothesisWord(text2, num, num2);
                    this.words.add(hypothesisWord);
                }
                catch (NumberFormatException ex)
                {
                    Throwable.instancehelper_printStackTrace(ex);
                }
                continue;
            }
            if (!this.words.isEmpty())
            {
                HypothesisWord hypothesisWord2 = (HypothesisWord)this.words.get(0);
                this.startTime = hypothesisWord2.getStartTime();
                HypothesisWord hypothesisWord3 = (HypothesisWord)this.words.get(this.words.size() - 1);
                this.endTime = hypothesisWord3.getEndTime();
            }
        }
Пример #8
0
    private void writeByte(int num)
    {
        if (!BinaryOut.s_assertionsDisabled && (num < 0 || num >= 256))
        {
            throw new AssertionError();
        }
        if (this.N == 0)
        {
            IOException ex;
            try
            {
                [email protected](num);
            }
            catch (IOException arg_37_0)
            {
                ex = ByteCodeHelper.MapException <IOException>(arg_37_0, ByteCodeHelper.MapFlags.NoRemapping);
                goto IL_41;
            }
            return;

IL_41:
            IOException this2 = ex;
            Throwable.instancehelper_printStackTrace(this2);
            return;
        }
        for (int i = 0; i < 8; i++)
        {
            int num2 = (((uint)num >> 8 - i - 1 & 1u) == 1u) ? 1 : 0;
            this.writeBit(num2 != 0);
        }
    }
Пример #9
0
        public static void main(string[] argv)
        {
            if (argv.Length < 2)
            {
                [email protected]("Usage: BatchDecoder propertiesFile batchFile [-shell]");
                java.lang.System.exit(1);
            }
            string text  = argv[0];
            string text2 = argv[1];

            try
            {
                URL url = new File(text).toURI().toURL();
                ConfigurationManager configurationManager = new ConfigurationManager(url);
                BatchModeRecognizer  batchModeRecognizer  = (BatchModeRecognizer)configurationManager.lookup("batch");
                if (batchModeRecognizer != null)
                {
                    if (argv.Length >= 3 && String.instancehelper_equals(argv[2], "-shell"))
                    {
                        batchModeRecognizer.shell(text2);
                    }
                    else
                    {
                        batchModeRecognizer.decode(text2);
                    }
                    [email protected](new StringBuilder().append("Tokens created: ").append(StatisticsVariable.getStatisticsVariable("totalTokensScored").value).toString());
                }
                java.lang.System.err.println(new StringBuilder().append("Can't find batchModeRecognizer in ").append(text).toString());
            }
            catch (System.Exception ex)
            {
                java.lang.System.err.println("Error during decoding: \n  ");
                Throwable.instancehelper_printStackTrace(ex);
            }
        }
Пример #10
0
        public override void run()
        {
            AudioData obj = this.audio;

            for (;;)
            {
                try
                {
                    System.Threading.Monitor.Enter(obj);
                    try
                    {
                        Object.instancehelper_wait(this.audio);
                        AudioFormat audioFormat = this.audio.getAudioFormat();
                        short[]     audioData   = this.audio.getAudioData();
                        int         num         = Math.max(0, this.selectionStart);
                        int         num2        = this.selectionEnd;
                        if (num2 == -1)
                        {
                            num2 = audioData.Length;
                        }
                        DataLine.Info info = new DataLine.Info(ClassLiteral <SourceDataLine> .Value, audioFormat);
                        this.line = (SourceDataLine)AudioSystem.getLine(info);
                        this.line.open(audioFormat);
                        this.line.start();
                        byte[] array = new byte[2];
                        int    num3  = num;
                        while (num3 < num2 && num3 < audioData.Length)
                        {
                            Utils.toBytes(audioData[num3], array, false);
                            this.line.write(array, 0, array.Length);
                            num3++;
                        }
                        this.line.drain();
                        this.line.close();
                        this.line = null;
                        System.Threading.Monitor.Exit(obj);
                    }
                    catch (System.Exception ex)
                    {
                        Throwable.instancehelper_printStackTrace(ex);

                        break;
                    }
                    continue;
                }
                catch (System.Exception ex3)
                {
                    Throwable.instancehelper_printStackTrace(ex3);
                }
                break;
            }
            try
            {
                System.Threading.Monitor.Exit(obj);
            }
            catch (System.Exception ex8)
            {
                Throwable.instancehelper_printStackTrace(ex8);
            }
        }
Пример #11
0
        internal virtual void setConfigurableClass(Class @class)
        {
            this.ownerClass = @class;
            if (this.isInstanciated())
            {
                string text = "class is already instantiated";

                throw new RuntimeException(text);
            }
            HashSet  hashSet  = new HashSet();
            Map      map      = PropertySheet.parseClass(this.ownerClass);
            Iterator iterator = map.entrySet().iterator();

            while (iterator.hasNext())
            {
                Map.Entry entry = (Map.Entry)iterator.next();
                try
                {
                    string text2 = (string)((Field)entry.getKey()).get(null, PropertySheet.__GetCallerID());
                    if (!PropertySheet.assertionsDisabled && hashSet.contains(text2))
                    {
                        object obj = new StringBuilder().append("duplicate property-name for different properties: ").append(text2).append(" for the class ").append(@class).toString();

                        throw new AssertionError(obj);
                    }
                    this.registerProperty(text2, new S4PropWrapper((java.lang.annotation.Annotation)entry.getValue()));
                    hashSet.add(text2);
                }
                catch (IllegalAccessException ex)
                {
                    Throwable.instancehelper_printStackTrace(ex);
                }
                continue;
            }
        }
Пример #12
0
        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);
                }
            }
        }
Пример #13
0
    private void clearBuffer()
    {
        if (this.N == 0)
        {
            return;
        }
        if (this.N > 0)
        {
            this.buffer <<= 8 - this.N;
        }
        IOException ex;

        try
        {
            [email protected](this.buffer);
        }
        catch (IOException arg_40_0)
        {
            ex = ByteCodeHelper.MapException <IOException>(arg_40_0, ByteCodeHelper.MapFlags.NoRemapping);
            goto IL_4A;
        }
        goto IL_56;
IL_4A:
        IOException this2 = ex;

        Throwable.instancehelper_printStackTrace(this2);
IL_56:
        this.N      = 0;
        this.buffer = 0;
    }
Пример #14
0
        private static short[] getRecordedAudio(Microphone microphone)
        {
            short[] array = new short[0];
            int     num   = 8000;

            while (microphone.hasMoreData())
            {
                try
                {
                    Data data = microphone.getData();
                    if (data is DoubleData)
                    {
                        num = ((DoubleData)data).getSampleRate();
                        double[] values = ((DoubleData)data).getValues();
                        short[]  array2 = Arrays.copyOf(array, array.Length + values.Length);
                        for (int i = 0; i < values.Length; i++)
                        {
                            array2[array.Length + i] = (short)ByteCodeHelper.d2i(values[i]);
                        }
                        array = array2;
                    }
                }
                catch (System.Exception ex)
                {
                    Throwable.instancehelper_printStackTrace(ex);
                }
                continue;
            }
            if (num > 8000)
            {
                [email protected](new StringBuilder().append("Downsampling from ").append(num).append(" to 8000.").toString());
                array = Downsampler.downsample(array, num / 1000, 16);
            }
            return(array);
        }
Пример #15
0
        public override Data getData()
        {
            Data result = null;

            while (this.waitIfEmpty && this.featureBuffer.isEmpty())
            {
                try
                {
                    Thread.sleep(this.waitTime);
                }
                catch (InterruptedException ex)
                {
                    Throwable.instancehelper_printStackTrace(ex);
                }
                continue;
            }
            if (!this.featureBuffer.isEmpty())
            {
                result = (Data)this.featureBuffer.remove(0);
            }
            else if (!DataBufferProcessor.assertionsDisabled && this.waitIfEmpty)
            {
                throw new AssertionError();
            }
            return(result);
        }
        public virtual void setGlobalProperty(string propertyName, string value)
        {
            if (value == null)
            {
                this.globalProperties.remove(propertyName);
            }
            else
            {
                this.globalProperties.put(propertyName, value);
            }
            Iterator iterator = this.getInstanceNames(ClassLiteral <Configurable> .Value).iterator();

            while (iterator.hasNext())
            {
                string        instanceName  = (string)iterator.next();
                PropertySheet propertySheet = this.getPropertySheet(instanceName);
                if (propertySheet.isInstanciated())
                {
                    try
                    {
                        propertySheet.getOwner().newProperties(propertySheet);
                    }
                    catch (PropertyException ex)
                    {
                        Throwable.instancehelper_printStackTrace(ex);
                    }
                    continue;
                }
            }
        }
        private static List readDriver(string text)
        {
            File        file      = new File(text);
            ArrayList   arrayList = null;
            IOException ex2;

            try
            {
                BufferedReader bufferedReader = new BufferedReader(new FileReader(file));
                arrayList = new ArrayList();
                string text2;
                while ((text2 = bufferedReader.readLine()) != null && String.instancehelper_length(String.instancehelper_trim(text2)) != 0)
                {
                    File file2 = new File(text2);
                    arrayList.add(file2.toURI().toURL());
                }
                bufferedReader.close();
            }
            catch (IOException ex)
            {
                ex2 = ex;
                goto IL_65;
            }
            goto IL_74;
IL_65:
            IOException ex3 = ex2;

            Throwable.instancehelper_printStackTrace(ex3);
IL_74:
            if (!ConcatAudioFileDataSource.assertionsDisabled && arrayList == null)
            {
                throw new AssertionError();
            }
            return(arrayList);
        }
Пример #18
0
        public static InputStream getInputStream(string format, string location, string file)
        {
            InputStream result = null;
            string      text;

            if (location == null)
            {
                text = null;
            }
            else
            {
                URI    uri                = URI.create(location);
                string scheme             = uri.getScheme();
                string schemeSpecificPart = uri.getSchemeSpecificPart();
                File   file2              = new File(schemeSpecificPart);
                URI    uri2               = file2.getAbsoluteFile().toURI();
                if (scheme == null)
                {
                    text = uri2.getSchemeSpecificPart();
                }
                else
                {
                    text = new StringBuilder().append(scheme).append(':').append(uri2.getSchemeSpecificPart()).toString();
                }
            }
            if (String.instancehelper_equals(format, "ZIP_FILE"))
            {
                try
                {
                    URI      uri     = new URI(text);
                    ZipFile  zipFile = new ZipFile(new File(uri));
                    ZipEntry entry   = zipFile.getEntry(file);
                    if (entry != null)
                    {
                        result = zipFile.getInputStream(entry);
                    }
                    zipFile.close();
                }
                catch (URISyntaxException ex)
                {
                    Throwable.instancehelper_printStackTrace(ex);
                    throw new ZipException(new StringBuilder().append("URISyntaxException: ").append(ex.getMessage()).toString());
                }
                return(result);
            }
            if (String.instancehelper_equals(format, "DIRECTORY"))
            {
                if (text != null)
                {
                    result = new FileInputStream(new StringBuilder().append(text).append(File.separator).append(file).toString());
                }
                else
                {
                    result = new FileInputStream(file);
                }
            }
            return(result);
        }
            public AudioInputStream nextElement()
            {
                AudioInputStream result = null;

                if (this.lastFile == null)
                {
                    ConcatAudioFileDataSource.access_002(this.this_0, this.readNext());
                }
                if (ConcatAudioFileDataSource.access_000(this.this_0) != null)
                {
                    try
                    {
                        try
                        {
                            AudioInputStream audioInputStream = AudioSystem.getAudioInputStream(ConcatAudioFileDataSource.access_000(this.this_0));
                            AudioFormat      format           = audioInputStream.getFormat();
                            if (!ConcatAudioFileDataSource.access_100(this.this_0))
                            {
                                ConcatAudioFileDataSource.access_102(this.this_0, true);
                                this.this_0.bigEndian     = format.isBigEndian();
                                this.this_0.sampleRate    = ByteCodeHelper.f2i(format.getSampleRate());
                                this.this_0.signedData    = format.getEncoding().equals(AudioFormat.Encoding.PCM_SIGNED);
                                this.this_0.bytesPerValue = format.getSampleSizeInBits() / 8;
                            }
                            if (format.getSampleRate() != (float)this.this_0.sampleRate || format.getChannels() != 1 || format.isBigEndian() != this.this_0.bigEndian)
                            {
                                string text = "format mismatch for subsequent files";

                                throw new RuntimeException(text);
                            }
                            result = audioInputStream;
                            ConcatAudioFileDataSource.access_200(this.this_0).finer(new StringBuilder().append("Strating processing of '").append(this.lastFile.getFile()).append('\'').toString());
                            Iterator iterator = this.this_0.__fileListeners.iterator();
                            while (iterator.hasNext())
                            {
                                AudioFileProcessListener audioFileProcessListener  = (AudioFileProcessListener)iterator.next();
                                AudioFileProcessListener audioFileProcessListener2 = audioFileProcessListener;
                                audioFileProcessListener2.audioFileProcStarted(new File(ConcatAudioFileDataSource.access_000(this.this_0).getFile()));
                            }
                            this.lastFile = ConcatAudioFileDataSource.access_000(this.this_0);
                            ConcatAudioFileDataSource.access_002(this.this_0, null);
                        }
                        catch (IOException ex)
                        {
                            Throwable.instancehelper_printStackTrace(ex);

                            throw new Error(new StringBuilder().append("Cannot convert ").append(ConcatAudioFileDataSource.access_000(this.this_0)).append(" to a FileInputStream").toString());
                        }
                    }
                    catch (UnsupportedAudioFileException ex3)
                    {
                        Throwable.instancehelper_printStackTrace(ex3);
                    }
                    return(result);
                }
                return(result);
            }
Пример #20
0
            public void stopRecording()
            {
                Microphone.access_100(this.this_0).stop();
                object obj;

                System.Exception     ex2;
                InterruptedException ex4;

                try
                {
                    System.Threading.Monitor.Enter(obj = this.@lock);
                    try
                    {
                        while (!this.done)
                        {
                            Object.instancehelper_wait(this.@lock);
                        }
                        System.Threading.Monitor.Exit(obj);
                    }
                    catch (System.Exception ex)
                    {
                        ex2 = ex;
                        goto IL_54;
                    }
                    goto IL_57;
                }
                catch (InterruptedException ex3)
                {
                    ex4 = ex3;
                    goto IL_59;
                }
IL_54:
                InterruptedException ex8;

                try
                {
                    System.Threading.Monitor.Exit(obj);
                    throw ex2;
                }
                catch (InterruptedException ex7)
                {
                    ex8 = ex7;
                }
                InterruptedException ex9 = ex8;

                goto IL_7E;
IL_57:
                return;

IL_59:
                ex9 = ex4;
IL_7E:
                InterruptedException ex10 = ex9;

                Throwable.instancehelper_printStackTrace(ex10);
            }
Пример #21
0
            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);
                }
            }
Пример #22
0
        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);
        }
Пример #23
0
 public static void e(string tag, Exception t)
 {
     if (logInterface != null)
     {
         logInterface.e(tag, t);
     }
     else
     {
         Throwable.instancehelper_printStackTrace(t);
     }
 }
Пример #24
0
 public virtual void loadTiedList(string nomFich)
 {
     try
     {
         BufferedReader bufferedReader = new BufferedReader(new FileReader(nomFich));
         int            num            = 0;
         for (;;)
         {
             string text = bufferedReader.readLine();
             if (text == null)
             {
                 break;
             }
             string[] array = String.instancehelper_split(text, " ");
             if (array.Length >= 2)
             {
                 num++;
             }
         }
         int   num2   = num;
         int   num3   = 2;
         int[] array2 = new int[2];
         int   num4   = num3;
         array2[1]     = num4;
         num4          = num2;
         array2[0]     = num4;
         this.tiedHMMs = (string[][])ByteCodeHelper.multianewarray(typeof(string[][]).TypeHandle, array2);
         bufferedReader.close();
         bufferedReader = new BufferedReader(new FileReader(nomFich));
         int num5 = 0;
         for (;;)
         {
             string text = bufferedReader.readLine();
             if (text == null)
             {
                 break;
             }
             string[] array = String.instancehelper_split(text, " ");
             if (array.Length >= 2)
             {
                 this.tiedHMMs[num5][0] = array[0];
                 string[][] array3 = this.tiedHMMs;
                 int        num6   = num5;
                 num5++;
                 array3[num6][1] = array[1];
             }
         }
         bufferedReader.close();
     }
     catch (IOException ex)
     {
         Throwable.instancehelper_printStackTrace(ex);
     }
 }
Пример #25
0
        public static OutputStream getOutputStream(string format, string location, string file, bool append)
        {
            OutputStream outputStream;

            if (String.instancehelper_equals(format, "ZIP_FILE"))
            {
                try
                {
                    [email protected]("WARNING: ZIP not yet fully supported.!");
                    File file2 = new File(location);
                    File file3 = new File(file2.getParent());
                    if (!file3.exists())
                    {
                        file3.mkdirs();
                    }
                    FileOutputStream fileOutputStream = new FileOutputStream(new File(new URI(location)), append);
                    outputStream = new ZipOutputStream(new BufferedOutputStream(fileOutputStream));
                    ZipEntry zipEntry = new ZipEntry(file);
                    ((ZipOutputStream)((ZipOutputStream)outputStream)).putNextEntry(zipEntry);
                }
                catch (URISyntaxException ex)
                {
                    Throwable.instancehelper_printStackTrace(ex);
                    throw new ZipException(new StringBuilder().append("URISyntaxException: ").append(ex.getMessage()).toString());
                }
                return(outputStream);
            }
            if (!String.instancehelper_equals(format, "DIRECTORY"))
            {
                string text2 = "Format not supported for writing";
                throw new IOException(text2);
            }
            if (location != null)
            {
                File file2 = new File(new StringBuilder().append(location).append(File.separator).append(file).toString());
                File file3 = new File(file2.getParent());
                if (!file3.exists())
                {
                    file3.mkdirs();
                }
                outputStream = new FileOutputStream(new StringBuilder().append(location).append(File.separator).append(file).toString());
            }
            else
            {
                File file2 = new File(file);
                File file3 = new File(file2.getParent());
                if (!file3.exists())
                {
                    file3.mkdirs();
                }
                outputStream = new FileOutputStream(file);
            }
            return(outputStream);
        }
 public virtual void setAudioFile(File audioFile, string streamName)
 {
     try
     {
         this.setAudioFile(audioFile.toURI().toURL(), streamName);
     }
     catch (MalformedURLException ex)
     {
         Throwable.instancehelper_printStackTrace(ex);
     }
 }
Пример #27
0
 public override void deallocate()
 {
     this.allocated = false;
     try
     {
         this.socket.close();
     }
     catch (IOException ex)
     {
         Throwable.instancehelper_printStackTrace(ex);
     }
 }
Пример #28
0
 private void init(Loader loader)
 {
     this.loader = loader;
     try
     {
         loader.load();
     }
     catch (System.Exception ex)
     {
         Throwable.instancehelper_printStackTrace(ex);
     }
     this.transform = loader.getTransformMatrix();
 }
Пример #29
0
        public virtual void loadScaleKMeans(string nom)
        {
            int num = 0;

            try
            {
                BufferedReader bufferedReader = new BufferedReader(new FileReader(nom));
                while (bufferedReader.readLine() != null)
                {
                    num++;
                }
                this.ngauss = num / 2;
                bufferedReader.close();
                bufferedReader = new BufferedReader(new FileReader(nom));
                string   text  = bufferedReader.readLine();
                string[] array = String.instancehelper_split(text, " ");
                this.ncoefs = array.Length - 1;
                bufferedReader.close();
                bufferedReader = new BufferedReader(new FileReader(nom));
                this.allocate();
                this.nT = 0;
                for (int i = 0; i < this.ngauss; i++)
                {
                    text            = bufferedReader.readLine();
                    array           = String.instancehelper_split(text, " ");
                    this.weights[i] = Float.parseFloat(array[0]);
                    this.nT         = ByteCodeHelper.f2i((float)this.nT + this.weights[i]);
                    for (int j = 0; j < this.ncoefs; j++)
                    {
                        this.setMean(i, j, Float.parseFloat(array[j + 1]));
                    }
                    text  = bufferedReader.readLine();
                    array = String.instancehelper_split(text, " ");
                    for (int j = 0; j < this.ncoefs; j++)
                    {
                        this.setVar(i, j, Float.parseFloat(array[j]));
                    }
                }
                for (int i = 0; i < this.ngauss; i++)
                {
                    this.setWeight(i, this.weights[i] / (float)this.nT);
                }
                bufferedReader.close();
                this.precomputeDistance();
            }
            catch (IOException ex)
            {
                Throwable.instancehelper_printStackTrace(ex);
            }
        }
 public FeatureFileDumper(ConfigurationManager cm, string frontEndName)
 {
     this.featureLength = -1;
     try
     {
         this.frontEnd    = (FrontEnd)cm.lookup(frontEndName);
         this.audioSource = (StreamDataSource)cm.lookup("streamDataSource");
     }
     catch (Exception ex)
     {
         Throwable.instancehelper_printStackTrace(ex);
     }
     return;
 }