Package edu.cmu.sphinx.frontend

Examples of edu.cmu.sphinx.frontend.DoubleData


    private DoubleData process(Data input) throws IllegalArgumentException {
        assert input instanceof DoubleData;

        double[] inFeatures;

        DoubleData doubleData = (DoubleData) input;
        assert sampleRate == doubleData.getSampleRate();

        inFeatures = doubleData.getValues();

        // check wether we reached the next insertion point and repeat some parts of the input part if necessary
        double[] extFeatures;
        long firstSampleNumber = doubleData.getFirstSampleNumber() + numInsertedSamples;
        long lastSampleNumber = doubleData.getFirstSampleNumber() + doubleData.getValues().length - 1;

        if (nextInsertionPoint >= doubleData.getFirstSampleNumber() && nextInsertionPoint <= lastSampleNumber) {
            int insertLength = Math.min(r.nextInt((int) maxRepeatedSamples) + 1, inFeatures.length);

            // make sure that after insertion the block-length does not exceed 160 samples because with more SpeechClassifierNT will fail
            assert doubleData.getValues().length + insertLength <= 160 : "block too large for next SpeechClassifier";


            extFeatures = new double[insertLength + inFeatures.length];

            logger.fine("RSR: repeat snippet with length " + insertLength + " at position " + nextInsertionPoint);

            // copy the existing block into the new array and replicate the desired snippet inbetween
            int startIndex = (int) (nextInsertionPoint - doubleData.getFirstSampleNumber());

            System.arraycopy(inFeatures, 0, extFeatures, 0, startIndex);
            System.arraycopy(inFeatures, 0, extFeatures, startIndex, insertLength);
            System.arraycopy(inFeatures, startIndex, extFeatures, startIndex + insertLength, inFeatures.length - startIndex);
            numInsertedSamples += insertLength;
            nextInsertionPoint = computeNextInsertionPoint();
        } else {
            extFeatures = inFeatures;
        }


        DoubleData extendedData = new DoubleData(extFeatures, doubleData.getSampleRate(),
                firstSampleNumber);

        return extendedData;
    }
View Full Code Here


        rsr.numInsertedSamples = 20;
        rsr.nextInsertionPoint = 5;

        // create a dummy DoubleData
        double[] data = new double[]{1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
        DoubleData dd = new DoubleData(data, 16000, 0);

        DoubleData extData = rsr.process(dd);

        double[] expectedData = new double[]{1, 2, 3, 4, 5, 1, 2, 6, 7, 8, 9, 10};
        Assert.assertEquals(extData.getFirstSampleNumber(), 20, 0);
        Assert.assertEquals(extData.getValues().length, expectedData.length);

        for (int i = 0; i < expectedData.length; i++) {
            Assert.assertEquals(extData.getValues()[i], expectedData[i], 0);
        }
    }
View Full Code Here

        rsr.numInsertedSamples = 20;
        rsr.nextInsertionPoint = 5;

        // create a dummy DoubleData
        double[] data = new double[]{1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
        DoubleData dd = new DoubleData(data, 16000, 0);

        DoubleData extData = rsr.process(dd);

        double[] expectedData = new double[]{1, 2, 3, 4, 5, 1, 2, 6, 7, 8, 9, 10};
        Assert.assertEquals(extData.getFirstSampleNumber(), 20, 0);
        Assert.assertEquals(extData.getValues().length, expectedData.length);

        for (int i = 0; i < expectedData.length; i++) {
            Assert.assertEquals(extData.getValues()[i], expectedData[i], 0);
        }
    }
View Full Code Here

        rsr.numInsertedSamples = 20;
        rsr.nextInsertionPoint = 9;

        // create a dummy DoubleData
        double[] data = new double[]{1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
        DoubleData dd = new DoubleData(data, 16000, 0);

        DoubleData extData = rsr.process(dd);

        double[] expectedData = new double[]{1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 10};
        Assert.assertEquals(extData.getFirstSampleNumber(), 20, 0);
        Assert.assertEquals(extData.getValues().length, expectedData.length);

        for (int i = 0; i < expectedData.length; i++) {
            Assert.assertEquals(extData.getValues()[i], expectedData[i], 0);
        }
    }
View Full Code Here

        long curStartSample = startSample;
        long shiftSamples = ms2samples((int) shiftMs, sampleRate);
        for (int i = 0; i < numFrames; i++) {
            double[] values = createRandFeatureVector(featDim, null, null);
            datas.add(new DoubleData(values, sampleRate, curStartSample));

            curStartSample += shiftSamples;
        }

        return datas;
View Full Code Here

        List<DoubleData> datas = new ArrayList<DoubleData>();

        double counter = 1;
        for (int i = 0; i < numSamples / blockSize; i++) {
            double[] values = new double[blockSize];
            datas.add(new DoubleData(values, sampleRate, (long) counter + offSet));

            for (int j = 0; j < values.length; j++)
                values[j] = counter++ + offSet;
        }
View Full Code Here

    public static boolean hasIncreasingOrder(List<Data> output, int lastValue) {
        int dataCounter = 0;

        for (Data data : output) {
            if (data instanceof DoubleData) {
                DoubleData dd = (DoubleData) data;

                for (int i = 0; i < dd.getValues().length; i++) {
                    if ((dataCounter + 1) == dd.getValues()[i])
                        dataCounter++;
                    else
                        return false;
                }
            }
View Full Code Here

        double[] cepstrum;

        // create the cepstrum by apply the melcosine filter
        cepstrum = applyMelCosine(melspectrum);

        return new DoubleData(cepstrum, input.getSampleRate(),
                input.getFirstSampleNumber());
    }
View Full Code Here

        }
        if (!(inputData instanceof DoubleData)) {
            return inputData;
        }

        DoubleData inputDoubleData = (DoubleData) inputData;
        double[] input = inputDoubleData.getValues();
        int length = input.length;

        if (power == null)
            initStatistics(input, length);
View Full Code Here

        recurseFft(inputFrame, outputSpectrum, numberFftPoints, invert);

        /**
         * Return the power spectrum
         */
        DoubleData output = new DoubleData
                (outputSpectrum, input.getSampleRate(),
                        input.getFirstSampleNumber());

        return output;
    }
View Full Code Here

TOP

Related Classes of edu.cmu.sphinx.frontend.DoubleData

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.