Exemplo n.º 1
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)
Exemplo n.º 2
0
                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()):