def ENF_estimator(power_signal0):
    fs = 1000  # downsampling frequency
    nfft = 8192
    frame_size = 1  # change it to 6 for videos with large length recording
    overlap = 0
    power_signal_object = pyenf.pyENF(signal0=power_signal0,
                                      fs=fs,
                                      nominal=60,
                                      harmonic_multiples=1,
                                      duration=0.1,
                                      strip_index=0,
                                      frame_size_secs=frame_size,
                                      nfft=nfft,
                                      overlap_amount_secs=overlap)
    power_spectro_strip, power_frequency_support = power_signal_object.compute_spectrogam_strips(
    )
    power_weights = power_signal_object.compute_combining_weights_from_harmonics(
    )
    power_OurStripCell, power_initial_frequency = power_signal_object.compute_combined_spectrum(
        power_spectro_strip, power_weights, power_frequency_support)
    power_ENF = power_signal_object.compute_ENF_from_combined_strip(
        power_OurStripCell, power_initial_frequency)

    # add a dynamic plot of the ENF here

    return power_ENF
예제 #2
0
def give_me_ENF(fs,nfft,frame_size,overlap,harmonics_mul,signal_file,nominal):
    power_signal_object = pyenf.pyENF(signal0=signal_file, fs=fs, nominal=nominal, harmonic_multiples=harmonics_mul, duration=0.1,
                                  strip_index=0, frame_size_secs=frame_size, nfft=nfft, overlap_amount_secs=overlap)
    power_spectro_strip, power_frequency_support = power_signal_object.compute_spectrogam_strips()
    power_weights = power_signal_object.compute_combining_weights_from_harmonics()
    power_OurStripCell, power_initial_frequency = power_signal_object.compute_combined_spectrum(power_spectro_strip,
                                                                                            power_weights,
                                                                                            power_frequency_support)
    ENF = power_signal_object.compute_ENF_from_combined_strip(power_OurStripCell, power_initial_frequency)
    #print(power_weights)
    #print(power_initial_frequency)
    return ENF
filename = power1_filepath

signal0, fs = librosa.load(filename, sr=fs)  # loading the video ENF data
power_signal_filename = power2_filepath
power_signal0_orig, fs = librosa.load(power_signal_filename,
                                      sr=fs)  # loading the power ENF data

power_signal0 = power_signal0_orig[:len(signal0)]

# ENF extraction from video recording
video_signal_object = pyenf.pyENF(signal0=signal0,
                                  fs=fs,
                                  nominal=60,
                                  harmonic_multiples=1,
                                  duration=1,
                                  strip_index=0,
                                  frame_size_secs=frame_size,
                                  nfft=nfft,
                                  overlap_amount_secs=overlap,
                                  width_signal=0.02,
                                  width_band=1)
spectro_strip, frequency_support = video_signal_object.compute_spectrogam_strips(
)
weights = video_signal_object.compute_combining_weights_from_harmonics()
OurStripCell, initial_frequency = video_signal_object.compute_combined_spectrum(
    spectro_strip, weights, frequency_support)
ENF = video_signal_object.compute_ENF_from_combined_strip(
    OurStripCell, initial_frequency)

# uncomment when comparing only 2 graphs.
# creating figures for 2 plots