Basic Usage

Authenticate

The first step is to initialize the SDK client with the credentials that have been provided to you:

Note: If you are both a Search: Custom Database and Search: Pex Registry customer, each product will require a separate set of credentials.

# AUTHENTICATE CLIENT
client = pex.PrivateSearchClient("CLIENT_ID", "CLIENT_SECRET")

Note: There might be a slight delay the first time you authenticate as the SDK downloads and installs necessary updates

Managing Your Custom Database

Generate Fingerprint

First, generate a fingerprint from the media file you would like to add to your Custom database:

# CREATE AUDIO FINGERPRINT FROM MEDIA FILE
ft = client.fingerprint_file("/path/to/file.mp3", pex.FingerprintType.AUDIO)

# CREATE MELODY FINGERPRINT FROM MEDIA FILE
ft = client.fingerprint_file("/path/to/file.mp3", pex.FingerprintType.MELODY)

# CREATE AUDIO FINGERPRINT FROM BYTE BUFFER HOLDING A MEDIA FILE
ft = client.fingerprint_buffer([]byte, pex.FingerprintType.AUDIO)

# CREATE MELODY FINGERPRINT FROM BYTE BUFFER HOLDING A MEDIA FILE
ft = client.fingerprint_buffer([]byte, pex.FingerprintType.MELODY)

Note: Our SDK's computations are single-threaded. If you need to process larger volumes of files, running computations in parallel is recommended. This can significantly improve processing capacity.

For information on the difference between audio and melody fingerprints and the use cases they address, please see our FAQ page

Add Fingerprint to Custom Database

Now that the fingerprint has been generated, you can add that fingerprint file to your custom database. You can associate a "custom_id" string of your choosing for each fingerprint (to help you uniquely identify each fingerprint that is in your database):

# ADD FINGERPRINT CUSTOM DATABASE
client.ingest("custom_id", ft)

Note: After ingesting an asset, it will take a short time (generally a few minutes) before it is available in your custom database to be searched against

Searching Against Your Custom Database

Generate Fingerprint

Before performing any searches you need to generate a fingerprint from a media file:

# CREATE AUDIO FINGERPRINT FROM MEDIA FILE
ft = client.fingerprint_file("/path/to/file.mp3", pex.FingerprintType.AUDIO)

# CREATE MELODY FINGERPRINT FROM MEDIA FILE
ft = client.fingerprint_file("/path/to/file.mp3", pex.FingerprintType.MELODY)

# CREATE AUDIO FINGERPRINT FROM BYTE BUFFER HOLDING A MEDIA FILE
ft = client.fingerprint_buffer([]byte, pex.FingerprintType.AUDIO)

# CREATE MELODY FINGERPRINT FROM BYTE BUFFER HOLDING A MEDIA FILE
ft = client.fingerprint_buffer([]byte, pex.FingerprintType.MELODY)

Note: Our SDK's computations are single-threaded. If you need to process larger volumes of files, running computations in parallel is recommended. This can significantly improve processing capacity.

For information on the difference between audio and melody fingerprints and the use cases they address, please see our FAQ page

Once the fingerprint has been generated, you are ready to initiate a search:

# BUILD CUSTOM DATABASE SEARCH REQUEST
req = pex.PrivateSearchRequest(fingerprint=ft)

# START SEARCH
future = client.start_search(req)

Retrieve Search Results

Once a search is complete, you can retrieve the results of the search:

# RETRIEVE SEARCH RESULTS
result = future.get()

Interpret Search Results

To view details on what's contained in a search response, please see the following section: Search Response

Last updated