Ejemplo n.º 1
0
    def __init__(self, working_dir, src, buggy, oracle, tests, golden, asserts, lines, build, configure, config):
        self.working_dir = working_dir
        self.config = config
        self.repair_test_suite = tests[:]
        self.validation_test_suite = tests[:]
        extracted = join(working_dir, 'extracted')
        os.mkdir(extracted)

        angelic_forest_file = join(working_dir, 'last-angelic-forest.json')

        tester = Tester(config, oracle, abspath(working_dir))
        self.run_test = tester
        self.get_suspicious_groups = Localizer(config, lines)
        self.reduce = Reducer(config)
        if self.config['use_semfix_syn']:
            self.synthesize_fix = Semfix_Synthesizer(working_dir,
                                                     config, extracted, angelic_forest_file)
            self.infer_spec = Semfix_Inferrer(working_dir, config, tester)
        else:
            self.synthesize_fix = Synthesizer(config, extracted, angelic_forest_file)
            self.infer_spec = Inferrer(config, tester, Load(working_dir))
        self.instrument_for_localization = RepairableTransformer(config)
        self.instrument_for_inference = SuspiciousTransformer(config, extracted)
        self.apply_patch = FixInjector(config)

        validation_dir = join(working_dir, "validation")
        shutil.copytree(src, validation_dir, symlinks=True)
        self.validation_src = Validation(config, validation_dir, buggy, build, configure)
        self.validation_src.configure()
        compilation_db = self.validation_src.export_compilation_db()
        self.validation_src.import_compilation_db(compilation_db)
        self.validation_src.initialize()

        frontend_dir = join(working_dir, "frontend")
        shutil.copytree(src, frontend_dir, symlinks=True)
        self.frontend_src = Frontend(config, frontend_dir, buggy, build, configure)
        self.frontend_src.import_compilation_db(compilation_db)
        self.frontend_src.initialize()

        backend_dir = join(working_dir, "backend")
        shutil.copytree(src, backend_dir, symlinks=True)
        self.backend_src = Backend(config, backend_dir, buggy, build, configure)
        self.backend_src.import_compilation_db(compilation_db)
        self.backend_src.initialize()

        if golden is not None:
            golden_dir = join(working_dir, "golden")
            shutil.copytree(golden, golden_dir, symlinks=True)
            self.golden_src = Frontend(config, golden_dir, buggy, build, configure)
            self.golden_src.import_compilation_db(compilation_db)
            self.golden_src.initialize()
        else:
            self.golden_src = None

        self.dump = Dump(working_dir, asserts)
        self.trace = Trace(working_dir)
Ejemplo n.º 2
0
def runSynthesisConfigured(topo, spec, expected):
    s = Specification.parseString(topo, spec)
    solver = Synthesizer(topo, s)
    result = solver.solve()
    for edge in expected:
        assert edge in result
Ejemplo n.º 3
0
 def __init__(self, working_dir, config, extracted, angelic_forest_file):
     Synthesizer.__init__(self, config, extracted, angelic_forest_file)
     self.working_dir = working_dir
Ejemplo n.º 4
0
 def __init__(self, working_dir, config, extracted, angelic_forest_file):
     Synthesizer.__init__(self, config, extracted, angelic_forest_file)
     self.working_dir = working_dir
Ejemplo n.º 5
0
    def generate_synthesized_mix(self, filename, separator, pitch_preproc, voicing):
        # Get file id from filename
        file_id = filename.split('/')[-1].replace('_vocal.wav', '')
        
        # Load audio with Spleeter's AudioAdapter
        audio_loader = AudioAdapter.default()
        waveform, _ = audio_loader.load(
            filename,
            sample_rate=self.sample_rate
        )

        # Run vocal separation on vocal audio
        prediction = separator.separate(waveform)
        audio = prediction['vocals']
        
        # To mono, energy filering and apply EqualLoudness for a better pitch extraction
        audio_mono = audio.sum(axis=1) / 2
        audio_mono_filt = self.filter_audio(audio=audio_mono, coef=0.00125)  # Energy filter to remove background noise
        audio_mono_eqloud = estd.EqualLoudness(sampleRate=self.sample_rate)(audio_mono_filt)
        
        # Extract pitch using PredominantMelodyMakam algorithm
        est_time, est_freq = self.extract_pitch_pmm(audio=audio_mono_eqloud)
        pitch = [[x, y] for x, y in zip(est_time, est_freq)]

        # Preprocessing analyzed audio and pitch
        preprocessor = PitchProcessor(
            pitch_preproc=pitch_preproc,
            voicing=voicing,
            gap_len=25,
        )
        audio, pitch_processed, time_stamps_processed = preprocessor.pre_processing(
            audio=audio_mono,
            extracted_pitch=pitch,
        )
        
        # Get freq limits to compute minf0
        tmp_est_freq = [x for x in est_freq if x > 20]
        if len(tmp_est_freq) > 0:
            minf0 = min(tmp_est_freq) - 20
        else:
            minf0 = 0
            
        # Synthesize vocal track
        synthesizer = Synthesizer(
            model='hpr',
            minf0=minf0,
            maxf0=max(pitch_processed) + 50,
        )
        synthesized_audio, pitch_track = synthesizer.synthesize(
            filtered_audio=audio,
            pitch_track=pitch_processed,
        )

        # Equalize voice
        #fx = (AudioEffectsChain().equalizer(200))
        #synthesized_audio = fx(synthesized_audio)

        # Get synthesized mix
        synthesized_audio_mix = self.mix(
            filename=filename,
            synthesized_voice=synthesized_audio
        )
        
        # Get vocal activations
        start_times, end_times = self.get_activations(time_stamps_processed, pitch_track)
        
        if len(start_times) > 2:
            # Write synthesized audio to file
            tmp_wav = 'audio/synth_mix_' + file_id + '.wav'
            self.save_audio_to_dataset(tmp_wav, synthesized_audio_mix)
    
            # Write csv melody annotation to file
            tmp_txt = 'annotations/melody/synth_mix_' + file_id + '.csv'
            self.save_pitch_track_to_dataset(tmp_txt, time_stamps_processed, pitch_track)
            
            # Write lab activations to file
            tmp_lab = 'annotations/activations/synth_mix_' + file_id + '.lab'
            self.save_activation_to_dataset(tmp_lab, start_times, end_times)
    
            return synthesized_audio_mix, pitch_track, time_stamps_processed
        else:
            print('UNVOICED TRACK! Skipping...')
            return [], [], []
Ejemplo n.º 6
0
 def __init__(self, working_dir, config, extracted, angelic_forest_file):
     #print ("__init__ in Semfix_Synthesizer is invoked with extra working dir " + working_dir)
     Synthesizer.__init__(self, config, extracted, angelic_forest_file)
     self.working_dir = working_dir