Example #1
0
def run(args):
    single_speaker = len(args.sep_scp.split(",")) == 1
    reporter = Report(args.spk2gender)

    if single_speaker:
        sep_reader = WaveReader(args.sep_scp)
        ref_reader = WaveReader(args.ref_scp)
        for key, sep in tqdm(sep_reader):
            ref = ref_reader[key]
            if sep.size != ref.size:
                end = min(sep.size, ref.size)
                sep = sep[:end]
                ref = ref[:end]
            snr = si_snr(sep, ref)
            reporter.add(key, snr)
    else:
        sep_reader = SpeakersReader(args.sep_scp)
        ref_reader = SpeakersReader(args.ref_scp)
        for key, sep_list in tqdm(sep_reader):
            ref_list = ref_reader[key]
            if sep_list[0].size != ref_list[0].size:
                end = min(sep_list[0].size, ref_list[0].size)
                sep_list = [s[:end] for s in sep_list]
                ref_list = [s[:end] for s in ref_list]
            snr = permute_si_snr(sep_list, ref_list)
            reporter.add(key, snr)
    reporter.report()
Example #2
0
def run(args):
    single_speaker = len(args.sep_scp.split(",")) == 1
    reporter = Report(args.spk2class)
    details = open(args.details, "w") if args.details else None

    if single_speaker:
        sep_reader = WaveReader(args.sep_scp)
        ref_reader = WaveReader(args.ref_scp)
        for key, sep in tqdm(sep_reader):
            ref = ref_reader[key]
            if sep.size != ref.size:
                end = min(sep.size, ref.size)
                sep = sep[:end]
                ref = ref[:end]
            snr = si_snr(sep, ref)
            reporter.add(key, snr)
            if details:
                details.write("{}\t{:.2f}\n".format(key, snr))
    else:
        sep_reader = SpeakersReader(args.sep_scp)
        ref_reader = SpeakersReader(args.ref_scp)
        for key, sep_list in tqdm(sep_reader):
            ref_list = ref_reader[key]
            if sep_list[0].size != ref_list[0].size:
                end = min(sep_list[0].size, ref_list[0].size)
                sep_list = [s[:end] for s in sep_list]
                ref_list = [s[:end] for s in ref_list]
            snr = permute_si_snr(sep_list, ref_list)
            reporter.add(key, snr)
            if details:
                details.write("{}\t{:.2f}\n".format(key, snr))
    reporter.report()
    if details:
        details.close()
def run(args):
    print("Working on folder {}".format(args.sep_scp))
    #get all scp files from separation folder
    folder = sorted(glob(args.sep_scp+'/*.scp', recursive=False)) # ndarray of names of all samples
    sep_scp = ""
    for scp in folder: # build string from array of scp files
        sep_scp += scp + "," 
    sep_scp = sep_scp[:-1] #remove last comma
    
    single_speaker = len(sep_scp.split(",")) == 1
    reporter = Report(args.spk2gender, outputDir=args.sep_scp)

    if single_speaker:
        sep_reader = WaveReader(sep_scp)
        ref_reader = WaveReader(args.ref_scp)
        for key, sep in tqdm(sep_reader):
            ref = ref_reader[key]
            if sep.size != ref.size:
                end = min(sep.size, ref.size)
                sep = sep[:end]
                ref = ref[:end]
            snr = si_snr(sep, ref)
            reporter.add(key, snr)
    else:
        sep_reader = SpeakersReader(sep_scp)
        ref_reader = SpeakersReader(args.ref_scp)

        for key, sep_list in tqdm(sep_reader):
            ref_list = ref_reader[key]
            zero_ref_list = ref_reader[key]
            if args.mixofmix != 0:
                if len(ref_list) > len(sep_list):
                    raise RuntimeError("There are more references then separs")
                #create zero references
                for i in range(len(sep_list) - len(ref_list)):
                    zero_ref_list.append(np.zeros_like(ref_list[0])+0.0001)
            #Cut lengths
            if sep_list[0].size != ref_list[0].size:
                end = min(sep_list[0].size, ref_list[0].size)
                sep_list = [s[:end] for s in sep_list]
                ref_list = [s[:end] for s in ref_list]
                zero_ref_list = [s[:end] for s in zero_ref_list]
            if args.mixofmix != 0: # get right outputs combination
                right_sep_list = permute_si_snr_mix_of_mix(sep_list, zero_ref_list)  
            else: right_sep_list = sep_list #compatibility
            #PIT
            snr = permute_si_snr(right_sep_list[:len(ref_list)], ref_list)
            reporter.add(key, snr)
    reporter.report()
Example #4
0
def run(args):
    single_speaker = len(args.sep_scp.split(",")) == 1
    reporter = Report(args.spk2class)
    utt_snr = open(args.per_utt, "w") if args.per_utt else None
    utt_ali = open(args.utt_ali, "w") if args.utt_ali else None

    if single_speaker:
        sep_reader = WaveReader(args.sep_scp)
        ref_reader = WaveReader(args.ref_scp)
        for key, sep in tqdm(sep_reader):
            ref = ref_reader[key]
            if sep.size != ref.size:
                end = min(sep.size, ref.size)
                sep = sep[:end]
                ref = ref[:end]
            snr = si_snr(sep, ref)
            reporter.add(key, snr)
            if utt_snr:
                utt_snr.write("{}\t{:.2f}\n".format(key, snr))
    else:
        sep_reader = SpeakersReader(args.sep_scp)
        ref_reader = SpeakersReader(args.ref_scp)
        for key, sep_list in tqdm(sep_reader):
            ref_list = ref_reader[key]
            if sep_list[0].size != ref_list[0].size:
                end = min(sep_list[0].size, ref_list[0].size)
                sep_list = [s[:end] for s in sep_list]
                ref_list = [s[:end] for s in ref_list]
            snr, ali = permute_si_snr(sep_list, ref_list, align=True)
            reporter.add(key, snr)
            if utt_snr:
                utt_snr.write(f"{key}\t{snr:.2f}\n")
            if utt_ali:
                ali_str = " ".join(map(str, ali))
                utt_ali.write(f"{key}\t{ali_str}\n")
    reporter.report()
    if utt_snr:
        utt_snr.close()
    if utt_ali:
        utt_ali.close()