ALIZE-Speaker-Recognition / android-alize

ALIZE for the Android platform.
GNU Lesser General Public License v3.0
35 stars 17 forks source link

Cannot use raw file to create speaker model #7

Closed ra2637 closed 6 years ago

ra2637 commented 6 years ago

Hi,

I am using a raw audio file to create the speaker model, the code is as following:

            AssetFileDescriptor audioFile = getApplicationContext().getAssets().openFd("raw.wav");

            //Translating from AssetDescriptor to Byte array
            byte[] audio = new byte[(int)audioFile.getLength()];
            audioFile.createInputStream().read(audio);

            // Send audio to the system
            alizeSystem.addAudio(audio);     //only the bytes

            // Train a model with the audio
            System.out.println("Creating speaker model...");
            alizeSystem.createSpeakerModel("speaker1");

The raw.wav file is actually a raw file, I changed the extension to .wav since I put the file in android assets and it only accept some kinds of extensions.

And my alize config file is as following:

distribType         GD
maxLLK              200
minLLK              -200
bigEndian           false
saveMixtureFileFormat       RAW
loadMixtureFileFormat       RAW
loadFeatureFileFormat       RAW
featureServerBufferSize     ALL_FEATURES
featureFilesPath        data/
mixtureFilesPath        data/

MAPAlgo                             MAPOccDep
loadFeatureFileExtension        .prm

After ran the program, I got the exception:

I/System.out: Creating speaker model...
W/System.err: AlizeSpkRec.AlizeException: [ InvalidDataException 0x73732f4c80 ]
W/System.err:   message   = "Wrong number of data"
W/System.err:   source file = /Workspace/alize/android-alize/alize/src/main/cpp/alize-core/src/FeatureFileReaderRaw.cpp
W/System.err:   line number = 98
W/System.err:   fileName =  /data/user/0/com.example.android.voicecamera/files/data/171113_200409.prm
W/System.err:     at AlizeSpkRec.SimpleSpkDetSystem.createSpeakerModel(Native Method)

I traced the FeatureFileReaderRaw.cpp and think it might be the problem of loadFeatureFileVectSize, and add loadFeatureFileVectSize 16 in the config file, and it crashed in addAudio function.

I/System.out: {AssetFileDescriptor: {ParcelFileDescriptor: java.io.FileDescriptor@e58a10a} start=13611864 len=354048}
W/System.err: AlizeSpkRec.AlizeException: [ IOException 0x73732f48c0 ]
W/System.err:   message   = "Failed to parameterize audio file"
W/System.err:   source file = /Workspace/alize/android-alize/alize/src/main/cpp/LIA_RAL/LIA_SpkDet/SimpleSpkDetSystem/src/SimpleSpkDetSystem.cpp
W/System.err:   line number = 558
W/System.err:   fileName =  /data/user/0/com.example.android.voicecamera/files/171113_200822.audio
W/System.err:     at AlizeSpkRec.SimpleSpkDetSystem.addAudio(Native Method)
...
A/libc: Fatal signal 11 (SIGSEGV), code 1, fault addr 0x220140000c in tid 15662 (FinalizerDaemon)

        [ 11-13 14:08:22.978   376:  376 W/         ]
        debuggerd: handling request: pid=15653 uid=10111 gid=10111 tid=15662
Application terminated.

Is there any suggestion that I can do here? Thanks.

ra2637 commented 6 years ago

I am thinking to close the issue. Since the problem solved after I use the published default config file. Thanks for the default config file, and I'd recommend to explain each fields so other's can modify the config to fit their system. Thanks!