Strum recognition
Learn how to create requests to recognize strumming direction in audio.
1. Request via API
import requests
API_KEY = 'YOUR_KLANGIO_API_KEY'
audio_file = open('{YOUR_FILE_NAME}', 'rb')
query_parameters = {
'webhook_url': '{YOUR_WEBHOOK_ENDPOINT_URL}' # optional, but recommended
}
multipart_params = {
'file': audio_file
}
resp = requests.post(
'https://api.klang.io/strum-recognition',
headers={
'kl-api-key': API_KEY
},
params=query_parameters,
files=multipart_params
)
if resp.status_code = 200:
print(resp.json())
# {
# 'job_id': 'SOME_JOB_ID',
# 'creation_date': '2023-01-01',
# 'deletion_date': '2023-02-01',
# 'status_endpoint_url': 'https://api.klang.io/job/{SOME_JOB_ID}/status'
# }
2. Result format
The strum recognition detects the direction and timing of each strum of the audio file.
The job result is an array of the strumming directions with timings. It is stored as json with the key strums and has the format:
[<time_stamp_in_seconds>, <strum_direction>] with the type [float, string].
The <strum_direction> are the two values "U" for up- and "D" for down-strokes.
Example:
{
"strums": [
[
0.6461865848302841,
"D"
],
...
[
1.0264313435554504,
"U"
],
],
}