Beispiel #1
0
 #v = Voiceid(db, '/Users/labcontenuti/Desktop/voiceid/adaltavoce/test/Piero_Baldini##mobyDick01_1sec.wav')
 #v = Voiceid(db, '/Users/labcontenuti/Desktop/voiceid/adaltavoce/test/Piero_Baldini##mobyDick01_3sec.wav')
 #v = Voiceid(db, '/Users/labcontenuti/Desktop/voiceid/DataSetVideolinaVoci/Giacomo_Mameli/2/Giacomo_Mameli##1-1.wav')
 v = Voiceid(db, '/Users/labcontenuti/Documents/workspace/activevoice/audio_test/2sec.wav')
     
 v.extract_speakers()
 
 for c in v.get_clusters():
     #print "c ", c   
     cluster = v.get_cluster(c) 
     """
     print "cluster.get_name ", cluster.get_name()        
     print "cluster.get_best_speaker ", cluster.get_best_speaker()
     print "cluster.get_duration ", cluster.get_duration()
     print "cluster.to_dict ", cluster.to_dict()
     print "cluster.get_segments ", cluster.get_segments()
     cluster.print_segments()
     #cluster.print_segments()
     """
     print "cluster.wave ", cluster.wave
     print "cluster.get_name ", cluster.get_name()
     print "\n\n\n\n\n\n"
     list_seg=cluster.get_segments()
     for seg in list_seg:
         print "start %s stop %s" %  (humanize_time(float(seg.get_start()) / 100),  humanize_time(float(seg.get_end()) / 100))
         print "speaker ", cluster.get_best_speaker()
         print "get_basename ",seg.get_basename()
         print "\n\n"
     print
  
 print "RND"
Beispiel #2
0
         
 if True:
         print "=============SHELVE================"
         sdb= shelve.open(FILE_PATH+"_shelve")
         tmp_sdb={}
         """
         db = GMMVoiceDB(DB_PATH)
         v = Voiceid(db, FILE_PATH)            
         v.extract_speakers()
         """
         for c in v.get_clusters():
             cluster = v.get_cluster(c)
             print "", cluster._label, " cluster.get_best_five()[0][0]=", cluster.get_best_five()[0][0], "  cluster.get_distance()=", cluster.get_distance(), " cluster.get_distance()>SCORE", cluster.get_distance()<SCORE
             speaker="Unknown" 
             if cluster.get_distance()>SCORE:
                 speaker=cluster.get_best_five()[0][0]
             sp0=cluster.get_best_five()[0][0]
             sp1=cluster.get_best_five()[0][1]
             if sp0.startswith(sp1[0:-1]) or sp1.startswith(sp0[0:-1]): 
                 speaker=cluster.get_best_five()[0][0] 
             list_seg=cluster.get_segments()
             for seg in list_seg:
                 tmp_sdb[seg.get_start()]=[str(speaker),str( humanize_time( (float(seg.get_end())-float(seg.get_start())) / 100) ),str( humanize_time(float(seg.get_end()) / 100) ), str( humanize_time(float(seg.get_start()) / 100) )]
         tmp_sdb_keys=tmp_sdb.keys()
         tmp_sdb_keys.sort()
         for k in tmp_sdb_keys:
             sdb[str(k)]=tmp_sdb[k]
             sdb.sync()
             print " start = ", str(k), " data=", sdb[str(k)]
         sdb.close()
 print "RND"
