Пример #1
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);
                }
            }
Пример #2
0
        public override Data getData()
        {
            object obj;

            if (this.curPoint == -1)
            {
                obj = new DataStartSignal(this.sampleRate);
                this.curPoint++;
            }
            else
            {
                if (this.curPoint == this.numPoints)
                {
                    if (this.numPoints > 0)
                    {
                        this.firstSampleNumber = this.firstSampleNumber - (long)this.frameShift + (long)this.frameSize - 1L;
                    }
                    int  num      = this.curPoint;
                    int  num2     = this.cepstrumLength;
                    int  num3     = (num2 != -1) ? (num / num2) : (-num);
                    int  i        = (num3 - 1) * this.frameShift + this.frameSize;
                    long duration = ByteCodeHelper.d2l((double)i / (double)this.sampleRate * 1000.0);
                    obj = new DataEndSignal(duration);
                    try
                    {
                        this.binaryStream.close();
                        this.curPoint++;
                    }
                    catch (IOException ex)
                    {
                        throw new DataProcessingException("IOException closing cepstrum stream", ex);
                    }
                    goto IL_1B5;
                }
                if (this.curPoint > this.numPoints)
                {
                    obj = null;
                }
                else
                {
                    double[] array = new double[this.cepstrumLength];
                    int      i     = 0;
                    while (i < this.cepstrumLength)
                    {
                        try
                        {
                            if (this.bigEndian)
                            {
                                array[i] = (double)this.binaryStream.readFloat();
                            }
                            else
                            {
                                array[i] = (double)Utilities.readLittleEndianFloat(this.binaryStream);
                            }
                            this.curPoint++;
                        }
                        catch (IOException ex4)
                        {
                            throw new DataProcessingException("IOException reading from cepstrum stream", ex4);
                        }
                        i++;
                        continue;
                    }
                    obj = new DoubleData(array, this.sampleRate, this.firstSampleNumber);
                    this.firstSampleNumber += (long)this.frameShift;
                }
            }
IL_1B5:
            object obj2 = obj;
            Data result;

            if (obj2 != null)
            {
                if ((result = (obj2 as Data)) == null)
                {
                    throw new IncompatibleClassChangeError();
                }
            }
            else
            {
                result = null;
            }
            return(result);
        }
 private long getDuration()
 {
     return(ByteCodeHelper.d2l((double)this.totalValuesRead / (double)this.sampleRate * 1000.0));
 }
