public BaselineAdaptationSet getInputSet(String inputFolder) { BasenameList b = new BasenameList(inputFolder, BaselineAdaptationSet.WAV_EXTENSION_DEFAULT); BaselineAdaptationSet inputSet = new BaselineAdaptationSet(b.getListAsVector().size()); for (int i = 0; i < inputSet.items.length; i++) inputSet.items[i].setFromWavFilename(inputFolder + b.getName(i) + BaselineAdaptationSet.WAV_EXTENSION_DEFAULT); return inputSet; }
/** * Ensure that the list is alphabetically sorted. * */ public void sort() { String[] str = getListAsArray(); Arrays.sort(str); bList.removeAllElements(); add(str); hasChanged = true; }
/** * Check if two lists are equal. * * @param bnl * The list of basenames to check for. * @return true if yes, false if no. */ public boolean equals(BasenameList bnl) { if (bnl.getLength() != this.getLength()) return (false); for (int i = 0; i < bnl.getLength(); i++) { if (!this.contains(bnl.getName(i))) return (false); } return (true); }
/** * Removes a list from another list. * * @param bnl * The basename list to remove. * @return true if the list was containing any element of the list to remove. */ public boolean remove(BasenameList bnl) { boolean ret = true; for (int i = 0; i < bnl.getLength(); i++) { bList.remove(bnl.getName(i)); } hasChanged = true; return (ret); }
@Override protected void initialiseComp() { featureCategories = new ArrayList<String>(); // feature categories annotationData = new HashMap<String, Map<String, String>>(); // basename --> (feature category, feature value) try { String basenameFile = db.getProp(db.VOCALIZATIONSDIR) + File.separator + "basenames.lst"; if ((new File(basenameFile)).exists()) { System.out.println("Loading basenames of vocalizations from '" + basenameFile + "' list..."); bnlVocalizations = new BasenameList(basenameFile); System.out.println("Found " + bnlVocalizations.getLength() + " vocalizations in basename list"); } else { String vocalWavDir = db.getProp(db.VOCALIZATIONSDIR) + File.separator + "wav"; System.out.println("Loading basenames of vocalizations from '" + vocalWavDir + "' directory..."); bnlVocalizations = new BasenameList(vocalWavDir, ".wav"); System.out.println("Found " + bnlVocalizations.getLength() + " vocalizations in " + vocalWavDir + " directory"); } } catch (IOException e) { e.printStackTrace(); } }
BasenameList checkList = new BasenameList(); while ((line = in.readLine()) != null) { line = line.substring(line.indexOf("(") + 1, line.lastIndexOf(")")); String basename = st.nextToken(); if (bnl.contains(basename)) { checkList.add(basename); PrintWriter out = new PrintWriter(new OutputStreamWriter(new FileOutputStream(new File(textDir, basename + db.getProp(db.TEXTEXT))), "UTF-8")); BasenameList diffList = bnl.duplicate(); diffList.remove(checkList); if (diffList.getLength() != 0) { System.out.println("WARNING: the following utterances have not been found in the file [" + getProp(TRANSCRIPTFILE) + "]:"); for (int i = 0; i < diffList.getLength(); i++) { System.out.println(diffList.getName(i)); bnl.remove(diffList); return (false); } else
/** * @param args * args * @throws IOException * IOException */ public static void main(String[] args) throws IOException { // String inDirName = "/home/sathish/phd/data/original-lab-wav-sync"; // String outDirName = "/home/sathish/phd/data/pauseless-lab-wav-sync"; String inDirName = "/home/sathish/phd/data/original_stimulus_sync"; String outDirName = "/home/sathish/phd/data/pauseless_stimulus_sync"; BasenameList bnl = new BasenameList(inDirName, ".wav"); VocalisationLabelInspector vli = new VocalisationLabelInspector(inDirName, outDirName); for (int i = 0; i < bnl.getLength(); i++) { vli.process(bnl.getName(i)); } }
public boolean compute() throws IOException, Exception { textDir = new File(db.getProp(db.TEXTDIR)); System.out.println("Computing unit features for " + bnl.getLength() + " files"); for (int i = 0; i < bnl.getLength(); i++) { percent = 100 * i / bnl.getLength(); computeFeaturesFor(bnl.getName(i)); // System.out.println( " " + bnl.getName(i) ); } bnl.write(db.getProp(db.ROOTDIR) + File.separator + "newbaselist.txt"); System.out.println("Finished computing the unit features."); return true; }
/** * Returns an autonomous sublist between fromIndex, inclusive, and toIndex, exclusive. * * @param fromIndex * fromIndex * @param toIndex * toIndex * @return basenameList(this.fromDir, this.fromExt, subVec) */ public BasenameList subList(int fromIndex, int toIndex) { Vector subVec = new Vector(toIndex - fromIndex, DEFAULT_INCREMENT); for (int i = fromIndex; i < toIndex; i++) subVec.add(this.getName(i)); return (new BasenameList(this.fromDir, this.fromExt, subVec)); }
String[] baseNameArray = bnlVocalizations.getListAsArray(); System.out.println("Computing pitchmarks for " + baseNameArray.length + " utterances.");
/** * Adds an array of basenames to the list. * * @param str * str */ public void add(String[] str) { for (int i = 0; i < str.length; i++) add(str[i]); hasChanged = true; }
/** * The standard compute() method of the VoiceImportComponent interface. * * @throws IOException * IOException */ public boolean compute() throws IOException { // do not attempt to launch ESTCaller if bnl is empty if (bnl.getLength() < 1) { logger.error("BaseNameList is empty, cannot proceed!"); return false; } String[] baseNameArray = bnl.getListAsArray(); System.out.println("Computing Mel cepstra for [" + baseNameArray.length + "] utterances."); ESTCaller caller = new ESTCaller(db); caller.make_mcep(baseNameArray, db.getProp(DatabaseLayout.PMDIR), db.getProp(DatabaseLayout.PMEXT), getProp(MCEPDIR), mcepExt); return (true); }
/** * Duplicates the list (i.e., emits an autonomous copy of it). * * @return BasenameList (fromdir, fromext, (vector) (bList.clone) */ public BasenameList duplicate() { return (new BasenameList(this.fromDir, this.fromExt, (Vector) (this.bList.clone()))); }
PrintWriter featWeightsOut = new PrintWriter(new OutputStreamWriter(new FileOutputStream(featWeights), "UTF-8"), true); BufferedReader uttFeats = new BufferedReader(new InputStreamReader(new FileInputStream(new File(getProp(FEATUREDIR) + bnl.getName(0) + featureExt)), "UTF-8")); FeatureDefinition featDef = new FeatureDefinition(uttFeats, false); // false: do not read weights uttFeats.close();
percent = 0; String[] baseNameArray = bnl.getListAsArray(); System.out.println("Computing pitchmarks for " + baseNameArray.length + " utterances."); bnl.write(baseNameListFileName);
protected void askIfSave() throws IOException { if (bnl.hasChanged()) { int answer = JOptionPane.showOptionDialog(this, "Do you want to save the list of basenames?", "Save?", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, null, null); if (answer == JOptionPane.YES_OPTION) { JFileChooser fc = new JFileChooser(); fc.setSelectedFile(new File(db.getProp(db.BASENAMEFILE))); int returnVal = fc.showSaveDialog(this); if (returnVal == JFileChooser.APPROVE_OPTION) { bnl.write(fc.getSelectedFile()); } } } else { System.exit(0); } }
/** * Write the basenameList to a file, identified by its name. * * @param fileName * fileName * @throws IOException * IOException */ public void write(String fileName) throws IOException { write(new File(fileName)); }
String[] basenames = bnl.getListAsArray(); String textDir = db.getProp(db.TEXTDIR); String textExt = db.getProp(db.TEXTEXT); textOut.println("( " + basenames[i] + " \"" + line + "\" )"); } catch (FileNotFoundException fnfe) { bnl.remove(basenames[i]); continue;