Sample Code

The following is some sample code that provides an example of performing a basic "identify music" audio search.
#!/usr/bin/env python3

import json
import pex

INPUT_FILE = "/path/to/file.mp3"

def main():
    # Initialize and authenticate the client
    client = pex.PrivateSearchClient(CLIENT_ID, CLIENT_SECRET)

    # Create an audio fingerprint from input file
    ft = client.fingerprint_file(INPUT_FILE, pex.FingerprintType.AUDIO)

    # Ingest FT into your custom database
    client.ingest("my_id_1", ft)

    # Build a search request
    req = pex.PrivateSearchRequest(fingerprint=ft)

    # Start the search against your custom database
    future = client.start_search(req)

    # Retrieve the result
    result = future.get()

    # Print the result
    print(json.dumps(result, indent=2))

if __name__ == '__main__':

Last updated