{
  "Comment": "Match Audio Asset Against Already Released Audio.",
  "StartAt": "${fingerprint_audio}",
  "States": {
    "${fingerprint_audio}": {
      "Type": "Task",
      "Next": "${match_audio}",
      "Resource": "${lambda_prefix}fingerprint",
      "Parameters": {
        "bucket.$": "$.bucket",
        "filename.$": "$.filename"
      },
      "ResultPath": "$.${fingerprint_audio}",
      "Retry": [
        {
          "ErrorEquals": [
            "States.ALL"
          ],
          "IntervalSeconds": 1,
          "BackoffRate": 2.04,
          "MaxAttempts": 15
        }
      ]
    },
    "${match_audio}": {
      "Type": "Task",
      "Resource": "${lambda_prefix}match",
      "Next": "${save_audio_matches}",
      "Parameters": {
        "audio_fingerprint.$": "$.${fingerprint_audio}.audio_fingerprint"
      },
      "ResultPath": "$.${match_audio}",
      "Retry": [
        {
          "ErrorEquals": [
            "States.ALL"
          ],
          "IntervalSeconds": 1,
          "BackoffRate": 2.04,
          "MaxAttempts": 15
        }
      ]
    },
    "${save_audio_matches}": {
      "Type": "Task",
      "Resource": "arn:aws:states:::dynamodb:putItem",
      "End": true,
      "Parameters": {
        "TableName": "${save_audio_matches_table_name}",
        "Item": {
          "asset_final_id": {
            "N.$": "States.Format('{}', $.asset_final_id)"
          },
          "matches": {
            "S.$": "States.JsonToString($.${match_audio})"
          }
        }
      },
      "ResultPath": "$.${save_audio_matches}",
      "Retry": [
        {
          "ErrorEquals": [
            "States.ALL"
          ],
          "IntervalSeconds": 1,
          "BackoffRate": 2.04,
          "MaxAttempts": 15
        }
      ]
    }
  }
}
