JAudio Feature文件在Desktop Compiler中工作,但在Android中不工作(错误:features.xml文件格式不正确)

时间:2018-11-12 20:04:02

标签: java android xml audio feature-extraction

我想提取音频功能,我正在提供wav音频文件,并想要获取arff文件。

    package Sound;
    import jAudioFeatureExtractor.ACE.DataTypes.Batch;
    import jAudioFeatureExtractor.DataModel;
    import java.io.File;
    import java.io.FileOutputStream;
    import java.io.OutputStream;

    public class Analysis {

   String featureFile =  getFilesDir()+ "/features.xml";
   String settingsFile = getFilesDir() + "/settings.xml";
   String FKOuputFile = getFilesDir() + "/fk.xml";
   String FVOuputFile = getFilesDir() + "/fv.xml";

     public String extractAudioFeatures() {
        Batch batch = new Batch(featureFile, null);
        try{
            batch.setRecordings(new File[]{new File(musicFile)});
            batch.getAggregator();
            batch.setSettings(settingsFile);

            DataModel dm = batch.getDataModel();
            OutputStream valsavepath = new FileOutputStream(FVOuputFile);
            OutputStream defsavepath = new FileOutputStream(FKOuputFile);
            dm.featureKey = defsavepath;
            dm.featureValue = valsavepath;
            batch.setDataModel(dm);

            batch.execute();
        }
        catch (Exception e){
            e.printStackTrace();
        }
    }
}

我正在尝试使用此代码获取arff文件,并且我使用的是具有GUI的Jar。 Feature.xml在Jaudio GUI和Netbeans,IntelliJ和Eclipse(意味着在桌面环境中)中都可以正常工作,但在android中则无法工作,而在Android中则是以下错误:

11-12 23:54:52.100 27977-27977 W/System.err: java.lang.Exception: The /storage/emulated/0/features.xml file is not formatted properly.
11-12 23:54:52.101 27977-27977 W/System.err: Details of the problem: Couldn't open /storage/emulated/0/features.xml
        at jAudioFeatureExtractor.ACE.XMLParsers.XMLDocumentParser.parseXMLDocument(XMLDocumentParser.java:109)
        at jAudioFeatureExtractor.DataModel.<init>(DataModel.java:175)
        at jAudioFeatureExtractor.ACE.DataTypes.Batch.init(Batch.java:87)
        at jAudioFeatureExtractor.ACE.DataTypes.Batch.<init>(Batch.java:81)

0 个答案:

没有答案