Ejemplo n.º 1
0
  public void printTheBestByThr(long thr) {
    System.out.println("------THE BEST BY SPEAKERil------");
    Hashtable cluster = clusterResultSet.getCluster();
    Iterator<String> it = cluster.keySet().iterator();
    Hashtable<String, Vector> speaker = new Hashtable<String, Vector>();
    while (it.hasNext()) {
      String cr_it = (String) it.next();
      // System.out.println(cr_it);
      ClusterResult cr = (ClusterResult) cluster.get(cr_it);
      Object[] db_arr = cr.getValue().keySet().toArray();
      Arrays.sort(db_arr);
      int ln = db_arr.length;
      if (speaker.keySet().contains((String) cr.getValue().get(db_arr[ln - 1]))) {
        Vector<String> tmp = speaker.get(cr.getValue().get(db_arr[ln - 1]));
        tmp.add(cr_it);
        speaker.put((String) cr.getValue().get(db_arr[ln - 1]), tmp);
      } else {
        Vector<String> tmp = new Vector<String>();
        tmp.add(cr_it);
        speaker.put((String) cr.getValue().get(db_arr[ln - 1]), tmp);
      }
      // System.out.println("score="+db_arr[ln-1] +" name="+cr.getValue().get(db_arr[ln-1])  );
    }
    Iterator<String> sp_it = speaker.keySet().iterator();
    // String f
    // ="/Users/labcontenuti/Documents/workspace/AudioActive/84/test_file/properties/testindent.txt";

    OutputStreamWriter dos;
    try {
      dos =
          new OutputStreamWriter(new FileOutputStream(outputRoot + "/" + baseName + "_ident.txt"));

      while (sp_it.hasNext()) {
        String key = (String) sp_it.next();
        System.out.println("name=" + key);
        for (int i = 0; i < ((Vector) speaker.get(key)).size(); i++) {
          TreeMap<Integer, Segment> map =
              clusterSetResult
                  .getCluster((String) ((Vector) speaker.get(key)).get(i))
                  .clusterToFrames();
          System.out.println(
              " cluster="
                  + ((Vector) speaker.get(key)).get(i)
                  + " lenght="
                  + clusterSetResult
                      .getCluster((String) ((Vector) speaker.get(key)).get(i))
                      .getLength());
          dos.write(((Vector) speaker.get(key)).get(i) + "=" + key + "\n");
        }
      }

      dos.close();
    } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
  }