#using DataFrames, CSV, WAV
function avianz_of_scores(scores::String) #scores.csv
df = CSV.read(scores, DataFrame)
sort!(df, [:file, :start_time, :end_time])
gdf = groupby(df, :file)
for group in gdf
filename = first(group.file)
audio_data, sample_rate, _, _ = WAV.wavread(filename)
duration = Float64(length(audio_data) / sample_rate)
data = Any[Dict([("Operator", "D"), ("Reviewer", "D"), ("Duration", duration)])]
labels = Any[]
for row in eachrow(group)
if row.prediction != "nothing"
label = [
row.start_time,
row.end_time,
0,
8000,
[
Dict([
("filter", "M"),
("species", row.prediction),
("certainty", 100),
]),
],
]
push!(labels, label)
end
end
append!(data, labels)
avianzf = filename * ".data"
length(data) > 1 && avianz_file_of_dict(avianzf, data)
end
end