Пример #1
0
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
    for i in query_audios:
        audio_id = i.split("/")[7].split(".")[0]
        # loading a time series audio data from one of the query audio
        start = time.time()
Пример #2
0
import time
import csv

# source directory for query audios
src_dir = "../../../Test_Data/Query_Audios/Pitch_Shifted/"
# retrieving all query audios under specified source directory

# STFT based spectrogram object
stft = STFT(n_fft=1024, hop_length=32, sr=7000)
# peak extractor object
peak_extractor = PeakExtractor(maximum_filter_width=150,
                               maximum_filter_height=75)
# fingerprint generator object
fingerprint_generator = FingerprintGenerator(frames_per_second=219,
                                             target_zone_width=2,
                                             target_zone_center=4,
                                             number_of_triplets_per_second=50,
                                             tolerance=0.31)
# fingerprint manager object
data_manager = FingerprintManager(db_path="../../../Databases/Quads_Test_1.db")
result_path = "../../../New_Results/Quad/Pitch_Shifting/"
for j in range(70, 135, 5):
    query_audios = dir_manager.find_wav_files(src_dir=src_dir + str(j))
    count = 1
    for i in query_audios:
        audio_title = i.split("/")[7].split(".")[0]
        audio_data = audio_manager.load_audio(audio_path=i,
                                              sr=7000,
                                              offset=0.0,
                                              duration=30.0)
        spectrogram = stft.compute_spectrogram_magnitude_in_db(
Пример #3
0
    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,
                                            audio_fingerprints_info=audio_fingerprints_info)
Пример #4
0
stft = STFT(n_fft=1024, hop_length=32, sr=7000)
'''
    Instantiating peak extractor object. A peak extractor object will accept
    STFT based spectrogram of an audio and it will return spectral peaks based on
    predefined parameters. Here, a spectral peak is defined in terms of its frequency and
    tempo information's.
'''
peak_extractor = PeakExtractor(maximum_filter_width=150,
                               maximum_filter_height=75)
'''
    Instantiating a fingerprint generator object. A fingerprint generator function will accept
    spectral peaks extracted from STFT based spectrogram of an audio and it will return audio 
    fingerprints generated using the association of four spectral peaks.
'''
fingerprint_generator = FingerprintGenerator(target_zone_width=1,
                                             target_zone_center=2,
                                             tolerance=0.31)

for i in query_audios:
    audio_data = audio_manager.load_audio(audio_path=i,
                                          offset=0.0,
                                          duration=5.0)
    spectrogram = stft.compute_spectrogram_magnitude_in_db(
        audio_data=audio_data)
    spectral_peaks = peak_extractor.spectral_peaks(spectrogram=spectrogram)
    audio_fingerprints = fingerprint_generator.generate_fingerprints(
        spectral_peaks=spectral_peaks[0])
    # print(audio_fingerprints)
    match_in_bins = match_fingerprints.match_fingerprints(
        raw_data_index=raw_data_index,
        rtree_index=r_tree_index,