我无法使用 musicg 库中的 FingerprintSimilarity
I'm not able to use FingerprintSimilarity from musicg library
我正在尝试在我的 android 项目中实现 musicg 库。
我已经成功地将它导入到我的项目中并尝试使用它来比较两个音频文件并获得它们之间的相似性。
这是我的代码:
final String rootPath = Environment.getExternalStorageDirectory().getPath() + "/Myapp/music/";
String p1 = rootPath + "outputfiles/1.wav";
String p2 = rootPath + "outputfiles/com.wav";
Wave w1 = new Wave(p1);
Wave w2 = new Wave(p2);
FingerprintSimilarity fingerprintSimilarity = w1.getFingerprintSimilarity(w2);
float score = fingerprintSimilarity.getScore();
float similarity = fingerprintSimilarity.getSimilarity();
Log.d("Similar sound :", "Score : " + score + "\n Similarity : "+ similarity);
但是当我 运行 它时,我的应用程序崩溃了:
FingerprintSimilarity fingerprintSimilarity = w1.getFingerprintSimilarity(w2);
我也调试了我的应用程序,但调试报告中没有报告错误。
请帮我。
提前谢谢你
可能是文件不存在或波形格式不正确?我建议添加更多调试信息以查看问题,例如:
try {
final String rootPath = Environment.getExternalStorageDirectory().getPath() + "/Myapp/music/";
String p1 = rootPath + "outputfiles/1.wav";
Log.d("p1 " + p1);
File f1 = new File(p1);
Log.d("f1 " + f1.exists() && !f1.isDirectory());
String p2 = rootPath + "outputfiles/com.wav";
Log.d("p2 " + p2);
File f2 = new File(p2);
Log.d("f2 " + f2.exists() && !f2.isDirectory());
Wave w1 = new Wave(p1);
Log.d("w1 " + w1);
Wave w2 = new Wave(p2);
Log.d("w2 " + w2);
FingerprintSimilarity fingerprintSimilarity = w1.getFingerprintSimilarity(w2);
Log.d("fingerprintSimilarity " + fingerprintSimilarity );
float score = fingerprintSimilarity.getScore();
Log.d("score " + score );
float similarity = fingerprintSimilarity.getSimilarity();
Log.d("Similar sound :", "Score : " + score + "\n Similarity : "+ similarity);
} catch (Exception e) {
Log.d("Error" + e.getMessage());
}
我正在尝试在我的 android 项目中实现 musicg 库。 我已经成功地将它导入到我的项目中并尝试使用它来比较两个音频文件并获得它们之间的相似性。
这是我的代码:
final String rootPath = Environment.getExternalStorageDirectory().getPath() + "/Myapp/music/";
String p1 = rootPath + "outputfiles/1.wav";
String p2 = rootPath + "outputfiles/com.wav";
Wave w1 = new Wave(p1);
Wave w2 = new Wave(p2);
FingerprintSimilarity fingerprintSimilarity = w1.getFingerprintSimilarity(w2);
float score = fingerprintSimilarity.getScore();
float similarity = fingerprintSimilarity.getSimilarity();
Log.d("Similar sound :", "Score : " + score + "\n Similarity : "+ similarity);
但是当我 运行 它时,我的应用程序崩溃了:
FingerprintSimilarity fingerprintSimilarity = w1.getFingerprintSimilarity(w2);
我也调试了我的应用程序,但调试报告中没有报告错误。 请帮我。 提前谢谢你
可能是文件不存在或波形格式不正确?我建议添加更多调试信息以查看问题,例如:
try {
final String rootPath = Environment.getExternalStorageDirectory().getPath() + "/Myapp/music/";
String p1 = rootPath + "outputfiles/1.wav";
Log.d("p1 " + p1);
File f1 = new File(p1);
Log.d("f1 " + f1.exists() && !f1.isDirectory());
String p2 = rootPath + "outputfiles/com.wav";
Log.d("p2 " + p2);
File f2 = new File(p2);
Log.d("f2 " + f2.exists() && !f2.isDirectory());
Wave w1 = new Wave(p1);
Log.d("w1 " + w1);
Wave w2 = new Wave(p2);
Log.d("w2 " + w2);
FingerprintSimilarity fingerprintSimilarity = w1.getFingerprintSimilarity(w2);
Log.d("fingerprintSimilarity " + fingerprintSimilarity );
float score = fingerprintSimilarity.getScore();
Log.d("score " + score );
float similarity = fingerprintSimilarity.getSimilarity();
Log.d("Similar sound :", "Score : " + score + "\n Similarity : "+ similarity);
} catch (Exception e) {
Log.d("Error" + e.getMessage());
}