Esempio n. 1
0
def generate_arguments(config_filename):
    """ This will generate the list of arguments to run simulation for """

    with open(config_filename, "r") as f:
        config = json.load(f)

    rng_state = np.random.get_state()
    np.random.seed(config["seed"])

    # Maximum total number of sources
    n_sources = np.max(config["n_channels_list"])

    # First we randomly select all the speech samples
    gen_files_seed = int(np.random.randint(2**32, dtype=np.uint32))
    all_wav_files = sampling(
        config["n_repeat"],
        n_sources,
        config["samples_list"],
        gender_balanced=True,
        seed=gen_files_seed,
    )

    # now get the transcripts
    with open(config["samples_list"]) as f:
        dataset_metadata = json.load(f)

    all_transcripts = []
    for subset in all_wav_files:
        transcripts = []
        for fn in subset:
            transcripts.append(dataset_metadata["transcripts"][Path(fn).name])
        all_transcripts.append(transcripts)

    # Pick the seeds to reproducibly build a bunch of random rooms
    room_seeds = np.random.randint(2**32,
                                   size=config["n_repeat"],
                                   dtype=np.uint32).tolist()

    args = []
    for n_channels in config["n_channels_list"]:
        for room_id, (wav_files, transcripts, room_seed) in enumerate(
                zip(all_wav_files, all_transcripts, room_seeds)):

            # add the new combination to the list
            args.append([
                n_channels,
                room_id,
                room_seed,
                wav_files[:n_channels],
                transcripts[:n_channels],
                config_filename,
            ])

    np.random.set_state(rng_state)

    return args
def generate_arguments(parameters):
    """ This will generate the list of arguments to run simulation for """

    rng_state = np.random.get_state()
    np.random.seed(parameters["seed"])

    # Maximum total number of sources
    n_sources = np.max(parameters["n_interferers_list"]) + np.max(
        parameters["n_targets_list"])

    # First we randomly select all the speech samples
    gen_files_seed = int(np.random.randint(2**32, dtype=np.uint32))
    all_wav_files = sampling(
        parameters["n_repeat"],
        n_sources,
        parameters["samples_list"],
        gender_balanced=True,
        seed=gen_files_seed,
    )

    # Pick the seeds to reproducibly build a bunch of random rooms
    room_seeds = np.random.randint(2**32,
                                   size=parameters["n_repeat"],
                                   dtype=np.uint32).tolist()

    args = []

    for n_targets in parameters["n_targets_list"]:
        for n_interferers in parameters["n_interferers_list"]:
            for n_mics in parameters["n_mics_list"]:

                # we don't do underdetermined
                if n_targets > n_mics:
                    continue

                for sinr in parameters["sinr_list"]:
                    for wav_files, room_seed in zip(all_wav_files, room_seeds):

                        # generate the seed for this simulation
                        seed = int(np.random.randint(2**32, dtype=np.uint32))

                        # add the new combination to the list
                        args.append([
                            n_targets,
                            n_interferers,
                            n_mics,
                            sinr,
                            wav_files,
                            room_seed,
                            seed,
                        ])

    np.random.set_state(rng_state)

    return args
Esempio n. 3
0
def generate_arguments(parameters):
    """ This will generate the list of arguments to run simulation for """

    rng_state = np.random.get_state()
    np.random.seed(parameters["seed"])

    gen_files_seed = int(np.random.randint(2**32, dtype=np.uint32))
    all_wav_files = sampling(
        parameters["n_repeat"],
        parameters["n_interferers"] + np.max(parameters["n_targets_list"]),
        parameters["samples_list"],
        gender_balanced=True,
        seed=gen_files_seed,
    )

    args = []

    for n_targets in parameters["n_targets_list"]:
        for n_mics in parameters["n_mics_list"]:

            # we don't do underdetermined
            if n_targets > n_mics:
                continue

            for rt60 in parameters["rt60_list"].keys():
                for sinr in parameters["sinr_list"]:
                    for wav_files in all_wav_files:

                        # generate the seed for this simulation
                        seed = int(np.random.randint(2**32, dtype=np.uint32))

                        # add the new combination to the list
                        args.append(
                            [n_targets, n_mics, rt60, sinr, wav_files, seed])

    np.random.set_state(rng_state)

    return args
Esempio n. 4
0
    target_locs = semi_circle_layout([4.1, 3.755, 1.1],
                                     np.pi / 2,
                                     2.0,
                                     n_sources_target,
                                     rot=0.743 * np.pi)
    # interferer_locs = grid_layout([3., 5.5], n_sources - n_sources_target, offset=[6.5, 1., 1.7])
    interferer_locs = random_layout([3.0, 5.5, 1.5],
                                    n_sources - n_sources_target,
                                    offset=[6.5, 1.0, 0.5],
                                    seed=1)
    source_locs = np.concatenate((target_locs, interferer_locs), axis=1)

    # Prepare the signals
    wav_files = sampling(1,
                         n_sources,
                         f"{samples_dir}/metadata.json",
                         gender_balanced=True,
                         seed=8)[0]
    signals = wav_read_center(wav_files, seed=123)

    # Place the blinkies regularly in the room (2D plane)
    blinky_locs = gm_layout(n_blinkies,
                            target_locs - np.c_[[0.0, 0.0, 0.4]],
                            std=[0.4, 0.4, 0.05],
                            seed=987)

    all_locs = np.concatenate((mic_locs, blinky_locs), axis=1)

    # Create the room itself
    room = pra.ShoeBox(room_dim,
                       fs=fs,
Esempio n. 5
0
    #source_locs[2,:] += np.random.uniform(-0.02, 0.02, size=n_sources)
    '''
    source_locs = np.c_[
            [3., 4.,  1.7],  # target source 1
            [3., 6.,  1.7],  # target source 2
            [2., 1.5, 1.9],  # interferer 1
            [4., 1.5, 1.9],  # interferer 1
            [6., 1.5, 1.9],  # interferer 1
            [8., 1.5, 1.9],  # interferer 1
            ]
    '''

    # Prepare the signals
    wav_files = sampling(1,
                         n_sources,
                         'samples/metadata.json',
                         gender_balanced=True,
                         seed=8)[0]
    signals = wav_read_center(wav_files, seed=123)

    # Place the blinkies regularly in the room (2D plane)
    #blinky_locs = grid_layout([3,5.5], n_blinkies, offset=[1., 1., 0.8])
    blinky_locs = gm_layout(n_blinkies,
                            target_locs - np.c_[[0., 0., 0.4]],
                            std=[0.4, 0.4, 0.05],
                            seed=987)
    #blinky_locs = grid_layout(room_dim[:2], n_blinkies, 0.7)
    #blinky_locs = random_layout([1.5,7.,1.], n_blinkies, offset=[0.5, 0.25, 0.8], seed=2)
    #blinky_locs = semi_circle_layout([4.1, 3.755, 0.75], 1.5 * 2 * np.pi / 3, 2., n_blinkies, rot=0.45 * np.pi)

    #blinky_locs = semi_circle_layout([4.1, 3.755, 1.1], np.pi, 3.5, n_blinkies, rot=0.743 * np.pi - np.pi / 4)