Пример #4
0
        public static Lattice readSlf(InputStream stream)
        {
            Lattice          lattice          = new Lattice();
            LineNumberReader lineNumberReader = new LineNumberReader(new InputStreamReader(stream));
            int    num  = 0;
            int    num2 = 0;
            int    num3 = 0;
            int    num4 = 1;
            double num5 = 9.5;
            string text;

            while ((text = lineNumberReader.readLine()) != null)
            {
                string       text2        = text;
                object       obj          = "Node definitions";
                CharSequence charSequence = CharSequence.Cast(obj);
                if (String.instancehelper_contains(text2, charSequence))
                {
                    num2 = 0;
                    num  = 1;
                }
                else
                {
                    string text3 = text;
                    obj          = "Link definitions";
                    charSequence = CharSequence.Cast(obj);
                    if (String.instancehelper_contains(text3, charSequence))
                    {
                        num2 = 1;
                        num  = 0;
                    }
                    else if (!String.instancehelper_startsWith(text, "#"))
                    {
                        if (num != 0)
                        {
                            string[] array = String.instancehelper_split(text, "\\s+");
                            if (array.Length != 3 || !String.instancehelper_startsWith(array[0], "I=") || !String.instancehelper_startsWith(array[1], "t=") || !String.instancehelper_startsWith(array[2], "W="))
                            {
                                lineNumberReader.close();
                                string text4 = new StringBuilder().append("Unknown node definition: ").append(text).toString();

                                throw new IOException(text4);
                            }
                            int    num6      = Integer.parseInt(String.instancehelper_substring(array[0], 2));
                            long   beginTime = ByteCodeHelper.d2l(Double.parseDouble(String.instancehelper_substring(array[1], 2)) * 1000.0);
                            string text5     = String.instancehelper_substring(array[2], 2);
                            int    isFiller  = 0;
                            if (num6 == num3 || String.instancehelper_equals(text5, "!ENTER"))
                            {
                                text5    = "<s>";
                                isFiller = 1;
                            }
                            if (num6 == num4 || String.instancehelper_equals(text5, "!EXIT"))
                            {
                                text5    = "</s>";
                                isFiller = 1;
                            }
                            if (String.instancehelper_equals(text5, "!NULL"))
                            {
                                text5    = "<sil>";
                                isFiller = 1;
                            }
                            if (String.instancehelper_startsWith(text5, "["))
                            {
                                isFiller = 1;
                            }
                            Word word = new Word(text5, new Pronunciation[0], isFiller != 0);
                            Node node = lattice.addNode(Integer.toString(num6), word, beginTime, -1L);
                            if (String.instancehelper_equals(text5, "<s>"))
                            {
                                lattice.setInitialNode(node);
                            }
                            if (String.instancehelper_equals(text5, "</s>"))
                            {
                                lattice.setTerminalNode(node);
                            }
                        }
                        else if (num2 != 0)
                        {
                            string[] array = String.instancehelper_split(text, "\\s+");
                            if (array.Length != 5 || !String.instancehelper_startsWith(array[1], "S=") || !String.instancehelper_startsWith(array[2], "E=") || !String.instancehelper_startsWith(array[3], "a=") || !String.instancehelper_startsWith(array[4], "l="))
                            {
                                lineNumberReader.close();
                                string text6 = new StringBuilder().append("Unknown edge definition: ").append(text).toString();

                                throw new IOException(text6);
                            }
                            string text7         = String.instancehelper_substring(array[1], 2);
                            string text8         = String.instancehelper_substring(array[2], 2);
                            double acousticScore = Double.parseDouble(String.instancehelper_substring(array[3], 2));
                            double lmScore       = Double.parseDouble(String.instancehelper_substring(array[4], 2)) * num5;
                            lattice.addEdge((Node)lattice.nodes.get(text7), (Node)lattice.nodes.get(text8), acousticScore, lmScore);
                        }
                        else
                        {
                            if (String.instancehelper_startsWith(text, "start="))
                            {
                                string text9 = text;
                                object obj2  = "start=";
                                obj = "";
                                object obj3 = obj2;
                                charSequence = CharSequence.Cast(obj3);
                                CharSequence charSequence2 = charSequence;
                                obj3         = obj;
                                charSequence = CharSequence.Cast(obj3);
                                num3         = Integer.parseInt(String.instancehelper_replace(text9, charSequence2, charSequence));
                            }
                            if (String.instancehelper_startsWith(text, "end="))
                            {
                                string text10 = text;
                                object obj4   = "end=";
                                object obj3   = "";
                                obj          = obj4;
                                charSequence = CharSequence.Cast(obj);
                                CharSequence charSequence3 = charSequence;
                                obj          = obj3;
                                charSequence = CharSequence.Cast(obj);
                                num4         = Integer.parseInt(String.instancehelper_replace(text10, charSequence3, charSequence));
                            }
                            if (String.instancehelper_startsWith(text, "lmscale="))
                            {
                                string text11 = text;
                                object obj5   = "lmscale=";
                                obj = "";
                                object obj3 = obj5;
                                charSequence = CharSequence.Cast(obj3);
                                CharSequence charSequence4 = charSequence;
                                obj3         = obj;
                                charSequence = CharSequence.Cast(obj3);
                                num5         = Double.parseDouble(String.instancehelper_replace(text11, charSequence4, charSequence));
                            }
                        }
                    }
                }
            }
            Iterator iterator = lattice.nodes.values().iterator();

            while (iterator.hasNext())
            {
                Node     node2     = (Node)iterator.next();
                Iterator iterator2 = node2.getLeavingEdges().iterator();
                while (iterator2.hasNext())
                {
                    Edge edge = (Edge)iterator2.next();
                    if (node2.getEndTime() < 0L || node2.getEndTime() > edge.getToNode().getBeginTime())
                    {
                        node2.setEndTime(Math.max(edge.getToNode().getBeginTime(), node2.getBeginTime()));
                    }
                }
            }
            return(lattice);
        }