总是从AcrCloud API Android获得1001错误(无结果)

时间:2019-05-19 19:43:04

标签: android api file

我正在使用acrcloud-android-sdk-1.5.9.jar库来尝试从acr中获取一些元数据,但是对于所有文件我总是会遇到相同的错误。我无法停止以错误的方式读取文件,有人可以帮忙吗?

我已经仔细检查了项目的桶,主机,密钥和机密以及所有匹配项。我还试图改变我从文件中获取字节的方式,试图从很多不同的歌曲中提取元数据,但没有任何效果。

公共类识别器{     ACRCloudClient客户端;

public void Recognizer() {


    client = new ACRCloudClient();
    ACRCloudConfig config = new ACRCloudConfig();

    config.accessKey = "k";
    config.accessSecret = "s";
    config.host = "h";
    config.context = App.binder.get();
    config.reqMode = ACRCloudConfig.ACRCloudRecMode.REC_MODE_REMOTE;

    config.acrcloudResultWithAudioListener = new IACRCloudResultWithAudioListener() {
        @Override public void onResult(ACRCloudResult acrCloudResult) {
            Log.d(App.myFuckingUniqueTAG + "Recognizer", "onResult: 1" + acrCloudResult.getResult());
        }

        @Override public void onVolumeChanged(double v) {
            Log.d(App.myFuckingUniqueTAG + "Recognizer", "onVolumeChanged: 1" + v);
        }
    };

    config.acrcloudListener = new IACRCloudListener() {
        @Override public void onResult(String s) {
            Log.d(App.myFuckingUniqueTAG + "Recognizer", "onResult: 2 " + s);
        }

        @Override public void onVolumeChanged(double v) {
            Log.d(App.myFuckingUniqueTAG + "Recognizer", "onVolumeChanged: " + v);
        }
    };

    Log.d(App.myFuckingUniqueTAG + "Recognizer", "Recognizer: chicking: Initialized? " + client.initWithConfig(config));


    final Track track = new NativeTracks().getTracksByName("Stressed out").get(0);
    Log.d(App.myFuckingUniqueTAG + "Recognizer", "Recognizer:  " + track.getTitle() + " " + track.getAlbum().getName() + "  " + track.getArtist().getArtistName());
    Runnable mRunnable = new Runnable() {
        @Override
        public void run() {
            try {
                recognize(track.getFilePath());
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    };
    new Thread(mRunnable).start();
}

private void recognize(String path) throws IOException {


    File file = new File(path);
    byte[] b = new byte[(int) file.length()];
    FileInputStream fileInputStream = new FileInputStream(file);
    fileInputStream.read(b);


    String result = client.recognize(b, b.length);
    Log.d(App.myFuckingUniqueTAG + "Recognizer", "recognize: " + result + " <> " + b.length);

}

}

0 个答案:

没有答案