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.PexSearchClient(CLIENT_ID, CLIENT_SECRET)

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

    # Build an identify music search request
    req = pex.PexSearchRequest(fingerprint=ft, type=pex.PexSearchType.IDENTIFY_MUSIC)

    # Start the search
    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