# IRCAM AI Detection API Test

The purpose of this code is to use the IRCAM AI Detection API on a test set of
data to gauge it's usefulness.

## Setup

Copy `.env.shadow` to `.env` and run `make run`

## Notes

The process to upload a local file is detailed [here](https://docs.ircamamplify.io/api#section/Quick-start)

The process to analyze a file with the aidetector is [here](https://docs.ircamamplify.io/api#tag/AI-Detector)

Note that the IRCAM Amplify creds are used to generate a new JWT authorization
token each time the script is run, but the token could be saved and reused for
up to an hour.

Files that are upload to IRCAM via the storage API are accessible via their IAS
ID. This ID is valid for 7 days, after which the files are expunged.

Uploading a file and running aidetection on it uses 1 API credit total.

## Custom runs

1. Add assets to check to the `assets/` directory.
1. Create a json file with an array of objects, one for each of the files to run like in the example below:

    ```jsonc
    [
        {
            "upc": "1",
            "unique_track_id": "1",
            "filepath": "assets/filename.flac",
            "ias_id": null,
            "file_id": null,
            "is_uploaded": false,
            "job_id": null,
            "result": null,
            "run_at": null
        }
        // add as many as necessary
    ]
    ```

1. Change the value of `DATA_FILEPATH` in `src/data.py` to reference the newly created json file.
1. Run the script via `make run`
