为什么我的代码中的指纹刺激不起作用



我正在创建一个应用程序来识别两个波文件的声音,因为这样做,我发现了" Musicg"库用于此目的。因此,我只是在项目中写一个简单的代码,以查看声音是否相似,但是当我运行项目崩溃时,我发现该程序遇到指纹simerity = wave.getfinger.getfingerprintsimerity(wave1(;然后它崩溃了,所以有人可以告诉我我在哪里犯了什么错误?

这是我的简单代码

FingerprintSimilarity fingerprintSimilarity;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        Wave wave = new Wave("sampledata/cock_a_1.wav");
        Wave wave1 = new Wave("sampledata/cock_a_1.wav");
        
        fingerprintSimilarity = wave.getFingerprintSimilarity(wave1);

       float score = fingerprintSimilarity.getScore();
       float similarity = fingerprintSimilarity.getSimilarity();
       Log.d("hi","score :" +score+ "n Similarity :" + similarity);

    }

它给了我这些错误:

03-24 23:42:41.984 2817-2817/com.example.fiterprint e/androidruntime:致命例外:主要过程:com.example.fingerprint,pid:2817java.lang.runtimeException:无法启动活动ComponentInfo {com.example.fingerprint/com.example.finger.fingerprint.mainactivity}:java.lang.nullpointerexception:尝试调用firtual method'int com.musicg.wave.wave.wave.wave.wave.wave.wave.wave.wave.wave.wave.wave.wave.wave.waveheader.getsamplore(('在空对象引用上在android.app.act.activitythread.performlaunchactivity(activityThread.java:2416(在android.app.act.activitythread.handlelaunchactivity(activityThread.java:2476(at android.app.ActivityThread.-wrap11(activityThread.java(at android.app.ActivityThread $ H.Handlemessage(activityThread.java:1344(at android.os.handler.dispatchmessage(Handler.java:102(at android.os.looper.loop(looper.java:148(at android.app.activitythread.main(activityThread.java:5417(在java.lang.reflect.method.invoke(本机方法(上在com.android.internal.os.os.zygoteinit $ methodAndargScaller.run(zygoteinit.java:726(在com.android.internal.os.os.zygoteinit.main(zygoteinit.java:616(引起:java.lang.nullpointerexception:尝试调用虚拟方法'int com.musicg.wave.wavehave.waveheader.getsamplerate(('null对象参考在com.musicg.fingerprint.fingerprintmanager.extractfingerprint(Fingerprintmanager.java:69(在com.musicg.wave.wave.getfingerprint(wave.java:329(在com.musicg.wave.wave.getfingerprintsimerity(wave.java:335(在com.example.fingerprint.mainactivity.oncreate(MainActivity.java:31(在android.app.activity.performcreate(activity.java:6237(at android.app.instrumentation.callactivityoncreate(instrumentation.java:1107(at android.app.activitythread.performlaunchactivity(activityThread.java:2369(在android.app.act.activitythread.handlelaunchactivity(activityThread.java:2476(at android.app.ActivityThread.-wrap11(activityThread.java(at android.app.ActivityThread $ H.Handlemessage(activityThread.java:1344(at android.os.handler.dispatchmessage(Handler.java:102(at android.os.looper.loop(looper.java:148(at android.app.activitythread.main(activityThread.java:5417(在java.lang.reflect.method.invoke(本机方法(上在com.android.internal.os.os.zygoteinit $ methodAndargScaller.run(zygoteinit.java:726(在com.android.internal.os.os.zygoteinit.main(zygoteinit.java:616(

wave((方法接受" inputstream"作为参数,而不是文件的路径。将文件的路径转换为InpustReam类型,然后将其放入Wave参数中。

相关内容

  • 没有找到相关文章

最新更新