from Utilities import dir_manager from Utilities import audio_manager from Core import STFT from Core import PeakExtractor from Core import FingerprintGenerator from FingerprintManager import FingerprintManager import time import csv # source directory for query audios src_dir = "../../../Test_Data/Modified_Audios_2/White_Noise/0/" # an object for computing stft based spectrogram stft = STFT(n_fft=1024, hop_length=32, sr=700) # an object to extract spectral peaks from stft based spectrogram peak_extractor = PeakExtractor(maximum_filter_width=150, maximum_filter_height=75) # an object to generate quad based audio fingerprints fingerprint_generator = FingerprintGenerator(frames_per_second=219, target_zone_width=1, target_zone_center=2, number_of_quads_per_second=9, tolerance=0.31) # FingerprintManager object fingerprint_manager = FingerprintManager( db_path="../../../Databases/Quads_Test.db") # results path result_path = "../../../Results_2/Quad/Granularity/" for t in range(5, 35, 5): query_audios = dir_manager.find_wav_files(src_dir=src_dir) dir_manager.create_dir(result_path) count = 901
You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>. """ from Utilities import DirManager from Utilities import AudioManager from Utilities import GraphManager from Core import Spectrogram from Core import PeakExtractor from Core import FingerprintGenerator # source directory src_dir = "../../../Test_Data/Reference_Audios" # spectrogram and peak extractor objects stft = Spectrogram(hop_length=32) peak_extractor = PeakExtractor() fingerprint_generator = FingerprintGenerator() # searching for all .mp3 file under specified source dir mp3_files = DirManager.find_mp3_files(src_dir=src_dir) # reading audio data re-sampled at 7KHz for # audio portion defined by offset and duration parameters audio_data = AudioManager.load_audio(audio_path=mp3_files[0], offset=10.0, duration=3.0) # computing spectrogram spectrogram = stft.compute_stft_magnitude_in_db(audio_data=audio_data) # extract spectral peaks spectral_peaks = peak_extractor.extract_spectral_peaks_1(spectrogram=spectrogram) # generate fingerprints audio_fingerprints = list() audio_fingerprints_info = list() fingerprint_generator.generate_fingerprints(spectral_peaks=spectral_peaks[0], audio_fingerprints=audio_fingerprints,