def normalize(input_file):
    temp_dir = tempfile.mkdtemp()

    transcoded_file = os.path.join(temp_dir, 'transcoded.flac')
    ffmpeg.transcode(input_file, transcoded_file)
    
    args_keep_silence = False
    args_silence_min_duration_sec = 0.1
    args_silence_threshold = 0.5
    
    if not args_keep_silence:
        trimmed_file = os.path.join(temp_dir, 'trimmed.flac')
        sox.remove_silence(
            transcoded_file,
            trimmed_file,
            min_duration_sec=args_silence_min_duration_sec,
            threshold=args_silence_threshold)
    else:
        trimmed_file = transcoded_file

    duration = sox.get_duration(trimmed_file)
    duration = int((duration // FRAGMENT_DURATION) * FRAGMENT_DURATION)

    normalized_file = os.path.join(temp_dir, 'normalized.flac')
    sox.normalize(trimmed_file, normalized_file, duration_in_sec=duration)
    return normalized_file, temp_dir
    def execute(self, context):
        input_files = context[self.input_files_key]
        output_files = context[self.output_files_key] = []

        for index, input_file in enumerate(input_files):
            output_file = common.append_suffix_to_filename(
                input_file, Normalizer.SUFFIX)
            output_files.append(output_file)

            volume = None

            sox.normalize(
                input_file,
                output_file,
                volume=volume,
                offset_in_sec=self.offset_in_sec,
                duration_in_sec=self.duration_in_sec)