Subtitle-Synchronizer / jlibrosa

Librosa equivalent Java library to process audio file adn extract features from it.
MIT License
89 stars 26 forks source link

Exception with loadandreadAsList #8

Open toborobot opened 2 years ago

toborobot commented 2 years ago

Method return exception in meanBufferList.add(Float.parseFloat(df.format(frameVal / mChannels))); because DecimalFormat df = new DecimalFormat("#.#####"); need to use with different locales For me works: meanBufferList.add(Float.parseFloat(df.format(frameVal / mChannels)..replace(',','.')));

here: `public ArrayList loadAndReadAsListWithOffset(String path, int sampleRate, int readDurationInSeconds, int offsetDuration) throws IOException, WavFileException, FileFormatNotSupportedException {

    float[][] magValueArray = readMagnitudeValuesFromFile(path, sampleRate, readDurationInSeconds, offsetDuration);

    DecimalFormat df = new DecimalFormat("#.#####");
    df.setRoundingMode(RoundingMode.CEILING);

    int mNumFrames = this.getNoOfFrames();
    int mChannels = this.getNoOfChannels();

    // take the mean of amplitude values across all the channels and convert the
    // signal to mono mode
    float[] meanBuffer = new float[mNumFrames];
    ArrayList<Float> meanBufferList = new ArrayList<Float>();
    for (int q = 0; q < mNumFrames; q++) {
        double frameVal = 0;
        for (int p = 0; p < mChannels; p++) {
            frameVal = frameVal + magValueArray[p][q];
        }
        meanBufferList.add(Float.parseFloat(df.format(frameVal / mChannels)));

    }

    return meanBufferList;

}`