Esempio n. 1
0
def gen_audio(is_clean, params, index, audio_samples_length=-1):
    '''Calls build_audio() to get an audio signal, and verify that it meets the
       activity threshold'''

    clipped_files = []
    low_activity_files = []
    if audio_samples_length == -1:
        audio_samples_length = int(params['audio_length']*params['fs'])
    if is_clean:
        activity_threshold = params['clean_activity_threshold']
    else:
        activity_threshold = params['noise_activity_threshold']

    while True:
        audio, source_files, new_clipped_files, index = \
            build_audio(is_clean, params, index, audio_samples_length)

        clipped_files += new_clipped_files
        if len(audio) < audio_samples_length:
            continue

        if activity_threshold == 0.0:
            break

        percactive = activitydetector(audio=audio)
        if percactive > activity_threshold:
            break
        else:
            low_activity_files += source_files

    return audio, source_files, clipped_files, low_activity_files, index
def gen_audio3(is_clean, params, spk_index, audio_samples_length=-1):
    '''Calls build_audio() to get an Primary speaker audio signal [ensure one unique speaker, track
    spk ids], and verify that it meets the activity threshold'''

    #    clipped_files = []
    low_activity_files = []

    if audio_samples_length == -1:
        audio_samples_length = int(params['audio_length'] * params['fs'])

    if is_clean:
        activity_threshold = params['clean_activity_threshold']
    else:
        activity_threshold = params['noise_activity_threshold']

    #for spk_index in range(0,len(params['cleanfilenames'])):
    audios_all, files_used, clipped_files = build_audio3(
        is_clean, params, spk_index)

    chosen_audio = []

    for audio in audios_all:
        percactive = activitydetector(audio=audio)
        if activity_threshold == 0.0 or percactive > activity_threshold:
            chosen_audio.append(audio)

    return chosen_audio