Beispiel #3
0
def test_dir():
    all_wav = []
    for f in os.listdir(DIR_PATH):
        if fnmatch.fnmatch(f, "*.wav") and f.find("##") > -1:
            all_wav.append(f)
    all_wav = verify_goodness(all_wav)
    print all_wav
    print "verifica ok... procediamo"

    logging.basicConfig(filename=DIR_PATH + "/result.log", level=logging.INFO)

    db = GMMVoiceDB("/Users/labcontenuti/.voiceid/gmm_db")
    # filter_criteria="Fabrizio_Gifuni##02Pasticciaccio.wav"
    for wav in all_wav:
        # if wav.find(filter_criteria)>-1:
        print "--------------------" + wav + "------------------------"
        v = Voiceid(db, DIR_PATH + wav)
        v.extract_speakers()

        logging.info("\n\n\n---------------------" + wav + "------------------")
        wav_tostring = str(wav) + ";   "

        for c in v.get_clusters():
            cluster = v.get_cluster(c)
            for seg in cluster.get_segments():
                print "\n seg: ", seg
                print seg.get_start()
                print seg.get_end()
                print humanize_time(seg.get_duration())

            print "cluster.get_duration  ", cluster.get_duration()
            logging.info("duration: " + str(cluster.get_duration()))
            wav_tostring = wav_tostring + ":  " + "duration:" + str(cluster.get_duration())

            print "cluster.get_name ", cluster.get_name()
            print "cluster.get_best_speaker ", cluster.get_best_speaker(), " correct?", verify_speaker(
                wav, cluster.get_best_speaker()
            )
            logging.info("best_speaker " + str(cluster.get_best_speaker()))
            wav_tostring = wav_tostring + ";  " + "best_speaker:" + str(cluster.get_best_speaker())

            print "v._get_time() ", v._get_time(), " ", humanize_time(v._get_time())
            logging.info("get_time:  " + str(humanize_time(v._get_time())))
            wav_tostring = wav_tostring + ";  " + "get_time:" + str(humanize_time(v._get_time()))

            # if cluster.get_best_speaker()=="unknown":
            print "cluster.get_best_five ", cluster.get_best_five(), cluster.get_best_five()[0]
            logging.info("best of five: " + str(cluster.get_best_five()[0]))
            wav_tostring = wav_tostring + ";  " + "best of five:" + str(cluster.get_best_five()[0])

            print "cluster.get_distance() ", str(cluster.get_distance())
            logging.info("distance best-closest " + str(cluster.get_distance()))
            wav_tostring = wav_tostring + ";  " + "distance best-closest:" + str(cluster.get_distance())

            print
            if not cluster.get_best_speaker() == "unknown":
                if verify_speaker(wav, cluster.get_best_speaker()):
                    find_ok.append(wav_tostring)
                else:
                    find_errata.append(wav_tostring)
            else:
                not_find.append(wav_tostring)
                if verify_speaker(wav, cluster.get_best_five()[0][0]):
                    unknown_ok.append(wav_tostring)
                else:
                    unknown_errata.append(wav_tostring)

        print "Number TEST--" + str(len(find_ok) + len(find_errata) + len(not_find))
        print "OK---------  " + str(len(find_ok))
        print "ERRATA-------" + str(len(find_errata))
        print "UNKNOWN------" + str(len(not_find))
        print "UNKNOWN ERR--" + str(len(unknown_errata))
        print "UNKNOWN  OK--" + str(len(unknown_ok))
    # resutl_file=file(DIR_PATH+"result.txt", "a+")

    logging.info("\n\n")  # for wav in unknown_errata:
    logging.info("Number TEST " + str(len(find_ok) + len(find_errata) + len(not_find)))
    logging.info("ok " + str(len(find_ok)))
    logging.info("ERRATA" + str(len(find_errata)))
    logging.info("UNKNOWN" + str(len(not_find)))
    logging.info("UNKNOWN ERR " + str(len(unknown_errata)))
    logging.info("UNKNOWN  OK " + str(len(unknown_ok)))

    logging.info("\n\n\n----UNKNOWN  OK ---")
    for f in unknown_ok:
        logging.info(f)

    logging.info("\n\n\n----UNKNOWN  ERRATA ---")
    for f in unknown_errata:
        logging.info(f)

    logging.info("\n\n\n----ERRATA---")
    for f in find_errata:
        logging.info(f)
Beispiel #4
0
    for wav in all_wav:
        # if wav.find(filter_criteria)>-1:
        print "--------------------" + wav + "------------------------"
        v = Voiceid(db, DIR_PATH + wav)
        v.extract_speakers()

        logging.info("\n\n\n---------------------" + wav + "------------------")
        wav_tostring = str(wav) + ";   "

        for c in v.get_clusters():
            cluster = v.get_cluster(c)
            for seg in cluster.get_segments():
                print "\n seg: ", seg
                print seg.get_start()
                print seg.get_end()
                print humanize_time(seg.get_duration())

            print "cluster.get_duration  ", cluster.get_duration()
            logging.info("duration: " + str(cluster.get_duration()))
            wav_tostring = wav_tostring + ":  " + "duration:" + str(cluster.get_duration())

            print "cluster.get_name ", cluster.get_name()
            print "cluster.get_best_speaker ", cluster.get_best_speaker(), " correct?", verify_speaker(
                wav, cluster.get_best_speaker()
            )
            logging.info("best_speaker " + str(cluster.get_best_speaker()))
            wav_tostring = wav_tostring + ";  " + "best_speaker:" + str(cluster.get_best_speaker())

            print "v._get_time() ", v._get_time(), " ", humanize_time(v._get_time())
            logging.info("get_time:  " + str(humanize_time(v._get_time())))
            wav_tostring = wav_tostring + ";  " + "get_time:" + str(humanize_time(v._get_time()))