|
|
from datasets import load_dataset |
|
|
import numpy as np |
|
|
import json |
|
|
import matplotlib.pyplot as plt |
|
|
|
|
|
data = load_dataset("rikeshsilwalekg/imeaudio", revision = "v3-output-audio-features", split="train") |
|
|
|
|
|
duration_values = [example['audio_features']['duration'] for example in data] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bin_width = 0.5 |
|
|
min_duration = 25 |
|
|
max_duration = 30 |
|
|
bins = np.arange(min_duration, max_duration + bin_width, bin_width) |
|
|
|
|
|
|
|
|
filtered_durations = duration_values[(duration_values >= min_duration) & (duration_values <= max_duration)] |
|
|
|
|
|
|
|
|
counts, bin_edges = np.histogram(filtered_durations, bins=bins) |
|
|
|
|
|
|
|
|
hist_dict = {} |
|
|
for i in range(len(counts)): |
|
|
key = f"{bin_edges[i]}-{bin_edges[i+1]}" |
|
|
hist_dict[key] = int(counts[i]) |
|
|
|
|
|
|
|
|
|
|
|
json_filename = "audio_duration_histtogram_25_30_seconds.json" |
|
|
with open(json_filename, "w") as f: |
|
|
json.dump(hist_dict, f, indent=2) |
|
|
|
|
|
|
|
|
plt.hist(filtered_durations, bins=bins, color='purple', edgecolor='black') |
|
|
plt.title('Distribution of Audio Durations (25-30 seconds)') |
|
|
plt.xlabel('Duration in seconds') |
|
|
plt.ylabel('Count') |
|
|
plt.xlim(min_duration, max_duration) |
|
|
plt.savefig("/home/sidd/Desktop/work/IME DATASET REVIEW/audio_duration/AudioDurations0-5.jpg") |
|
|
plt.show() |
|
|
|
|
|
|
|
|
import numpy as np |
|
|
import json |
|
|
import matplotlib.pyplot as plt |
|
|
|
|
|
|
|
|
|
|
|
bin_width = 0.5 |
|
|
min_duration = 0 |
|
|
max_duration = 5 |
|
|
bins = np.arange(min_duration, max_duration + bin_width, bin_width) |
|
|
|
|
|
|
|
|
filtered_durations = duration_values[(duration_values >= min_duration) & (duration_values <= max_duration)] |
|
|
|
|
|
|
|
|
counts, bin_edges = np.histogram(filtered_durations, bins=bins) |
|
|
|
|
|
|
|
|
hist_dict = {} |
|
|
for i in range(len(counts)): |
|
|
key = f"{bin_edges[i]}-{bin_edges[i+1]}" |
|
|
hist_dict[key] = int(counts[i]) |
|
|
|
|
|
|
|
|
json_filename = "audio_duration_histtogram_0_51_seconds.json" |
|
|
with open(json_filename, "w") as f: |
|
|
json.dump(hist_dict, f, indent=2) |
|
|
|
|
|
|
|
|
plt.hist(filtered_durations, bins=bins, color='purple', edgecolor='black') |
|
|
plt.title('Distribution of Audio Durations (0-5 seconds)') |
|
|
plt.xlabel('Duration in seconds') |
|
|
plt.ylabel('Count') |
|
|
plt.xlim(min_duration, max_duration) |
|
|
plt.savefig("/home/sidd/Desktop/work/IME DATASET REVIEW/audio_duration/AudioDurations0-5.jpg") |
|
|
plt.show() |
|
|
|
|
|
|
|
|
import numpy as np |
|
|
import json |
|
|
import matplotlib.pyplot as plt |
|
|
|
|
|
|
|
|
|
|
|
bin_width = 0.5 |
|
|
min_duration = 5 |
|
|
max_duration = 10 |
|
|
bins = np.arange(min_duration, max_duration + bin_width, bin_width) |
|
|
|
|
|
|
|
|
duration_values = np.array(duration_values) |
|
|
|
|
|
|
|
|
filtered_durations = duration_values[(duration_values >= min_duration) & (duration_values <= max_duration)] |
|
|
|
|
|
|
|
|
counts, bin_edges = np.histogram(filtered_durations, bins=bins) |
|
|
|
|
|
|
|
|
hist_dict = {} |
|
|
for i in range(len(counts)): |
|
|
key = f"{bin_edges[i]}-{bin_edges[i+1]}" |
|
|
hist_dict[key] = int(counts[i]) |
|
|
|
|
|
|
|
|
json_filename = "audio_duration_histogram_5_10_seconds.json" |
|
|
with open(json_filename, "w") as f: |
|
|
json.dump(hist_dict, f, indent=2) |
|
|
|
|
|
|
|
|
plt.hist(filtered_durations, bins=bins, color='purple', edgecolor='black') |
|
|
plt.title('Distribution of Audio Durations (5-10 seconds)') |
|
|
plt.xlabel('Duration in seconds') |
|
|
plt.ylabel('Count') |
|
|
plt.xlim(min_duration, max_duration) |
|
|
plt.savefig("/home/sidd/Desktop/work/IME DATASET REVIEW/audio_duration/AudioDurations5-10.jpg") |
|
|
plt.show() |
|
|
|
|
|
|
|
|
import numpy as np |
|
|
import json |
|
|
import matplotlib.pyplot as plt |
|
|
|
|
|
|
|
|
|
|
|
bin_width = 0.5 |
|
|
min_duration = 10 |
|
|
max_duration = 15 |
|
|
bins = np.arange(min_duration, max_duration + bin_width, bin_width) |
|
|
|
|
|
|
|
|
duration_values = np.array(duration_values) |
|
|
|
|
|
|
|
|
filtered_durations = duration_values[(duration_values >= min_duration) & (duration_values <= max_duration)] |
|
|
|
|
|
|
|
|
counts, bin_edges = np.histogram(filtered_durations, bins=bins) |
|
|
|
|
|
|
|
|
hist_dict = {} |
|
|
for i in range(len(counts)): |
|
|
key = f"{bin_edges[i]}-{bin_edges[i+1]}" |
|
|
hist_dict[key] = int(counts[i]) |
|
|
|
|
|
|
|
|
json_filename = "audio_duration_histogram_10_15_seconds.json" |
|
|
with open(json_filename, "w") as f: |
|
|
json.dump(hist_dict, f, indent=2) |
|
|
|
|
|
|
|
|
plt.hist(filtered_durations, bins=bins, color='purple', edgecolor='black') |
|
|
plt.title('Distribution of Audio Durations (10-15seconds)') |
|
|
plt.xlabel('Duration in seconds') |
|
|
plt.ylabel('Count') |
|
|
plt.xlim(min_duration, max_duration) |
|
|
plt.savefig("/home/sidd/Desktop/work/IME DATASET REVIEW/audio_duration/AudioDurations10-15.jpg") |
|
|
plt.show() |
|
|
|
|
|
|
|
|
import numpy as np |
|
|
import json |
|
|
import matplotlib.pyplot as plt |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bin_width = 0.5 |
|
|
min_duration = 15 |
|
|
max_duration = 20 |
|
|
bins = np.arange(min_duration, max_duration + bin_width, bin_width) |
|
|
|
|
|
|
|
|
duration_values = np.array(duration_values) |
|
|
|
|
|
|
|
|
filtered_durations = duration_values[(duration_values >= min_duration) & (duration_values <= max_duration)] |
|
|
|
|
|
|
|
|
counts, bin_edges = np.histogram(filtered_durations, bins=bins) |
|
|
|
|
|
|
|
|
hist_dict = {} |
|
|
for i in range(len(counts)): |
|
|
key = f"{bin_edges[i]}-{bin_edges[i+1]}" |
|
|
hist_dict[key] = int(counts[i]) |
|
|
|
|
|
|
|
|
json_filename = "audio_duration_histogram_15_20_seconds.json" |
|
|
with open(json_filename, "w") as f: |
|
|
json.dump(hist_dict, f, indent=2) |
|
|
|
|
|
|
|
|
plt.hist(filtered_durations, bins=bins, color='purple', edgecolor='black') |
|
|
plt.title('Distribution of Audio Durations (15-20 seconds)') |
|
|
plt.xlabel('Duration in seconds') |
|
|
plt.ylabel('Count') |
|
|
plt.xlim(min_duration, max_duration) |
|
|
plt.savefig("/home/sidd/Desktop/work/IME DATASET REVIEW/audio_duration/AudioDurations15-20.jpg") |
|
|
plt.show() |
|
|
|
|
|
|
|
|
import numpy as np |
|
|
import json |
|
|
import matplotlib.pyplot as plt |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bin_width = 0.5 |
|
|
min_duration = 20 |
|
|
max_duration = 25 |
|
|
bins = np.arange(min_duration, max_duration + bin_width, bin_width) |
|
|
|
|
|
|
|
|
duration_values = np.array(duration_values) |
|
|
|
|
|
|
|
|
filtered_durations = duration_values[(duration_values >= min_duration) & (duration_values <= max_duration)] |
|
|
|
|
|
|
|
|
counts, bin_edges = np.histogram(filtered_durations, bins=bins) |
|
|
|
|
|
|
|
|
hist_dict = {} |
|
|
for i in range(len(counts)): |
|
|
key = f"{bin_edges[i]}-{bin_edges[i+1]}" |
|
|
hist_dict[key] = int(counts[i]) |
|
|
|
|
|
|
|
|
json_filename = "audio_duration_histogram_20_25_seconds.json" |
|
|
with open(json_filename, "w") as f: |
|
|
json.dump(hist_dict, f, indent=2) |
|
|
|
|
|
|
|
|
plt.hist(filtered_durations, bins=bins, color='purple', edgecolor='black') |
|
|
plt.title('Distribution of Audio Durations (20-25 seconds)') |
|
|
plt.xlabel('Duration in seconds') |
|
|
plt.ylabel('Count') |
|
|
plt.xlim(min_duration, max_duration) |
|
|
plt.savefig("/home/sidd/Desktop/work/IME DATASET REVIEW/audio_duration/AudioDurations20-25.jpg") |
|
|
plt.show() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bin_width = 0.5 |
|
|
min_duration = 25 |
|
|
max_duration = 30 |
|
|
bins = np.arange(min_duration, max_duration + bin_width, bin_width) |
|
|
|
|
|
|
|
|
duration_values = np.array(duration_values) |
|
|
|
|
|
|
|
|
filtered_durations = duration_values[(duration_values >= min_duration) & (duration_values <= max_duration)] |
|
|
|
|
|
|
|
|
counts, bin_edges = np.histogram(filtered_durations, bins=bins) |
|
|
|
|
|
|
|
|
hist_dict = {} |
|
|
for i in range(len(counts)): |
|
|
key = f"{bin_edges[i]}-{bin_edges[i+1]}" |
|
|
hist_dict[key] = int(counts[i]) |
|
|
|
|
|
|
|
|
json_filename = "audio_duration_histogram_25-30_seconds.json" |
|
|
with open(json_filename, "w") as f: |
|
|
json.dump(hist_dict, f, indent=2) |
|
|
|
|
|
|
|
|
plt.hist(filtered_durations, bins=bins, color='purple', edgecolor='black') |
|
|
plt.title('Distribution of Audio Durations (20-25 seconds)') |
|
|
plt.xlabel('Duration in seconds') |
|
|
plt.ylabel('Count') |
|
|
plt.xlim(min_duration, max_duration) |
|
|
|
|
|
plt.show() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
dynamic_range_lra = [example['audio_features']['dynamic_range_lra'] for example in data] |
|
|
|
|
|
|
|
|
bin_width = 0.5 |
|
|
min_duration = 0 |
|
|
max_duration = 5 |
|
|
|
|
|
|
|
|
duration_values = np.array(duration_values) |
|
|
dynamic_range_lra_values = np.array(dynamic_range_lra) |
|
|
|
|
|
|
|
|
filtered_dynamic_range_lra = dynamic_range_lra_values[ |
|
|
(duration_values >= min_duration) & (duration_values <= max_duration) |
|
|
] |
|
|
|
|
|
|
|
|
lra_bins = np.arange(0, 5 + bin_width, bin_width) |
|
|
|
|
|
|
|
|
counts, bin_edges = np.histogram(filtered_dynamic_range_lra, bins=lra_bins) |
|
|
|
|
|
|
|
|
hist_dict = {} |
|
|
for i in range(len(counts)): |
|
|
key = f"{bin_edges[i]}-{bin_edges[i+1]}" |
|
|
hist_dict[key] = int(counts[i]) |
|
|
|
|
|
|
|
|
json_filename = "dynamic_range_lra_histogram_0_5_seconds.json" |
|
|
with open(json_filename, "w") as f: |
|
|
json.dump(hist_dict, f, indent=2) |
|
|
|
|
|
|
|
|
plt.hist(filtered_dynamic_range_lra, bins=lra_bins, color='purple', edgecolor='black') |
|
|
plt.title('Distribution of Dynamic Range LRA (0-5 seconds duration)') |
|
|
plt.xlabel('Dynamic Range LRA') |
|
|
plt.ylabel('Count') |
|
|
plt.xlim(0, 5) |
|
|
plt.savefig("/home/sidd/Desktop/work/IME DATASET REVIEW/audio_duration//DynamicRangeLRA0-5.jpg") |
|
|
plt.show() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bin_width = 0.5 |
|
|
min_lra = 5 |
|
|
max_lra = 10 |
|
|
bins = np.arange(min_lra, max_lra + bin_width, bin_width) |
|
|
|
|
|
|
|
|
dynamic_range_lra_values = np.array(dynamic_range_lra) |
|
|
|
|
|
|
|
|
filtered_dynamic_range_lra = dynamic_range_lra_values[ |
|
|
(duration_values >= min_duration) & (duration_values <= max_duration)] |
|
|
|
|
|
|
|
|
counts, bin_edges = np.histogram(filtered_dynamic_range_lra, bins=bins) |
|
|
|
|
|
|
|
|
hist_dict = {} |
|
|
for i in range(len(counts)): |
|
|
key = f"{bin_edges[i]}-{bin_edges[i+1]}" |
|
|
hist_dict[key] = int(counts[i]) |
|
|
|
|
|
|
|
|
json_filename = "dynamic_range_lra_histogram_5_10.json" |
|
|
with open(json_filename, "w") as f: |
|
|
json.dump(hist_dict, f, indent=2) |
|
|
|
|
|
|
|
|
plt.hist(filtered_dynamic_range_lra, bins=bins, color='purple', edgecolor='black') |
|
|
plt.title('Distribution of Dynamic Range LRA (5-10)') |
|
|
plt.xlabel('Dynamic Range LRA') |
|
|
plt.ylabel('Count') |
|
|
plt.xlim(min_lra, max_lra) |
|
|
plt.savefig("/home/sidd/Desktop/work/IME DATASET REVIEW/audio_duration//DynamicRangeLRA5-10.jpg") |
|
|
plt.show() |
|
|
|
|
|
|
|
|
|
|
|
bin_width = 0.5 |
|
|
min_lra = 10 |
|
|
max_lra = 15 |
|
|
bins = np.arange(min_lra, max_lra + bin_width, bin_width) |
|
|
|
|
|
|
|
|
dynamic_range_lra_values = np.array(dynamic_range_lra) |
|
|
|
|
|
|
|
|
filtered_dynamic_range_lra = dynamic_range_lra_values[ |
|
|
(duration_values >= min_duration) & (duration_values <= max_duration)] |
|
|
|
|
|
|
|
|
counts, bin_edges = np.histogram(filtered_dynamic_range_lra, bins=bins) |
|
|
|
|
|
|
|
|
hist_dict = {} |
|
|
for i in range(len(counts)): |
|
|
key = f"{bin_edges[i]}-{bin_edges[i+1]}" |
|
|
hist_dict[key] = int(counts[i]) |
|
|
|
|
|
|
|
|
json_filename = "dynamic_range_lra_histogram_10_15.json" |
|
|
with open(json_filename, "w") as f: |
|
|
json.dump(hist_dict, f, indent=2) |
|
|
|
|
|
|
|
|
plt.hist(filtered_dynamic_range_lra, bins=bins, color='purple', edgecolor='black') |
|
|
plt.title('Distribution of Dynamic Range LRA (10-15)') |
|
|
plt.xlabel('Dynamic Range LRA') |
|
|
plt.ylabel('Count') |
|
|
plt.xlim(min_lra, max_lra) |
|
|
plt.savefig("/home/sidd/Desktop/work/IME DATASET REVIEW/audio_duration//DynamicRangeLRA10-15.jpg") |
|
|
plt.show() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bin_width = 0.5 |
|
|
min_lra = 15 |
|
|
max_lra = 20 |
|
|
bins = np.arange(min_lra, max_lra + bin_width, bin_width) |
|
|
|
|
|
|
|
|
dynamic_range_lra_values = np.array(dynamic_range_lra) |
|
|
|
|
|
|
|
|
filtered_dynamic_range_lra = dynamic_range_lra_values[ |
|
|
(duration_values >= min_duration) & (duration_values <= max_duration)] |
|
|
|
|
|
|
|
|
counts, bin_edges = np.histogram(filtered_dynamic_range_lra, bins=bins) |
|
|
|
|
|
|
|
|
hist_dict = {} |
|
|
for i in range(len(counts)): |
|
|
key = f"{bin_edges[i]}-{bin_edges[i+1]}" |
|
|
hist_dict[key] = int(counts[i]) |
|
|
|
|
|
|
|
|
json_filename = "dynamic_range_lra_histogram_15_20.json" |
|
|
with open(json_filename, "w") as f: |
|
|
json.dump(hist_dict, f, indent=2) |
|
|
|
|
|
|
|
|
plt.hist(filtered_dynamic_range_lra, bins=bins, color='purple', edgecolor='black') |
|
|
plt.title('Distribution of Dynamic Range LRA (15-20)') |
|
|
plt.xlabel('Dynamic Range LRA') |
|
|
plt.ylabel('Count') |
|
|
plt.xlim(min_lra, max_lra) |
|
|
plt.savefig("/home/sidd/Desktop/work/IME DATASET REVIEW/audio_duration//DynamicRangeLRA15-20.jpg") |
|
|
plt.show() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bin_width = 0.5 |
|
|
min_lra = 20 |
|
|
max_lra = 25 |
|
|
bins = np.arange(min_lra, max_lra + bin_width, bin_width) |
|
|
|
|
|
|
|
|
dynamic_range_lra_values = np.array(dynamic_range_lra) |
|
|
|
|
|
|
|
|
filtered_dynamic_range_lra = dynamic_range_lra_values[ |
|
|
(duration_values >= min_duration) & (duration_values <= max_duration)] |
|
|
|
|
|
|
|
|
counts, bin_edges = np.histogram(filtered_dynamic_range_lra, bins=bins) |
|
|
|
|
|
|
|
|
hist_dict = {} |
|
|
for i in range(len(counts)): |
|
|
key = f"{bin_edges[i]}-{bin_edges[i+1]}" |
|
|
hist_dict[key] = int(counts[i]) |
|
|
|
|
|
|
|
|
json_filename = "dynamic_range_lra_histogram_20_25.json" |
|
|
with open(json_filename, "w") as f: |
|
|
json.dump(hist_dict, f, indent=2) |
|
|
|
|
|
|
|
|
plt.hist(filtered_dynamic_range_lra, bins=bins, color='purple', edgecolor='black') |
|
|
plt.title('Distribution of Dynamic Range LRA (20-25)') |
|
|
plt.xlabel('Dynamic Range LRA') |
|
|
plt.ylabel('Count') |
|
|
plt.xlim(min_lra, max_lra) |
|
|
plt.savefig("/home/sidd/Desktop/work/IME DATASET REVIEW/audio_duration//DynamicRangeLRA20-25.jpg") |
|
|
plt.show() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bin_width = 0.5 |
|
|
min_lra = 25 |
|
|
max_lra = 30 |
|
|
bins = np.arange(min_lra, max_lra + bin_width, bin_width) |
|
|
|
|
|
|
|
|
dynamic_range_lra_values = np.array(dynamic_range_lra) |
|
|
|
|
|
|
|
|
filtered_dynamic_range_lra = dynamic_range_lra_values[ |
|
|
(duration_values >= min_duration) & (duration_values <= max_duration)] |
|
|
|
|
|
|
|
|
counts, bin_edges = np.histogram(filtered_dynamic_range_lra, bins=bins) |
|
|
|
|
|
|
|
|
hist_dict = {} |
|
|
for i in range(len(counts)): |
|
|
key = f"{bin_edges[i]}-{bin_edges[i+1]}" |
|
|
hist_dict[key] = int(counts[i]) |
|
|
|
|
|
|
|
|
json_filename = "dynamic_range_lra_histogram_25-30.json" |
|
|
with open(json_filename, "w") as f: |
|
|
json.dump(hist_dict, f, indent=2) |
|
|
|
|
|
|
|
|
plt.hist(filtered_dynamic_range_lra, bins=bins, color='purple', edgecolor='black') |
|
|
plt.title('Distribution of Dynamic Range LRA (25-30)') |
|
|
plt.xlabel('Dynamic Range LRA') |
|
|
plt.ylabel('Count') |
|
|
plt.xlim(min_lra, max_lra) |
|
|
plt.savefig("/home/sidd/Desktop/work/IME DATASET REVIEW/audio_duration//DynamicRangeLRA25-30.jpg") |
|
|
plt.show() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
loudness_lufs = [example['audio_features']['loudness_lufs'] for example in data] |
|
|
|
|
|
|
|
|
duration_array = np.array(duration_values) |
|
|
loudness_array = np.array(loudness_lufs) |
|
|
|
|
|
|
|
|
bin_width = 0.5 |
|
|
min_duration = 0 |
|
|
max_duration = 5 |
|
|
bins = np.arange(min_duration, max_duration + bin_width, bin_width) |
|
|
|
|
|
|
|
|
loudness_per_duration_bin = {} |
|
|
x_labels = [] |
|
|
y_values = [] |
|
|
|
|
|
|
|
|
for i in range(len(bins) - 1): |
|
|
start = bins[i] |
|
|
end = bins[i + 1] |
|
|
|
|
|
|
|
|
mask = (duration_array >= start) & (duration_array < end) |
|
|
loudness_in_bin = loudness_array[mask] |
|
|
|
|
|
|
|
|
loudness_in_bin = loudness_in_bin[~np.isnan(loudness_in_bin)] |
|
|
|
|
|
|
|
|
if len(loudness_in_bin) > 0: |
|
|
avg_loudness = float(np.mean(loudness_in_bin)) |
|
|
else: |
|
|
avg_loudness = None |
|
|
|
|
|
|
|
|
key = f"{start}-{end}" |
|
|
loudness_per_duration_bin[key] = avg_loudness |
|
|
x_labels.append(key) |
|
|
y_values.append(avg_loudness if avg_loudness is not None else 0) |
|
|
|
|
|
|
|
|
json_filename = "avg_loudness_lufs_per_duration_bin.json" |
|
|
with open(json_filename, "w") as f: |
|
|
json.dump(loudness_per_duration_bin, f, indent=2) |
|
|
|
|
|
|
|
|
plt.figure(figsize=(10, 6)) |
|
|
plt.bar(x_labels, y_values, color='teal', edgecolor='black') |
|
|
plt.xticks(rotation=45) |
|
|
plt.xlabel("Duration Bin (seconds)") |
|
|
plt.ylabel("Average Loudness (LUFS)") |
|
|
plt.title("Average Loudness per Duration Bin (0–5 sec)") |
|
|
plt.grid(axis='y') |
|
|
plt.tight_layout() |
|
|
plt.savefig("/home/sidd/Desktop/work/IME DATASET REVIEW/audio_duration/loudness0-5.jpg") |
|
|
plt.show() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
duration_array = np.array(duration_values) |
|
|
loudness_array = np.array(loudness_lufs) |
|
|
|
|
|
|
|
|
bin_width = 0.5 |
|
|
min_duration = 5 |
|
|
max_duration = 10 |
|
|
bins = np.arange(min_duration, max_duration + bin_width, bin_width) |
|
|
|
|
|
|
|
|
loudness_per_duration_bin = {} |
|
|
x_labels = [] |
|
|
y_values = [] |
|
|
|
|
|
|
|
|
for i in range(len(bins) - 1): |
|
|
start = bins[i] |
|
|
end = bins[i + 1] |
|
|
|
|
|
|
|
|
mask = (duration_array >= start) & (duration_array < end) |
|
|
loudness_in_bin = loudness_array[mask] |
|
|
|
|
|
|
|
|
loudness_in_bin = loudness_in_bin[~np.isnan(loudness_in_bin)] |
|
|
|
|
|
|
|
|
if len(loudness_in_bin) > 0: |
|
|
avg_loudness = float(np.mean(loudness_in_bin)) |
|
|
else: |
|
|
avg_loudness = None |
|
|
|
|
|
|
|
|
key = f"{start}-{end}" |
|
|
loudness_per_duration_bin[key] = avg_loudness |
|
|
x_labels.append(key) |
|
|
y_values.append(avg_loudness if avg_loudness is not None else 0) |
|
|
|
|
|
|
|
|
json_filename = "avg_loudness_lufs_per_duration5-10_bin.json" |
|
|
with open(json_filename, "w") as f: |
|
|
json.dump(loudness_per_duration_bin, f, indent=2) |
|
|
|
|
|
|
|
|
plt.figure(figsize=(10, 6)) |
|
|
plt.bar(x_labels, y_values, color='teal', edgecolor='black') |
|
|
plt.xticks(rotation=45) |
|
|
plt.xlabel("Duration Bin (seconds)") |
|
|
plt.ylabel("Average Loudness (LUFS)") |
|
|
plt.title("Average Loudness per Duration Bin (5-10 sec)") |
|
|
plt.grid(axis='y') |
|
|
plt.tight_layout() |
|
|
plt.savefig("/home/sidd/Desktop/work/IME DATASET REVIEW/audio_duration/loudness5-10.jpg") |
|
|
plt.show() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
duration_array = np.array(duration_values) |
|
|
loudness_array = np.array(loudness_lufs) |
|
|
|
|
|
|
|
|
bin_width = 0.5 |
|
|
min_duration = 10 |
|
|
max_duration = 15 |
|
|
bins = np.arange(min_duration, max_duration + bin_width, bin_width) |
|
|
|
|
|
|
|
|
loudness_per_duration_bin = {} |
|
|
x_labels = [] |
|
|
y_values = [] |
|
|
|
|
|
|
|
|
for i in range(len(bins) - 1): |
|
|
start = bins[i] |
|
|
end = bins[i + 1] |
|
|
|
|
|
|
|
|
mask = (duration_array >= start) & (duration_array < end) |
|
|
loudness_in_bin = loudness_array[mask] |
|
|
|
|
|
|
|
|
loudness_in_bin = loudness_in_bin[~np.isnan(loudness_in_bin)] |
|
|
|
|
|
|
|
|
if len(loudness_in_bin) > 0: |
|
|
avg_loudness = float(np.mean(loudness_in_bin)) |
|
|
else: |
|
|
avg_loudness = None |
|
|
|
|
|
|
|
|
key = f"{start}-{end}" |
|
|
loudness_per_duration_bin[key] = avg_loudness |
|
|
x_labels.append(key) |
|
|
y_values.append(avg_loudness if avg_loudness is not None else 0) |
|
|
|
|
|
|
|
|
json_filename = "avg_loudness_lufs_per_duration10-15_bin.json" |
|
|
with open(json_filename, "w") as f: |
|
|
json.dump(loudness_per_duration_bin, f, indent=2) |
|
|
|
|
|
|
|
|
plt.figure(figsize=(10, 6)) |
|
|
plt.bar(x_labels, y_values, color='teal', edgecolor='black') |
|
|
plt.xticks(rotation=45) |
|
|
plt.xlabel("Duration Bin (seconds)") |
|
|
plt.ylabel("Average Loudness (LUFS)") |
|
|
plt.title("Average Loudness per Duration Bin (10-15 sec)") |
|
|
plt.grid(axis='y') |
|
|
plt.tight_layout() |
|
|
plt.savefig("/home/sidd/Desktop/work/IME DATASET REVIEW/audio_duration/loudness10-15.jpg") |
|
|
plt.show() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
duration_array = np.array(duration_values) |
|
|
loudness_array = np.array(loudness_lufs) |
|
|
|
|
|
|
|
|
bin_width = 0.5 |
|
|
min_duration = 15 |
|
|
max_duration = 20 |
|
|
bins = np.arange(min_duration, max_duration + bin_width, bin_width) |
|
|
|
|
|
|
|
|
loudness_per_duration_bin = {} |
|
|
x_labels = [] |
|
|
y_values = [] |
|
|
|
|
|
|
|
|
for i in range(len(bins) - 1): |
|
|
start = bins[i] |
|
|
end = bins[i + 1] |
|
|
|
|
|
|
|
|
mask = (duration_array >= start) & (duration_array < end) |
|
|
loudness_in_bin = loudness_array[mask] |
|
|
|
|
|
|
|
|
loudness_in_bin = loudness_in_bin[~np.isnan(loudness_in_bin)] |
|
|
|
|
|
|
|
|
if len(loudness_in_bin) > 0: |
|
|
avg_loudness = float(np.mean(loudness_in_bin)) |
|
|
else: |
|
|
avg_loudness = None |
|
|
|
|
|
|
|
|
key = f"{start}-{end}" |
|
|
loudness_per_duration_bin[key] = avg_loudness |
|
|
x_labels.append(key) |
|
|
y_values.append(avg_loudness if avg_loudness is not None else 0) |
|
|
|
|
|
|
|
|
json_filename = "avg_loudness_lufs_per_duration15-20_bin.json" |
|
|
with open(json_filename, "w") as f: |
|
|
json.dump(loudness_per_duration_bin, f, indent=2) |
|
|
|
|
|
|
|
|
plt.figure(figsize=(10, 6)) |
|
|
plt.bar(x_labels, y_values, color='teal', edgecolor='black') |
|
|
plt.xticks(rotation=45) |
|
|
plt.xlabel("Duration Bin (seconds)") |
|
|
plt.ylabel("Average Loudness (LUFS)") |
|
|
plt.title("Average Loudness per Duration Bin (15-20sec)") |
|
|
plt.grid(axis='y') |
|
|
plt.tight_layout() |
|
|
plt.savefig("/home/sidd/Desktop/work/IME DATASET REVIEW/audio_duration/loudness15-20.jpg") |
|
|
plt.show() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
duration_array = np.array(duration_values) |
|
|
loudness_array = np.array(loudness_lufs) |
|
|
|
|
|
|
|
|
bin_width = 0.5 |
|
|
min_duration = 20 |
|
|
max_duration = 25 |
|
|
bins = np.arange(min_duration, max_duration + bin_width, bin_width) |
|
|
|
|
|
|
|
|
loudness_per_duration_bin = {} |
|
|
x_labels = [] |
|
|
y_values = [] |
|
|
|
|
|
|
|
|
for i in range(len(bins) - 1): |
|
|
start = bins[i] |
|
|
end = bins[i + 1] |
|
|
|
|
|
|
|
|
mask = (duration_array >= start) & (duration_array < end) |
|
|
loudness_in_bin = loudness_array[mask] |
|
|
|
|
|
|
|
|
loudness_in_bin = loudness_in_bin[~np.isnan(loudness_in_bin)] |
|
|
|
|
|
|
|
|
if len(loudness_in_bin) > 0: |
|
|
avg_loudness = float(np.mean(loudness_in_bin)) |
|
|
else: |
|
|
avg_loudness = None |
|
|
|
|
|
|
|
|
key = f"{start}-{end}" |
|
|
loudness_per_duration_bin[key] = avg_loudness |
|
|
x_labels.append(key) |
|
|
y_values.append(avg_loudness if avg_loudness is not None else 0) |
|
|
|
|
|
|
|
|
json_filename = "avg_loudness_lufs_per_duration20-25_bin.json" |
|
|
with open(json_filename, "w") as f: |
|
|
json.dump(loudness_per_duration_bin, f, indent=2) |
|
|
|
|
|
|
|
|
plt.figure(figsize=(10, 6)) |
|
|
plt.bar(x_labels, y_values, color='teal', edgecolor='black') |
|
|
plt.xticks(rotation=45) |
|
|
plt.xlabel("Duration Bin (seconds)") |
|
|
plt.ylabel("Average Loudness (LUFS)") |
|
|
plt.title("Average Loudness per Duration Bin (20-25sec)") |
|
|
plt.grid(axis='y') |
|
|
plt.tight_layout() |
|
|
plt.savefig("/home/sidd/Desktop/work/IME DATASET REVIEW/audio_duration/loudness20-25.jpg") |
|
|
plt.show() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
duration_array = np.array(duration_values) |
|
|
loudness_array = np.array(loudness_lufs) |
|
|
|
|
|
|
|
|
bin_width = 0.5 |
|
|
min_duration = 25 |
|
|
max_duration = 30 |
|
|
bins = np.arange(min_duration, max_duration + bin_width, bin_width) |
|
|
|
|
|
|
|
|
loudness_per_duration_bin = {} |
|
|
x_labels = [] |
|
|
y_values = [] |
|
|
|
|
|
|
|
|
for i in range(len(bins) - 1): |
|
|
start = bins[i] |
|
|
end = bins[i + 1] |
|
|
|
|
|
|
|
|
mask = (duration_array >= start) & (duration_array < end) |
|
|
loudness_in_bin = loudness_array[mask] |
|
|
|
|
|
|
|
|
loudness_in_bin = loudness_in_bin[~np.isnan(loudness_in_bin)] |
|
|
|
|
|
|
|
|
if len(loudness_in_bin) > 0: |
|
|
avg_loudness = float(np.mean(loudness_in_bin)) |
|
|
else: |
|
|
avg_loudness = None |
|
|
|
|
|
|
|
|
key = f"{start}-{end}" |
|
|
loudness_per_duration_bin[key] = avg_loudness |
|
|
x_labels.append(key) |
|
|
y_values.append(avg_loudness if avg_loudness is not None else 0) |
|
|
|
|
|
|
|
|
json_filename = "avg_loudness_lufs_per_duration25-30_bin.json" |
|
|
with open(json_filename, "w") as f: |
|
|
json.dump(loudness_per_duration_bin, f, indent=2) |
|
|
|
|
|
|
|
|
plt.figure(figsize=(10, 6)) |
|
|
plt.bar(x_labels, y_values, color='teal', edgecolor='black') |
|
|
plt.xticks(rotation=45) |
|
|
plt.xlabel("Duration Bin (seconds)") |
|
|
plt.ylabel("Average Loudness (LUFS)") |
|
|
plt.title("Average Loudness per Duration Bin (25-30sec)") |
|
|
plt.grid(axis='y') |
|
|
plt.tight_layout() |
|
|
plt.savefig("/home/sidd/Desktop/work/IME DATASET REVIEW/audio_duration/loudness25-30.jpg") |
|
|
plt.show() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mean_f0_hz = [example['audio_features']['mean_f0_hz'] for example in data] |
|
|
|
|
|
|
|
|
|
|
|
cleaned_f0 = [float(x) if isinstance(x, (int, float)) and x is not None else np.nan for x in mean_f0_hz] |
|
|
f0_array = np.array(cleaned_f0, dtype=np.float32) |
|
|
|
|
|
|
|
|
cleaned_durations = [float(x) if isinstance(x, (int, float)) and x is not None else np.nan for x in duration_values] |
|
|
duration_array = np.array(cleaned_durations, dtype=np.float32) |
|
|
|
|
|
|
|
|
bin_width = 0.5 |
|
|
min_duration = 0 |
|
|
max_duration = 5 |
|
|
bins = np.arange(min_duration, max_duration + bin_width, bin_width) |
|
|
|
|
|
|
|
|
f0_per_duration_bin = {} |
|
|
x_labels = [] |
|
|
y_values = [] |
|
|
|
|
|
|
|
|
for i in range(len(bins) - 1): |
|
|
start = bins[i] |
|
|
end = bins[i + 1] |
|
|
|
|
|
|
|
|
mask = (duration_array >= start) & (duration_array < end) & ~np.isnan(f0_array) |
|
|
f0_in_bin = f0_array[mask] |
|
|
|
|
|
avg_f0 = float(np.mean(f0_in_bin)) if len(f0_in_bin) > 0 else None |
|
|
|
|
|
key = f"{start}-{end}" |
|
|
f0_per_duration_bin[key] = avg_f0 |
|
|
x_labels.append(key) |
|
|
y_values.append(avg_f0 if avg_f0 is not None else 0) |
|
|
|
|
|
|
|
|
json_filename = "avg_mean_f0_hz_per_duration0-5_bin.json" |
|
|
with open(json_filename, "w") as f: |
|
|
json.dump(f0_per_duration_bin, f, indent=2) |
|
|
|
|
|
|
|
|
plt.figure(figsize=(10, 6)) |
|
|
plt.bar(x_labels, y_values, color='salmon', edgecolor='black') |
|
|
plt.xticks(rotation=45) |
|
|
plt.xlabel("Duration Bin (seconds)") |
|
|
plt.ylabel("Average Mean F0 (Hz)") |
|
|
plt.title("Average Mean F0 per Duration Bin (0–5 sec)") |
|
|
plt.grid(axis='y') |
|
|
plt.tight_layout() |
|
|
plt.savefig("/home/sidd/Desktop/work/IME DATASET REVIEW/audio_duration/AvgMeanF0:0-5.jpg") |
|
|
plt.show() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cleaned_f0 = [float(x) if isinstance(x, (int, float)) and x is not None else np.nan for x in mean_f0_hz] |
|
|
f0_array = np.array(cleaned_f0, dtype=np.float32) |
|
|
|
|
|
|
|
|
cleaned_durations = [float(x) if isinstance(x, (int, float)) and x is not None else np.nan for x in duration_values] |
|
|
duration_array = np.array(cleaned_durations, dtype=np.float32) |
|
|
|
|
|
|
|
|
bin_width = 0.5 |
|
|
min_duration = 5 |
|
|
max_duration = 10 |
|
|
bins = np.arange(min_duration, max_duration + bin_width, bin_width) |
|
|
|
|
|
|
|
|
f0_per_duration_bin = {} |
|
|
x_labels = [] |
|
|
y_values = [] |
|
|
|
|
|
|
|
|
for i in range(len(bins) - 1): |
|
|
start = bins[i] |
|
|
end = bins[i + 1] |
|
|
|
|
|
|
|
|
mask = (duration_array >= start) & (duration_array < end) & ~np.isnan(f0_array) |
|
|
f0_in_bin = f0_array[mask] |
|
|
|
|
|
avg_f0 = float(np.mean(f0_in_bin)) if len(f0_in_bin) > 0 else None |
|
|
|
|
|
key = f"{start}-{end}" |
|
|
f0_per_duration_bin[key] = avg_f0 |
|
|
x_labels.append(key) |
|
|
y_values.append(avg_f0 if avg_f0 is not None else 0) |
|
|
|
|
|
|
|
|
json_filename = "avg_mean_f0_hz_per_duration5-10_bin.json" |
|
|
with open(json_filename, "w") as f: |
|
|
json.dump(f0_per_duration_bin, f, indent=2) |
|
|
|
|
|
|
|
|
plt.figure(figsize=(10, 6)) |
|
|
plt.bar(x_labels, y_values, color='salmon', edgecolor='black') |
|
|
plt.xticks(rotation=45) |
|
|
plt.xlabel("Duration Bin (seconds)") |
|
|
plt.ylabel("Average Mean F0 (Hz)") |
|
|
plt.title("Average Mean F0 per Duration Bin (5-10 sec)") |
|
|
plt.grid(axis='y') |
|
|
plt.tight_layout() |
|
|
plt.savefig("/home/sidd/Desktop/work/IME DATASET REVIEW/audio_duration/AvgMeanF0:5-10.jpg") |
|
|
plt.show() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cleaned_f0 = [float(x) if isinstance(x, (int, float)) and x is not None else np.nan for x in mean_f0_hz] |
|
|
f0_array = np.array(cleaned_f0, dtype=np.float32) |
|
|
|
|
|
|
|
|
cleaned_durations = [float(x) if isinstance(x, (int, float)) and x is not None else np.nan for x in duration_values] |
|
|
duration_array = np.array(cleaned_durations, dtype=np.float32) |
|
|
|
|
|
|
|
|
bin_width = 0.5 |
|
|
min_duration = 10 |
|
|
max_duration = 15 |
|
|
bins = np.arange(min_duration, max_duration + bin_width, bin_width) |
|
|
|
|
|
|
|
|
f0_per_duration_bin = {} |
|
|
x_labels = [] |
|
|
y_values = [] |
|
|
|
|
|
|
|
|
for i in range(len(bins) - 1): |
|
|
start = bins[i] |
|
|
end = bins[i + 1] |
|
|
|
|
|
|
|
|
mask = (duration_array >= start) & (duration_array < end) & ~np.isnan(f0_array) |
|
|
f0_in_bin = f0_array[mask] |
|
|
|
|
|
avg_f0 = float(np.mean(f0_in_bin)) if len(f0_in_bin) > 0 else None |
|
|
|
|
|
key = f"{start}-{end}" |
|
|
f0_per_duration_bin[key] = avg_f0 |
|
|
x_labels.append(key) |
|
|
y_values.append(avg_f0 if avg_f0 is not None else 0) |
|
|
|
|
|
|
|
|
json_filename = "avg_mean_f0_hz_per_duration10-15_bin.json" |
|
|
with open(json_filename, "w") as f: |
|
|
json.dump(f0_per_duration_bin, f, indent=2) |
|
|
|
|
|
|
|
|
plt.figure(figsize=(10, 6)) |
|
|
plt.bar(x_labels, y_values, color='salmon', edgecolor='black') |
|
|
plt.xticks(rotation=45) |
|
|
plt.xlabel("Duration Bin (seconds)") |
|
|
plt.ylabel("Average Mean F0 (Hz)") |
|
|
plt.title("Average Mean F0 per Duration Bin (10-15 sec)") |
|
|
plt.grid(axis='y') |
|
|
plt.tight_layout() |
|
|
plt.savefig("/home/sidd/Desktop/work/IME DATASET REVIEW/audio_duration/AvgMeanF0:10-15.jpg") |
|
|
plt.show() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cleaned_f0 = [float(x) if isinstance(x, (int, float)) and x is not None else np.nan for x in mean_f0_hz] |
|
|
f0_array = np.array(cleaned_f0, dtype=np.float32) |
|
|
|
|
|
|
|
|
cleaned_durations = [float(x) if isinstance(x, (int, float)) and x is not None else np.nan for x in duration_values] |
|
|
duration_array = np.array(cleaned_durations, dtype=np.float32) |
|
|
|
|
|
|
|
|
bin_width = 0.5 |
|
|
min_duration = 15 |
|
|
max_duration = 20 |
|
|
bins = np.arange(min_duration, max_duration + bin_width, bin_width) |
|
|
|
|
|
|
|
|
f0_per_duration_bin = {} |
|
|
x_labels = [] |
|
|
y_values = [] |
|
|
|
|
|
|
|
|
for i in range(len(bins) - 1): |
|
|
start = bins[i] |
|
|
end = bins[i + 1] |
|
|
|
|
|
|
|
|
mask = (duration_array >= start) & (duration_array < end) & ~np.isnan(f0_array) |
|
|
f0_in_bin = f0_array[mask] |
|
|
|
|
|
avg_f0 = float(np.mean(f0_in_bin)) if len(f0_in_bin) > 0 else None |
|
|
|
|
|
key = f"{start}-{end}" |
|
|
f0_per_duration_bin[key] = avg_f0 |
|
|
x_labels.append(key) |
|
|
y_values.append(avg_f0 if avg_f0 is not None else 0) |
|
|
|
|
|
|
|
|
json_filename = "avg_mean_f0_hz_per_duration_bin15-20.json" |
|
|
with open(json_filename, "w") as f: |
|
|
json.dump(f0_per_duration_bin, f, indent=2) |
|
|
|
|
|
|
|
|
plt.figure(figsize=(10, 6)) |
|
|
plt.bar(x_labels, y_values, color='salmon', edgecolor='black') |
|
|
plt.xticks(rotation=45) |
|
|
plt.xlabel("Duration Bin (seconds)") |
|
|
plt.ylabel("Average Mean F0 (Hz)") |
|
|
plt.title("Average Mean F0 per Duration Bin (15-20 sec)") |
|
|
plt.grid(axis='y') |
|
|
plt.tight_layout() |
|
|
plt.savefig("/home/sidd/Desktop/work/IME DATASET REVIEW/audio_duration/AvgMeanF0:15-20.jpg") |
|
|
plt.show() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cleaned_f0 = [float(x) if isinstance(x, (int, float)) and x is not None else np.nan for x in mean_f0_hz] |
|
|
f0_array = np.array(cleaned_f0, dtype=np.float32) |
|
|
|
|
|
|
|
|
cleaned_durations = [float(x) if isinstance(x, (int, float)) and x is not None else np.nan for x in duration_values] |
|
|
duration_array = np.array(cleaned_durations, dtype=np.float32) |
|
|
|
|
|
|
|
|
bin_width = 0.5 |
|
|
min_duration = 20 |
|
|
max_duration = 25 |
|
|
bins = np.arange(min_duration, max_duration + bin_width, bin_width) |
|
|
|
|
|
|
|
|
f0_per_duration_bin = {} |
|
|
x_labels = [] |
|
|
y_values = [] |
|
|
|
|
|
|
|
|
for i in range(len(bins) - 1): |
|
|
start = bins[i] |
|
|
end = bins[i + 1] |
|
|
|
|
|
|
|
|
mask = (duration_array >= start) & (duration_array < end) & ~np.isnan(f0_array) |
|
|
f0_in_bin = f0_array[mask] |
|
|
|
|
|
avg_f0 = float(np.mean(f0_in_bin)) if len(f0_in_bin) > 0 else None |
|
|
|
|
|
key = f"{start}-{end}" |
|
|
f0_per_duration_bin[key] = avg_f0 |
|
|
x_labels.append(key) |
|
|
y_values.append(avg_f0 if avg_f0 is not None else 0) |
|
|
|
|
|
|
|
|
json_filename = "avg_mean_f0_hz_per_duration20-25_bin.json" |
|
|
with open(json_filename, "w") as f: |
|
|
json.dump(f0_per_duration_bin, f, indent=2) |
|
|
|
|
|
|
|
|
plt.figure(figsize=(10, 6)) |
|
|
plt.bar(x_labels, y_values, color='salmon', edgecolor='black') |
|
|
plt.xticks(rotation=45) |
|
|
plt.xlabel("Duration Bin (seconds)") |
|
|
plt.ylabel("Average Mean F0 (Hz)") |
|
|
plt.title("Average Mean F0 per Duration Bin (20-25 sec)") |
|
|
plt.grid(axis='y') |
|
|
plt.tight_layout() |
|
|
plt.savefig("/home/sidd/Desktop/work/IME DATASET REVIEW/audio_duration/AvgMeanF0:20-25.jpg") |
|
|
plt.show() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cleaned_f0 = [float(x) if isinstance(x, (int, float)) and x is not None else np.nan for x in mean_f0_hz] |
|
|
f0_array = np.array(cleaned_f0, dtype=np.float32) |
|
|
|
|
|
|
|
|
cleaned_durations = [float(x) if isinstance(x, (int, float)) and x is not None else np.nan for x in duration_values] |
|
|
duration_array = np.array(cleaned_durations, dtype=np.float32) |
|
|
|
|
|
|
|
|
bin_width = 0.5 |
|
|
min_duration = 25 |
|
|
max_duration = 30 |
|
|
bins = np.arange(min_duration, max_duration + bin_width, bin_width) |
|
|
|
|
|
|
|
|
f0_per_duration_bin = {} |
|
|
x_labels = [] |
|
|
y_values = [] |
|
|
|
|
|
|
|
|
for i in range(len(bins) - 1): |
|
|
start = bins[i] |
|
|
end = bins[i + 1] |
|
|
|
|
|
|
|
|
mask = (duration_array >= start) & (duration_array < end) & ~np.isnan(f0_array) |
|
|
f0_in_bin = f0_array[mask] |
|
|
|
|
|
avg_f0 = float(np.mean(f0_in_bin)) if len(f0_in_bin) > 0 else None |
|
|
|
|
|
key = f"{start}-{end}" |
|
|
f0_per_duration_bin[key] = avg_f0 |
|
|
x_labels.append(key) |
|
|
y_values.append(avg_f0 if avg_f0 is not None else 0) |
|
|
|
|
|
|
|
|
json_filename = "avg_mean_f0_hz_per_duration25-30_bin.json" |
|
|
with open(json_filename, "w") as f: |
|
|
json.dump(f0_per_duration_bin, f, indent=2) |
|
|
|
|
|
|
|
|
plt.figure(figsize=(10, 6)) |
|
|
plt.bar(x_labels, y_values, color='salmon', edgecolor='black') |
|
|
plt.xticks(rotation=45) |
|
|
plt.xlabel("Duration Bin (seconds)") |
|
|
plt.ylabel("Average Mean F0 (Hz)") |
|
|
plt.title("Average Mean F0 per Duration Bin (25-30 sec)") |
|
|
plt.grid(axis='y') |
|
|
plt.tight_layout() |
|
|
plt.savefig("/home/sidd/Desktop/work/IME DATASET REVIEW/audio_duration/AvgMeanF0:25-30.jpg") |
|
|
plt.show() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mean_spectral_centroid_hz = [example['audio_features']['mean_spectral_centroid_hz'] for example in data] |
|
|
|
|
|
|
|
|
cleaned_centroid = [ |
|
|
float(x) if isinstance(x, (int, float)) and x is not None else np.nan |
|
|
for x in mean_spectral_centroid_hz |
|
|
] |
|
|
centroid_array = np.array(cleaned_centroid, dtype=np.float32) |
|
|
|
|
|
|
|
|
cleaned_durations = [ |
|
|
float(x) if isinstance(x, (int, float)) and x is not None else np.nan |
|
|
for x in duration_values |
|
|
] |
|
|
duration_array = np.array(cleaned_durations, dtype=np.float32) |
|
|
|
|
|
|
|
|
bin_width = 0.5 |
|
|
min_duration = 0 |
|
|
max_duration = 5 |
|
|
bins = np.arange(min_duration, max_duration + bin_width, bin_width) |
|
|
|
|
|
|
|
|
centroid_per_bin = {} |
|
|
x_labels = [] |
|
|
y_values = [] |
|
|
|
|
|
for i in range(len(bins) - 1): |
|
|
start = bins[i] |
|
|
end = bins[i + 1] |
|
|
|
|
|
|
|
|
mask = (duration_array >= start) & (duration_array < end) & ~np.isnan(centroid_array) |
|
|
values_in_bin = centroid_array[mask] |
|
|
|
|
|
avg_centroid = float(np.mean(values_in_bin)) if len(values_in_bin) > 0 else None |
|
|
|
|
|
key = f"{start}-{end}" |
|
|
centroid_per_bin[key] = avg_centroid |
|
|
x_labels.append(key) |
|
|
y_values.append(avg_centroid if avg_centroid is not None else 0) |
|
|
|
|
|
|
|
|
json_filename = "avg_mean_spectral_centroid_hz_per_duration0-5_bin.json" |
|
|
with open(json_filename, "w") as f: |
|
|
json.dump(centroid_per_bin, f, indent=2) |
|
|
|
|
|
|
|
|
plt.figure(figsize=(10, 6)) |
|
|
plt.bar(x_labels, y_values, color='royalblue', edgecolor='black') |
|
|
plt.xticks(rotation=45) |
|
|
plt.xlabel("Duration Bin (seconds)") |
|
|
plt.ylabel("Average Spectral Centroid (Hz)") |
|
|
plt.title("Average Spectral Centroid per Duration Bin (0–5 sec)") |
|
|
plt.grid(axis='y') |
|
|
plt.tight_layout() |
|
|
plt.savefig("/home/sidd/Desktop/work/IME DATASET REVIEW/audio_duration/AverageSpectral0-5.jpg") |
|
|
plt.show() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cleaned_centroid = [ |
|
|
float(x) if isinstance(x, (int, float)) and x is not None else np.nan |
|
|
for x in mean_spectral_centroid_hz |
|
|
] |
|
|
centroid_array = np.array(cleaned_centroid, dtype=np.float32) |
|
|
|
|
|
|
|
|
cleaned_durations = [ |
|
|
float(x) if isinstance(x, (int, float)) and x is not None else np.nan |
|
|
for x in duration_values |
|
|
] |
|
|
duration_array = np.array(cleaned_durations, dtype=np.float32) |
|
|
|
|
|
|
|
|
bin_width = 0.5 |
|
|
min_duration = 5 |
|
|
max_duration = 10 |
|
|
bins = np.arange(min_duration, max_duration + bin_width, bin_width) |
|
|
|
|
|
|
|
|
centroid_per_bin = {} |
|
|
x_labels = [] |
|
|
y_values = [] |
|
|
|
|
|
for i in range(len(bins) - 1): |
|
|
start = bins[i] |
|
|
end = bins[i + 1] |
|
|
|
|
|
|
|
|
mask = (duration_array >= start) & (duration_array < end) & ~np.isnan(centroid_array) |
|
|
values_in_bin = centroid_array[mask] |
|
|
|
|
|
avg_centroid = float(np.mean(values_in_bin)) if len(values_in_bin) > 0 else None |
|
|
|
|
|
key = f"{start}-{end}" |
|
|
centroid_per_bin[key] = avg_centroid |
|
|
x_labels.append(key) |
|
|
y_values.append(avg_centroid if avg_centroid is not None else 0) |
|
|
|
|
|
|
|
|
json_filename = "avg_mean_spectral_centroid_hz_per_duration5-10_bin.json" |
|
|
with open(json_filename, "w") as f: |
|
|
json.dump(centroid_per_bin, f, indent=2) |
|
|
|
|
|
|
|
|
plt.figure(figsize=(10, 6)) |
|
|
plt.bar(x_labels, y_values, color='royalblue', edgecolor='black') |
|
|
plt.xticks(rotation=45) |
|
|
plt.xlabel("Duration Bin (seconds)") |
|
|
plt.ylabel("Average Spectral Centroid (Hz)") |
|
|
plt.title("Average Spectral Centroid per Duration Bin (5-10 sec)") |
|
|
plt.grid(axis='y') |
|
|
plt.tight_layout() |
|
|
plt.savefig("/home/sidd/Desktop/work/IME DATASET REVIEW/audio_duration/AverageSpectral5-10.jpg") |
|
|
plt.show() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cleaned_centroid = [ |
|
|
float(x) if isinstance(x, (int, float)) and x is not None else np.nan |
|
|
for x in mean_spectral_centroid_hz |
|
|
] |
|
|
centroid_array = np.array(cleaned_centroid, dtype=np.float32) |
|
|
|
|
|
|
|
|
cleaned_durations = [ |
|
|
float(x) if isinstance(x, (int, float)) and x is not None else np.nan |
|
|
for x in duration_values |
|
|
] |
|
|
duration_array = np.array(cleaned_durations, dtype=np.float32) |
|
|
|
|
|
|
|
|
bin_width = 0.5 |
|
|
min_duration = 10 |
|
|
max_duration = 15 |
|
|
bins = np.arange(min_duration, max_duration + bin_width, bin_width) |
|
|
|
|
|
|
|
|
centroid_per_bin = {} |
|
|
x_labels = [] |
|
|
y_values = [] |
|
|
|
|
|
for i in range(len(bins) - 1): |
|
|
start = bins[i] |
|
|
end = bins[i + 1] |
|
|
|
|
|
|
|
|
mask = (duration_array >= start) & (duration_array < end) & ~np.isnan(centroid_array) |
|
|
values_in_bin = centroid_array[mask] |
|
|
|
|
|
avg_centroid = float(np.mean(values_in_bin)) if len(values_in_bin) > 0 else None |
|
|
|
|
|
key = f"{start}-{end}" |
|
|
centroid_per_bin[key] = avg_centroid |
|
|
x_labels.append(key) |
|
|
y_values.append(avg_centroid if avg_centroid is not None else 0) |
|
|
|
|
|
|
|
|
json_filename = "avg_mean_spectral_centroid_hz_per_duration10-15_bin.json" |
|
|
with open(json_filename, "w") as f: |
|
|
json.dump(centroid_per_bin, f, indent=2) |
|
|
|
|
|
|
|
|
plt.figure(figsize=(10, 6)) |
|
|
plt.bar(x_labels, y_values, color='royalblue', edgecolor='black') |
|
|
plt.xticks(rotation=45) |
|
|
plt.xlabel("Duration Bin (seconds)") |
|
|
plt.ylabel("Average Spectral Centroid (Hz)") |
|
|
plt.title("Average Spectral Centroid per Duration Bin (10-15) sec)") |
|
|
plt.grid(axis='y') |
|
|
plt.tight_layout() |
|
|
plt.savefig("/home/sidd/Desktop/work/IME DATASET REVIEW/audio_duration/AverageSpectral10-15.jpg") |
|
|
plt.show() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cleaned_centroid = [ |
|
|
float(x) if isinstance(x, (int, float)) and x is not None else np.nan |
|
|
for x in mean_spectral_centroid_hz |
|
|
] |
|
|
centroid_array = np.array(cleaned_centroid, dtype=np.float32) |
|
|
|
|
|
|
|
|
cleaned_durations = [ |
|
|
float(x) if isinstance(x, (int, float)) and x is not None else np.nan |
|
|
for x in duration_values |
|
|
] |
|
|
duration_array = np.array(cleaned_durations, dtype=np.float32) |
|
|
|
|
|
|
|
|
bin_width = 0.5 |
|
|
min_duration = 15 |
|
|
max_duration = 20 |
|
|
bins = np.arange(min_duration, max_duration + bin_width, bin_width) |
|
|
|
|
|
|
|
|
centroid_per_bin = {} |
|
|
x_labels = [] |
|
|
y_values = [] |
|
|
|
|
|
for i in range(len(bins) - 1): |
|
|
start = bins[i] |
|
|
end = bins[i + 1] |
|
|
|
|
|
|
|
|
mask = (duration_array >= start) & (duration_array < end) & ~np.isnan(centroid_array) |
|
|
values_in_bin = centroid_array[mask] |
|
|
|
|
|
avg_centroid = float(np.mean(values_in_bin)) if len(values_in_bin) > 0 else None |
|
|
|
|
|
key = f"{start}-{end}" |
|
|
centroid_per_bin[key] = avg_centroid |
|
|
x_labels.append(key) |
|
|
y_values.append(avg_centroid if avg_centroid is not None else 0) |
|
|
|
|
|
|
|
|
json_filename = "avg_mean_spectral_centroid_hz_per_duration15-20_bin.json" |
|
|
with open(json_filename, "w") as f: |
|
|
json.dump(centroid_per_bin, f, indent=2) |
|
|
|
|
|
|
|
|
plt.figure(figsize=(10, 6)) |
|
|
plt.bar(x_labels, y_values, color='royalblue', edgecolor='black') |
|
|
plt.xticks(rotation=45) |
|
|
plt.xlabel("Duration Bin (seconds)") |
|
|
plt.ylabel("Average Spectral Centroid (Hz)") |
|
|
plt.title("Average Spectral Centroid per Duration Bin (15-20) sec)") |
|
|
plt.grid(axis='y') |
|
|
plt.tight_layout() |
|
|
plt.savefig("/home/sidd/Desktop/work/IME DATASET REVIEW/audio_duration/AverageSpectral15-20.jpg") |
|
|
plt.show() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cleaned_centroid = [ |
|
|
float(x) if isinstance(x, (int, float)) and x is not None else np.nan |
|
|
for x in mean_spectral_centroid_hz |
|
|
] |
|
|
centroid_array = np.array(cleaned_centroid, dtype=np.float32) |
|
|
|
|
|
|
|
|
cleaned_durations = [ |
|
|
float(x) if isinstance(x, (int, float)) and x is not None else np.nan |
|
|
for x in duration_values |
|
|
] |
|
|
duration_array = np.array(cleaned_durations, dtype=np.float32) |
|
|
|
|
|
|
|
|
bin_width = 0.5 |
|
|
min_duration = 20 |
|
|
max_duration = 25 |
|
|
bins = np.arange(min_duration, max_duration + bin_width, bin_width) |
|
|
|
|
|
|
|
|
centroid_per_bin = {} |
|
|
x_labels = [] |
|
|
y_values = [] |
|
|
|
|
|
for i in range(len(bins) - 1): |
|
|
start = bins[i] |
|
|
end = bins[i + 1] |
|
|
|
|
|
|
|
|
mask = (duration_array >= start) & (duration_array < end) & ~np.isnan(centroid_array) |
|
|
values_in_bin = centroid_array[mask] |
|
|
|
|
|
avg_centroid = float(np.mean(values_in_bin)) if len(values_in_bin) > 0 else None |
|
|
|
|
|
key = f"{start}-{end}" |
|
|
centroid_per_bin[key] = avg_centroid |
|
|
x_labels.append(key) |
|
|
y_values.append(avg_centroid if avg_centroid is not None else 0) |
|
|
|
|
|
|
|
|
json_filename = "avg_mean_spectral_centroid_hz_per_duration20-25_bin.json" |
|
|
with open(json_filename, "w") as f: |
|
|
json.dump(centroid_per_bin, f, indent=2) |
|
|
|
|
|
|
|
|
plt.figure(figsize=(10, 6)) |
|
|
plt.bar(x_labels, y_values, color='royalblue', edgecolor='black') |
|
|
plt.xticks(rotation=45) |
|
|
plt.xlabel("Duration Bin (seconds)") |
|
|
plt.ylabel("Average Spectral Centroid (Hz)") |
|
|
plt.title("Average Spectral Centroid per Duration Bin (20-25) sec)") |
|
|
plt.grid(axis='y') |
|
|
plt.tight_layout() |
|
|
plt.savefig("/home/sidd/Desktop/work/IME DATASET REVIEW/audio_duration/AverageSpectral20-25.jpg") |
|
|
plt.show() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cleaned_centroid = [ |
|
|
float(x) if isinstance(x, (int, float)) and x is not None else np.nan |
|
|
for x in mean_spectral_centroid_hz |
|
|
] |
|
|
centroid_array = np.array(cleaned_centroid, dtype=np.float32) |
|
|
|
|
|
|
|
|
cleaned_durations = [ |
|
|
float(x) if isinstance(x, (int, float)) and x is not None else np.nan |
|
|
for x in duration_values |
|
|
] |
|
|
duration_array = np.array(cleaned_durations, dtype=np.float32) |
|
|
|
|
|
|
|
|
bin_width = 0.5 |
|
|
min_duration = 25 |
|
|
max_duration = 30 |
|
|
bins = np.arange(min_duration, max_duration + bin_width, bin_width) |
|
|
|
|
|
|
|
|
centroid_per_bin = {} |
|
|
x_labels = [] |
|
|
y_values = [] |
|
|
|
|
|
for i in range(len(bins) - 1): |
|
|
start = bins[i] |
|
|
end = bins[i + 1] |
|
|
|
|
|
|
|
|
mask = (duration_array >= start) & (duration_array < end) & ~np.isnan(centroid_array) |
|
|
values_in_bin = centroid_array[mask] |
|
|
|
|
|
avg_centroid = float(np.mean(values_in_bin)) if len(values_in_bin) > 0 else None |
|
|
|
|
|
key = f"{start}-{end}" |
|
|
centroid_per_bin[key] = avg_centroid |
|
|
x_labels.append(key) |
|
|
y_values.append(avg_centroid if avg_centroid is not None else 0) |
|
|
|
|
|
|
|
|
json_filename = "avg_mean_spectral_centroid_hz_per_duration25-30_bin.json" |
|
|
with open(json_filename, "w") as f: |
|
|
json.dump(centroid_per_bin, f, indent=2) |
|
|
|
|
|
|
|
|
plt.figure(figsize=(10, 6)) |
|
|
plt.bar(x_labels, y_values, color='royalblue', edgecolor='black') |
|
|
plt.xticks(rotation=45) |
|
|
plt.xlabel("Duration Bin (seconds)") |
|
|
plt.ylabel("Average Spectral Centroid (Hz)") |
|
|
plt.title("Average Spectral Centroid per Duration Bin (20-25) sec)") |
|
|
plt.grid(axis='y') |
|
|
plt.tight_layout() |
|
|
plt.savefig("/home/sidd/Desktop/work/IME DATASET REVIEW/audio_duration/AverageSpectral25-30jpg") |
|
|
plt.show() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
snr_estimate_db= [example['audio_features']['snr_estimate_db'] for example in data] |
|
|
|
|
|
|
|
|
min_duration = 0 |
|
|
max_duration = 5 |
|
|
bin_width = 0.5 |
|
|
bins = np.arange(min_duration, max_duration + bin_width, bin_width) |
|
|
|
|
|
cleaned_snr = [float(x) if isinstance(x, (int, float)) and x is not None else np.nan for x in snr_estimate_db] |
|
|
snr_array = np.array(cleaned_snr, dtype=np.float32) |
|
|
|
|
|
cleaned_durations = [float(x) if isinstance(x, (int, float)) and x is not None else np.nan for x in duration_values] |
|
|
duration_array = np.array(cleaned_durations, dtype=np.float32) |
|
|
|
|
|
snr_per_bin = {} |
|
|
x_labels = [] |
|
|
y_values = [] |
|
|
|
|
|
for i in range(len(bins) - 1): |
|
|
mask = (duration_array >= bins[i]) & (duration_array < bins[i+1]) & ~np.isnan(snr_array) |
|
|
values = snr_array[mask] |
|
|
avg = float(np.mean(values)) if len(values) > 0 else None |
|
|
key = f"{bins[i]}-{bins[i+1]}" |
|
|
snr_per_bin[key] = avg |
|
|
x_labels.append(key) |
|
|
y_values.append(avg if avg is not None else 0) |
|
|
|
|
|
with open("avg_snr_estimate_db_per_duration0-5_bin.json", "w") as f: |
|
|
json.dump(snr_per_bin, f, indent=2) |
|
|
|
|
|
plt.figure(figsize=(10, 6)) |
|
|
plt.bar(x_labels, y_values, color='teal', edgecolor='black') |
|
|
plt.xticks(rotation=45) |
|
|
plt.xlabel("Duration Bin (s)") |
|
|
plt.ylabel("Avg SNR (dB)") |
|
|
plt.title("Average SNR Estimate per Duration Bin") |
|
|
plt.grid(axis='y') |
|
|
plt.tight_layout() |
|
|
plt.savefig("/home/sidd/Desktop/work/IME DATASET REVIEW/audio_duration/AverageSNR0-5.jpg") |
|
|
plt.show() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
min_duration = 5 |
|
|
max_duration = 10 |
|
|
bin_width = 0.5 |
|
|
bins = np.arange(min_duration, max_duration + bin_width, bin_width) |
|
|
|
|
|
cleaned_snr = [float(x) if isinstance(x, (int, float)) and x is not None else np.nan for x in snr_estimate_db] |
|
|
snr_array = np.array(cleaned_snr, dtype=np.float32) |
|
|
|
|
|
cleaned_durations = [float(x) if isinstance(x, (int, float)) and x is not None else np.nan for x in duration_values] |
|
|
duration_array = np.array(cleaned_durations, dtype=np.float32) |
|
|
|
|
|
snr_per_bin = {} |
|
|
x_labels = [] |
|
|
y_values = [] |
|
|
|
|
|
for i in range(len(bins) - 1): |
|
|
mask = (duration_array >= bins[i]) & (duration_array < bins[i+1]) & ~np.isnan(snr_array) |
|
|
values = snr_array[mask] |
|
|
avg = float(np.mean(values)) if len(values) > 0 else None |
|
|
key = f"{bins[i]}-{bins[i+1]}" |
|
|
snr_per_bin[key] = avg |
|
|
x_labels.append(key) |
|
|
y_values.append(avg if avg is not None else 0) |
|
|
|
|
|
with open("avg_snr_estimate_db_per_duration5-10_bin.json", "w") as f: |
|
|
json.dump(snr_per_bin, f, indent=2) |
|
|
|
|
|
plt.figure(figsize=(10, 6)) |
|
|
plt.bar(x_labels, y_values, color='teal', edgecolor='black') |
|
|
plt.xticks(rotation=45) |
|
|
plt.xlabel("Duration Bin (s)") |
|
|
plt.ylabel("Avg SNR (dB)") |
|
|
plt.title("Average SNR Estimate per Duration Bin") |
|
|
plt.grid(axis='y') |
|
|
plt.tight_layout() |
|
|
plt.savefig("/home/sidd/Desktop/work/IME DATASET REVIEW/audio_duration/AverageSNR5-10.jpg") |
|
|
plt.show() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
min_duration = 10 |
|
|
max_duration = 15 |
|
|
bin_width = 0.5 |
|
|
bins = np.arange(min_duration, max_duration + bin_width, bin_width) |
|
|
|
|
|
cleaned_snr = [float(x) if isinstance(x, (int, float)) and x is not None else np.nan for x in snr_estimate_db] |
|
|
snr_array = np.array(cleaned_snr, dtype=np.float32) |
|
|
|
|
|
cleaned_durations = [float(x) if isinstance(x, (int, float)) and x is not None else np.nan for x in duration_values] |
|
|
duration_array = np.array(cleaned_durations, dtype=np.float32) |
|
|
|
|
|
snr_per_bin = {} |
|
|
x_labels = [] |
|
|
y_values = [] |
|
|
|
|
|
for i in range(len(bins) - 1): |
|
|
mask = (duration_array >= bins[i]) & (duration_array < bins[i+1]) & ~np.isnan(snr_array) |
|
|
values = snr_array[mask] |
|
|
avg = float(np.mean(values)) if len(values) > 0 else None |
|
|
key = f"{bins[i]}-{bins[i+1]}" |
|
|
snr_per_bin[key] = avg |
|
|
x_labels.append(key) |
|
|
y_values.append(avg if avg is not None else 0) |
|
|
|
|
|
with open("avg_snr_estimate_db_per_duration10-15_bin.json", "w") as f: |
|
|
json.dump(snr_per_bin, f, indent=2) |
|
|
|
|
|
plt.figure(figsize=(10, 6)) |
|
|
plt.bar(x_labels, y_values, color='teal', edgecolor='black') |
|
|
plt.xticks(rotation=45) |
|
|
plt.xlabel("Duration Bin (s)") |
|
|
plt.ylabel("Avg SNR (dB)") |
|
|
plt.title("Average SNR Estimate per Duration Bin") |
|
|
plt.grid(axis='y') |
|
|
plt.tight_layout() |
|
|
plt.savefig("/home/sidd/Desktop/work/IME DATASET REVIEW/audio_duration/AverageSNR10-15.jpg") |
|
|
plt.show() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
min_duration = 15 |
|
|
max_duration = 20 |
|
|
bin_width = 0.5 |
|
|
bins = np.arange(min_duration, max_duration + bin_width, bin_width) |
|
|
|
|
|
cleaned_snr = [float(x) if isinstance(x, (int, float)) and x is not None else np.nan for x in snr_estimate_db] |
|
|
snr_array = np.array(cleaned_snr, dtype=np.float32) |
|
|
|
|
|
cleaned_durations = [float(x) if isinstance(x, (int, float)) and x is not None else np.nan for x in duration_values] |
|
|
duration_array = np.array(cleaned_durations, dtype=np.float32) |
|
|
|
|
|
snr_per_bin = {} |
|
|
x_labels = [] |
|
|
y_values = [] |
|
|
|
|
|
for i in range(len(bins) - 1): |
|
|
mask = (duration_array >= bins[i]) & (duration_array < bins[i+1]) & ~np.isnan(snr_array) |
|
|
values = snr_array[mask] |
|
|
avg = float(np.mean(values)) if len(values) > 0 else None |
|
|
key = f"{bins[i]}-{bins[i+1]}" |
|
|
snr_per_bin[key] = avg |
|
|
x_labels.append(key) |
|
|
y_values.append(avg if avg is not None else 0) |
|
|
|
|
|
with open("avg_snr_estimate_db_per_duration15-20_bin.json", "w") as f: |
|
|
json.dump(snr_per_bin, f, indent=2) |
|
|
|
|
|
plt.figure(figsize=(10, 6)) |
|
|
plt.bar(x_labels, y_values, color='teal', edgecolor='black') |
|
|
plt.xticks(rotation=45) |
|
|
plt.xlabel("Duration Bin (s)") |
|
|
plt.ylabel("Avg SNR (dB)") |
|
|
plt.title("Average SNR Estimate per Duration Bin") |
|
|
plt.grid(axis='y') |
|
|
plt.tight_layout() |
|
|
plt.savefig("/home/sidd/Desktop/work/IME DATASET REVIEW/audio_duration/AverageSNR15-20.jpg") |
|
|
plt.show() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
min_duration = 20 |
|
|
max_duration = 25 |
|
|
bin_width = 0.5 |
|
|
bins = np.arange(min_duration, max_duration + bin_width, bin_width) |
|
|
|
|
|
cleaned_snr = [float(x) if isinstance(x, (int, float)) and x is not None else np.nan for x in snr_estimate_db] |
|
|
snr_array = np.array(cleaned_snr, dtype=np.float32) |
|
|
|
|
|
cleaned_durations = [float(x) if isinstance(x, (int, float)) and x is not None else np.nan for x in duration_values] |
|
|
duration_array = np.array(cleaned_durations, dtype=np.float32) |
|
|
|
|
|
snr_per_bin = {} |
|
|
x_labels = [] |
|
|
y_values = [] |
|
|
|
|
|
for i in range(len(bins) - 1): |
|
|
mask = (duration_array >= bins[i]) & (duration_array < bins[i+1]) & ~np.isnan(snr_array) |
|
|
values = snr_array[mask] |
|
|
avg = float(np.mean(values)) if len(values) > 0 else None |
|
|
key = f"{bins[i]}-{bins[i+1]}" |
|
|
snr_per_bin[key] = avg |
|
|
x_labels.append(key) |
|
|
y_values.append(avg if avg is not None else 0) |
|
|
|
|
|
with open("avg_snr_estimate_db_per_duration20-25_bin.json", "w") as f: |
|
|
json.dump(snr_per_bin, f, indent=2) |
|
|
|
|
|
plt.figure(figsize=(10, 6)) |
|
|
plt.bar(x_labels, y_values, color='teal', edgecolor='black') |
|
|
plt.xticks(rotation=45) |
|
|
plt.xlabel("Duration Bin (s)") |
|
|
plt.ylabel("Avg SNR (dB)") |
|
|
plt.title("Average SNR Estimate per Duration Bin") |
|
|
plt.grid(axis='y') |
|
|
plt.tight_layout() |
|
|
plt.savefig("/home/sidd/Desktop/work/IME DATASET REVIEW/audio_duration/AverageSNR20-25.jpg") |
|
|
plt.show() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
min_duration = 25 |
|
|
max_duration = 30 |
|
|
bin_width = 0.5 |
|
|
bins = np.arange(min_duration, max_duration + bin_width, bin_width) |
|
|
|
|
|
cleaned_snr = [float(x) if isinstance(x, (int, float)) and x is not None else np.nan for x in snr_estimate_db] |
|
|
snr_array = np.array(cleaned_snr, dtype=np.float32) |
|
|
|
|
|
cleaned_durations = [float(x) if isinstance(x, (int, float)) and x is not None else np.nan for x in duration_values] |
|
|
duration_array = np.array(cleaned_durations, dtype=np.float32) |
|
|
|
|
|
snr_per_bin = {} |
|
|
x_labels = [] |
|
|
y_values = [] |
|
|
|
|
|
for i in range(len(bins) - 1): |
|
|
mask = (duration_array >= bins[i]) & (duration_array < bins[i+1]) & ~np.isnan(snr_array) |
|
|
values = snr_array[mask] |
|
|
avg = float(np.mean(values)) if len(values) > 0 else None |
|
|
key = f"{bins[i]}-{bins[i+1]}" |
|
|
snr_per_bin[key] = avg |
|
|
x_labels.append(key) |
|
|
y_values.append(avg if avg is not None else 0) |
|
|
|
|
|
with open("avg_snr_estimate_db_per_duration25-30_bin.json", "w") as f: |
|
|
json.dump(snr_per_bin, f, indent=2) |
|
|
|
|
|
plt.figure(figsize=(10, 6)) |
|
|
plt.bar(x_labels, y_values, color='teal', edgecolor='black') |
|
|
plt.xticks(rotation=45) |
|
|
plt.xlabel("Duration Bin (s)") |
|
|
plt.ylabel("Avg SNR (dB)") |
|
|
plt.title("Average SNR Estimate per Duration Bin") |
|
|
plt.grid(axis='y') |
|
|
plt.tight_layout() |
|
|
plt.savefig("/home/sidd/Desktop/work/IME DATASET REVIEW/audio_duration/AverageSNR25-30jpg") |
|
|
plt.show() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
speech_percentage= [example['audio_features']['speech_percentage'] for example in data] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
min_duration = 0 |
|
|
max_duration = 5 |
|
|
bin_width = 0.5 |
|
|
bins = np.arange(min_duration, max_duration + bin_width, bin_width) |
|
|
|
|
|
cleaned_speech_pct = [float(x) if isinstance(x, (int, float)) and x is not None else np.nan for x in speech_percentage] |
|
|
speech_pct_array = np.array(cleaned_speech_pct, dtype=np.float32) |
|
|
|
|
|
speech_per_bin = {} |
|
|
x_labels = [] |
|
|
y_values = [] |
|
|
|
|
|
for i in range(len(bins) - 1): |
|
|
mask = (duration_array >= bins[i]) & (duration_array < bins[i+1]) & ~np.isnan(speech_pct_array) |
|
|
values = speech_pct_array[mask] |
|
|
avg = float(np.mean(values)) if len(values) > 0 else None |
|
|
key = f"{bins[i]}-{bins[i+1]}" |
|
|
speech_per_bin[key] = avg |
|
|
x_labels.append(key) |
|
|
y_values.append(avg if avg is not None else 0) |
|
|
|
|
|
with open("avg_speech_percentage_per_duration0-5_bin.json", "w") as f: |
|
|
json.dump(speech_per_bin, f, indent=2) |
|
|
|
|
|
plt.figure(figsize=(10, 6)) |
|
|
plt.bar(x_labels, y_values, color='green', edgecolor='black') |
|
|
plt.xticks(rotation=45) |
|
|
plt.xlabel("Duration Bin (s)") |
|
|
plt.ylabel("Avg Speech %") |
|
|
plt.title("Average Speech Percentage per Duration Bin") |
|
|
plt.grid(axis='y') |
|
|
plt.tight_layout() |
|
|
plt.savefig("/home/sidd/Desktop/work/IME DATASET REVIEW/avg_speech/AverageSpeechPercentage0-5.jpg") |
|
|
plt.show() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
min_duration = 5 |
|
|
max_duration = 10 |
|
|
bin_width = 0.5 |
|
|
bins = np.arange(min_duration, max_duration + bin_width, bin_width) |
|
|
|
|
|
cleaned_speech_pct = [float(x) if isinstance(x, (int, float)) and x is not None else np.nan for x in speech_percentage] |
|
|
speech_pct_array = np.array(cleaned_speech_pct, dtype=np.float32) |
|
|
|
|
|
speech_per_bin = {} |
|
|
x_labels = [] |
|
|
y_values = [] |
|
|
|
|
|
for i in range(len(bins) - 1): |
|
|
mask = (duration_array >= bins[i]) & (duration_array < bins[i+1]) & ~np.isnan(speech_pct_array) |
|
|
values = speech_pct_array[mask] |
|
|
avg = float(np.mean(values)) if len(values) > 0 else None |
|
|
key = f"{bins[i]}-{bins[i+1]}" |
|
|
speech_per_bin[key] = avg |
|
|
x_labels.append(key) |
|
|
y_values.append(avg if avg is not None else 0) |
|
|
|
|
|
with open("avg_speech_percentage_per_duration5-10_bin.json", "w") as f: |
|
|
json.dump(speech_per_bin, f, indent=2) |
|
|
|
|
|
plt.figure(figsize=(10, 6)) |
|
|
plt.bar(x_labels, y_values, color='green', edgecolor='black') |
|
|
plt.xticks(rotation=45) |
|
|
plt.xlabel("Duration Bin (s)") |
|
|
plt.ylabel("Avg Speech %") |
|
|
plt.title("Average Speech Percentage per Duration Bin") |
|
|
plt.grid(axis='y') |
|
|
plt.tight_layout() |
|
|
plt.savefig("/home/sidd/Desktop/work/IME DATASET REVIEW/audio_duration/AverageSpeechPercentage5-10.jpg") |
|
|
plt.show() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
min_duration = 10 |
|
|
max_duration = 15 |
|
|
bin_width = 0.5 |
|
|
bins = np.arange(min_duration, max_duration + bin_width, bin_width) |
|
|
|
|
|
cleaned_speech_pct = [float(x) if isinstance(x, (int, float)) and x is not None else np.nan for x in speech_percentage] |
|
|
speech_pct_array = np.array(cleaned_speech_pct, dtype=np.float32) |
|
|
|
|
|
speech_per_bin = {} |
|
|
x_labels = [] |
|
|
y_values = [] |
|
|
|
|
|
for i in range(len(bins) - 1): |
|
|
mask = (duration_array >= bins[i]) & (duration_array < bins[i+1]) & ~np.isnan(speech_pct_array) |
|
|
values = speech_pct_array[mask] |
|
|
avg = float(np.mean(values)) if len(values) > 0 else None |
|
|
key = f"{bins[i]}-{bins[i+1]}" |
|
|
speech_per_bin[key] = avg |
|
|
x_labels.append(key) |
|
|
y_values.append(avg if avg is not None else 0) |
|
|
|
|
|
with open("avg_speech_percentage_per_duration10-15_bin.json", "w") as f: |
|
|
json.dump(speech_per_bin, f, indent=2) |
|
|
|
|
|
plt.figure(figsize=(10, 6)) |
|
|
plt.bar(x_labels, y_values, color='green', edgecolor='black') |
|
|
plt.xticks(rotation=45) |
|
|
plt.xlabel("Duration Bin (s)") |
|
|
plt.ylabel("Avg Speech %") |
|
|
plt.title("Average Speech Percentage per Duration Bin") |
|
|
plt.grid(axis='y') |
|
|
plt.tight_layout() |
|
|
plt.savefig("/home/sidd/Desktop/work/IME DATASET REVIEW/audio_duration/AverageSpeechPercentage10-15.jpg") |
|
|
plt.show() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
min_duration = 15 |
|
|
max_duration = 20 |
|
|
bin_width = 0.5 |
|
|
bins = np.arange(min_duration, max_duration + bin_width, bin_width) |
|
|
|
|
|
cleaned_speech_pct = [float(x) if isinstance(x, (int, float)) and x is not None else np.nan for x in speech_percentage] |
|
|
speech_pct_array = np.array(cleaned_speech_pct, dtype=np.float32) |
|
|
|
|
|
speech_per_bin = {} |
|
|
x_labels = [] |
|
|
y_values = [] |
|
|
|
|
|
for i in range(len(bins) - 1): |
|
|
mask = (duration_array >= bins[i]) & (duration_array < bins[i+1]) & ~np.isnan(speech_pct_array) |
|
|
values = speech_pct_array[mask] |
|
|
avg = float(np.mean(values)) if len(values) > 0 else None |
|
|
key = f"{bins[i]}-{bins[i+1]}" |
|
|
speech_per_bin[key] = avg |
|
|
x_labels.append(key) |
|
|
y_values.append(avg if avg is not None else 0) |
|
|
|
|
|
with open("avg_speech_percentage_per_duration15-20_bin.json", "w") as f: |
|
|
json.dump(speech_per_bin, f, indent=2) |
|
|
|
|
|
plt.figure(figsize=(10, 6)) |
|
|
plt.bar(x_labels, y_values, color='green', edgecolor='black') |
|
|
plt.xticks(rotation=45) |
|
|
plt.xlabel("Duration Bin (s)") |
|
|
plt.ylabel("Avg Speech %") |
|
|
plt.title("Average Speech Percentage per Duration Bin") |
|
|
plt.grid(axis='y') |
|
|
plt.tight_layout() |
|
|
plt.savefig("/home/sidd/Desktop/work/IME DATASET REVIEW/audio_duration/AverageSpeechPercentage15-20.jpg") |
|
|
plt.show() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
min_duration = 20 |
|
|
max_duration = 25 |
|
|
bin_width = 0.5 |
|
|
bins = np.arange(min_duration, max_duration + bin_width, bin_width) |
|
|
|
|
|
cleaned_speech_pct = [float(x) if isinstance(x, (int, float)) and x is not None else np.nan for x in speech_percentage] |
|
|
speech_pct_array = np.array(cleaned_speech_pct, dtype=np.float32) |
|
|
|
|
|
speech_per_bin = {} |
|
|
x_labels = [] |
|
|
y_values = [] |
|
|
|
|
|
for i in range(len(bins) - 1): |
|
|
mask = (duration_array >= bins[i]) & (duration_array < bins[i+1]) & ~np.isnan(speech_pct_array) |
|
|
values = speech_pct_array[mask] |
|
|
avg = float(np.mean(values)) if len(values) > 0 else None |
|
|
key = f"{bins[i]}-{bins[i+1]}" |
|
|
speech_per_bin[key] = avg |
|
|
x_labels.append(key) |
|
|
y_values.append(avg if avg is not None else 0) |
|
|
|
|
|
with open("avg_speech_percentage_per_duration20-25_bin.json", "w") as f: |
|
|
json.dump(speech_per_bin, f, indent=2) |
|
|
|
|
|
plt.figure(figsize=(10, 6)) |
|
|
plt.bar(x_labels, y_values, color='green', edgecolor='black') |
|
|
plt.xticks(rotation=45) |
|
|
plt.xlabel("Duration Bin (s)") |
|
|
plt.ylabel("Avg Speech %") |
|
|
plt.title("Average Speech Percentage per Duration Bin") |
|
|
plt.grid(axis='y') |
|
|
plt.tight_layout() |
|
|
plt.savefig("/home/sidd/Desktop/work/IME DATASET REVIEW/audio_duration/AverageSpeechPercentage20-25.jpg") |
|
|
plt.show() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
min_duration = 25 |
|
|
max_duration = 30 |
|
|
bin_width = 0.5 |
|
|
bins = np.arange(min_duration, max_duration + bin_width, bin_width) |
|
|
|
|
|
cleaned_speech_pct = [float(x) if isinstance(x, (int, float)) and x is not None else np.nan for x in speech_percentage] |
|
|
speech_pct_array = np.array(cleaned_speech_pct, dtype=np.float32) |
|
|
|
|
|
speech_per_bin = {} |
|
|
x_labels = [] |
|
|
y_values = [] |
|
|
|
|
|
for i in range(len(bins) - 1): |
|
|
mask = (duration_array >= bins[i]) & (duration_array < bins[i+1]) & ~np.isnan(speech_pct_array) |
|
|
values = speech_pct_array[mask] |
|
|
avg = float(np.mean(values)) if len(values) > 0 else None |
|
|
key = f"{bins[i]}-{bins[i+1]}" |
|
|
speech_per_bin[key] = avg |
|
|
x_labels.append(key) |
|
|
y_values.append(avg if avg is not None else 0) |
|
|
|
|
|
with open("avg_speech_percentage_per_duration25-30_bin.json", "w") as f: |
|
|
json.dump(speech_per_bin, f, indent=2) |
|
|
|
|
|
plt.figure(figsize=(10, 6)) |
|
|
plt.bar(x_labels, y_values, color='green', edgecolor='black') |
|
|
plt.xticks(rotation=45) |
|
|
plt.xlabel("Duration Bin (s)") |
|
|
plt.ylabel("Avg Speech %") |
|
|
plt.title("Average Speech Percentage per Duration Bin") |
|
|
plt.grid(axis='y') |
|
|
plt.tight_layout() |
|
|
plt.savefig("/home/sidd/Desktop/work/IME DATASET REVIEW/audio_duration/AverageSpeechPercentage25-30.jpg") |
|
|
plt.show() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
std_dev_f0_hz = [example['audio_features']['std_dev_f0_hz'] for example in data] |
|
|
|
|
|
|
|
|
min_duration = 0 |
|
|
max_duration = 5 |
|
|
bin_width = 0.5 |
|
|
bins = np.arange(min_duration, max_duration + bin_width, bin_width) |
|
|
|
|
|
cleaned_std_f0 = [float(x) if isinstance(x, (int, float)) and x is not None else np.nan for x in std_dev_f0_hz] |
|
|
std_f0_array = np.array(cleaned_std_f0, dtype=np.float32) |
|
|
|
|
|
std_f0_per_bin = {} |
|
|
x_labels = [] |
|
|
y_values = [] |
|
|
|
|
|
for i in range(len(bins) - 1): |
|
|
mask = (duration_array >= bins[i]) & (duration_array < bins[i+1]) & ~np.isnan(std_f0_array) |
|
|
values = std_f0_array[mask] |
|
|
avg = float(np.mean(values)) if len(values) > 0 else None |
|
|
key = f"{bins[i]}-{bins[i+1]}" |
|
|
std_f0_per_bin[key] = avg |
|
|
x_labels.append(key) |
|
|
y_values.append(avg if avg is not None else 0) |
|
|
|
|
|
with open("avg_std_dev_f0_hz_per_duration0-5_bin.json", "w") as f: |
|
|
json.dump(std_f0_per_bin, f, indent=2) |
|
|
|
|
|
plt.figure(figsize=(10, 6)) |
|
|
plt.bar(x_labels, y_values, color='violet', edgecolor='black') |
|
|
plt.xticks(rotation=45) |
|
|
plt.xlabel("Duration Bin (s)") |
|
|
plt.ylabel("Avg Std Dev F0 (Hz)") |
|
|
plt.title("Avg Std Dev of F0 per Duration Bin") |
|
|
plt.grid(axis='y') |
|
|
plt.tight_layout() |
|
|
plt.savefig("/home/sidd/Desktop/work/IME DATASET REVIEW/audio_duration/AvgStdDev0-5.jpg") |
|
|
plt.show() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
min_duration = 5 |
|
|
max_duration = 10 |
|
|
bin_width = 0.5 |
|
|
bins = np.arange(min_duration, max_duration + bin_width, bin_width) |
|
|
|
|
|
cleaned_std_f0 = [float(x) if isinstance(x, (int, float)) and x is not None else np.nan for x in std_dev_f0_hz] |
|
|
std_f0_array = np.array(cleaned_std_f0, dtype=np.float32) |
|
|
|
|
|
std_f0_per_bin = {} |
|
|
x_labels = [] |
|
|
y_values = [] |
|
|
|
|
|
for i in range(len(bins) - 1): |
|
|
mask = (duration_array >= bins[i]) & (duration_array < bins[i+1]) & ~np.isnan(std_f0_array) |
|
|
values = std_f0_array[mask] |
|
|
avg = float(np.mean(values)) if len(values) > 0 else None |
|
|
key = f"{bins[i]}-{bins[i+1]}" |
|
|
std_f0_per_bin[key] = avg |
|
|
x_labels.append(key) |
|
|
y_values.append(avg if avg is not None else 0) |
|
|
|
|
|
with open("avg_std_dev_f0_hz_per_duration5-10_bin.json", "w") as f: |
|
|
json.dump(std_f0_per_bin, f, indent=2) |
|
|
|
|
|
plt.figure(figsize=(10, 6)) |
|
|
plt.bar(x_labels, y_values, color='violet', edgecolor='black') |
|
|
plt.xticks(rotation=45) |
|
|
plt.xlabel("Duration Bin (s)") |
|
|
plt.ylabel("Avg Std Dev F0 (Hz)") |
|
|
plt.title("Avg Std Dev of F0 per Duration Bin") |
|
|
plt.grid(axis='y') |
|
|
plt.tight_layout() |
|
|
plt.savefig("/home/sidd/Desktop/work/IME DATASET REVIEW/audio_duration/AvgStdDev5-10.jpg") |
|
|
plt.show() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
min_duration = 10 |
|
|
max_duration = 15 |
|
|
bin_width = 0.5 |
|
|
bins = np.arange(min_duration, max_duration + bin_width, bin_width) |
|
|
|
|
|
cleaned_std_f0 = [float(x) if isinstance(x, (int, float)) and x is not None else np.nan for x in std_dev_f0_hz] |
|
|
std_f0_array = np.array(cleaned_std_f0, dtype=np.float32) |
|
|
|
|
|
std_f0_per_bin = {} |
|
|
x_labels = [] |
|
|
y_values = [] |
|
|
|
|
|
for i in range(len(bins) - 1): |
|
|
mask = (duration_array >= bins[i]) & (duration_array < bins[i+1]) & ~np.isnan(std_f0_array) |
|
|
values = std_f0_array[mask] |
|
|
avg = float(np.mean(values)) if len(values) > 0 else None |
|
|
key = f"{bins[i]}-{bins[i+1]}" |
|
|
std_f0_per_bin[key] = avg |
|
|
x_labels.append(key) |
|
|
y_values.append(avg if avg is not None else 0) |
|
|
|
|
|
with open("avg_std_dev_f0_hz_per_duration10-15_bin.json", "w") as f: |
|
|
json.dump(std_f0_per_bin, f, indent=2) |
|
|
|
|
|
plt.figure(figsize=(10, 6)) |
|
|
plt.bar(x_labels, y_values, color='violet', edgecolor='black') |
|
|
plt.xticks(rotation=45) |
|
|
plt.xlabel("Duration Bin (s)") |
|
|
plt.ylabel("Avg Std Dev F0 (Hz)") |
|
|
plt.title("Avg Std Dev of F0 per Duration Bin") |
|
|
plt.grid(axis='y') |
|
|
plt.tight_layout() |
|
|
plt.savefig("/home/sidd/Desktop/work/IME DATASET REVIEW/audio_duration/AvgStdDev10-15.jpg") |
|
|
plt.show() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
min_duration = 15 |
|
|
max_duration = 20 |
|
|
bin_width = 0.5 |
|
|
bins = np.arange(min_duration, max_duration + bin_width, bin_width) |
|
|
|
|
|
cleaned_std_f0 = [float(x) if isinstance(x, (int, float)) and x is not None else np.nan for x in std_dev_f0_hz] |
|
|
std_f0_array = np.array(cleaned_std_f0, dtype=np.float32) |
|
|
|
|
|
std_f0_per_bin = {} |
|
|
x_labels = [] |
|
|
y_values = [] |
|
|
|
|
|
for i in range(len(bins) - 1): |
|
|
mask = (duration_array >= bins[i]) & (duration_array < bins[i+1]) & ~np.isnan(std_f0_array) |
|
|
values = std_f0_array[mask] |
|
|
avg = float(np.mean(values)) if len(values) > 0 else None |
|
|
key = f"{bins[i]}-{bins[i+1]}" |
|
|
std_f0_per_bin[key] = avg |
|
|
x_labels.append(key) |
|
|
y_values.append(avg if avg is not None else 0) |
|
|
|
|
|
with open("avg_std_dev_f0_hz_per_duration15-20_bin.json", "w") as f: |
|
|
json.dump(std_f0_per_bin, f, indent=2) |
|
|
|
|
|
plt.figure(figsize=(10, 6)) |
|
|
plt.bar(x_labels, y_values, color='violet', edgecolor='black') |
|
|
plt.xticks(rotation=45) |
|
|
plt.xlabel("Duration Bin (s)") |
|
|
plt.ylabel("Avg Std Dev F0 (Hz)") |
|
|
plt.title("Avg Std Dev of F0 per Duration Bin") |
|
|
plt.grid(axis='y') |
|
|
plt.tight_layout() |
|
|
plt.savefig("/home/sidd/Desktop/work/IME DATASET REVIEW/audio_duration/AvgStdDev15-20.jpg") |
|
|
plt.show() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
min_duration = 20 |
|
|
max_duration = 25 |
|
|
bin_width = 0.5 |
|
|
bins = np.arange(min_duration, max_duration + bin_width, bin_width) |
|
|
|
|
|
cleaned_std_f0 = [float(x) if isinstance(x, (int, float)) and x is not None else np.nan for x in std_dev_f0_hz] |
|
|
std_f0_array = np.array(cleaned_std_f0, dtype=np.float32) |
|
|
|
|
|
std_f0_per_bin = {} |
|
|
x_labels = [] |
|
|
y_values = [] |
|
|
|
|
|
for i in range(len(bins) - 1): |
|
|
mask = (duration_array >= bins[i]) & (duration_array < bins[i+1]) & ~np.isnan(std_f0_array) |
|
|
values = std_f0_array[mask] |
|
|
avg = float(np.mean(values)) if len(values) > 0 else None |
|
|
key = f"{bins[i]}-{bins[i+1]}" |
|
|
std_f0_per_bin[key] = avg |
|
|
x_labels.append(key) |
|
|
y_values.append(avg if avg is not None else 0) |
|
|
|
|
|
with open("avg_std_dev_f0_hz_per_duration20-25_bin.json", "w") as f: |
|
|
json.dump(std_f0_per_bin, f, indent=2) |
|
|
|
|
|
plt.figure(figsize=(10, 6)) |
|
|
plt.bar(x_labels, y_values, color='violet', edgecolor='black') |
|
|
plt.xticks(rotation=45) |
|
|
plt.xlabel("Duration Bin (s)") |
|
|
plt.ylabel("Avg Std Dev F0 (Hz)") |
|
|
plt.title("Avg Std Dev of F0 per Duration Bin") |
|
|
plt.grid(axis='y') |
|
|
plt.tight_layout() |
|
|
plt.savefig("/home/sidd/Desktop/work/IME DATASET REVIEW/audio_duration/AvgStdDev20-25.jpg") |
|
|
plt.show() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
min_duration = 25 |
|
|
max_duration = 30 |
|
|
bin_width = 0.5 |
|
|
bins = np.arange(min_duration, max_duration + bin_width, bin_width) |
|
|
|
|
|
cleaned_std_f0 = [float(x) if isinstance(x, (int, float)) and x is not None else np.nan for x in std_dev_f0_hz] |
|
|
std_f0_array = np.array(cleaned_std_f0, dtype=np.float32) |
|
|
|
|
|
std_f0_per_bin = {} |
|
|
x_labels = [] |
|
|
y_values = [] |
|
|
|
|
|
for i in range(len(bins) - 1): |
|
|
mask = (duration_array >= bins[i]) & (duration_array < bins[i+1]) & ~np.isnan(std_f0_array) |
|
|
values = std_f0_array[mask] |
|
|
avg = float(np.mean(values)) if len(values) > 0 else None |
|
|
key = f"{bins[i]}-{bins[i+1]}" |
|
|
std_f0_per_bin[key] = avg |
|
|
x_labels.append(key) |
|
|
y_values.append(avg if avg is not None else 0) |
|
|
|
|
|
with open("avg_std_dev_f0_hz_per_duration25-30_bin.json", "w") as f: |
|
|
json.dump(std_f0_per_bin, f, indent=2) |
|
|
|
|
|
plt.figure(figsize=(10, 6)) |
|
|
plt.bar(x_labels, y_values, color='violet', edgecolor='black') |
|
|
plt.xticks(rotation=45) |
|
|
plt.xlabel("Duration Bin (s)") |
|
|
plt.ylabel("Avg Std Dev F0 (Hz)") |
|
|
plt.title("Avg Std Dev of F0 per Duration Bin") |
|
|
plt.grid(axis='y') |
|
|
plt.tight_layout() |
|
|
plt.savefig("/home/sidd/Desktop/work/IME DATASET REVIEW/audio_duration/AvgStdDev25-30.jpg") |
|
|
plt.show() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bandwidth_category = [example['audio_features']['bandwidth_category'] for example in data] |
|
|
|
|
|
import numpy as np |
|
|
import matplotlib.pyplot as plt |
|
|
import json |
|
|
|
|
|
|
|
|
|
|
|
min_duration = 0 |
|
|
max_duration = 5 |
|
|
bin_width = 0.5 |
|
|
bins = np.arange(min_duration, max_duration + bin_width, bin_width) |
|
|
|
|
|
|
|
|
bandwidth_category_array = np.array(bandwidth_category, dtype=object) |
|
|
duration_array = np.array(duration_values, dtype=np.float32) |
|
|
|
|
|
|
|
|
bandwidth_per_bin = {} |
|
|
x_labels = [] |
|
|
|
|
|
for i in range(len(bins) - 1): |
|
|
start, end = bins[i], bins[i + 1] |
|
|
|
|
|
mask = ( |
|
|
(duration_array >= start) & |
|
|
(duration_array < end) & |
|
|
np.array([x is not None and x != '' for x in bandwidth_category_array]) |
|
|
) |
|
|
|
|
|
|
|
|
categories_in_bin = bandwidth_category_array[mask] |
|
|
|
|
|
|
|
|
category_counts = {} |
|
|
for category in categories_in_bin: |
|
|
category_counts[category] = category_counts.get(category, 0) + 1 |
|
|
|
|
|
|
|
|
key = f"{start}-{end}" |
|
|
bandwidth_per_bin[key] = category_counts |
|
|
x_labels.append(key) |
|
|
|
|
|
|
|
|
with open("bandwidth_category_per_duration_bin.json", "w") as f: |
|
|
json.dump(bandwidth_per_bin, f, indent=2) |
|
|
|
|
|
|
|
|
category_labels = list(set(cat for bin_data in bandwidth_per_bin.values() for cat in bin_data.keys())) |
|
|
category_counts = {category: [] for category in category_labels} |
|
|
|
|
|
for label in x_labels: |
|
|
bin_data = bandwidth_per_bin[label] |
|
|
for category in category_labels: |
|
|
category_counts[category].append(bin_data.get(category, 0)) |
|
|
|
|
|
|
|
|
plt.figure(figsize=(10, 6)) |
|
|
bar_width = 0.1 |
|
|
|
|
|
for idx, category in enumerate(category_labels): |
|
|
plt.bar( |
|
|
np.arange(len(x_labels)) + idx * bar_width, |
|
|
category_counts[category], |
|
|
width=bar_width, |
|
|
label=category |
|
|
) |
|
|
|
|
|
plt.xticks(np.arange(len(x_labels)) + bar_width * (len(category_labels) - 1) / 2, x_labels, rotation=45) |
|
|
plt.xlabel("Duration Bin (s)") |
|
|
plt.ylabel("Count") |
|
|
plt.title("Bandwidth Category per Duration Bin") |
|
|
plt.legend(title="Bandwidth Category") |
|
|
plt.tight_layout() |
|
|
|
|
|
plt.savefig("/home/sidd/Desktop/work/IME DATASET REVIEW/bandwidth_category/bandwidth_duration0-5_histogram.jpg") |
|
|
plt.show() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import numpy as np |
|
|
import matplotlib.pyplot as plt |
|
|
import json |
|
|
|
|
|
|
|
|
|
|
|
min_duration = 5 |
|
|
max_duration = 10 |
|
|
bin_width = 0.5 |
|
|
bins = np.arange(min_duration, max_duration + bin_width, bin_width) |
|
|
|
|
|
|
|
|
bandwidth_category_array = np.array(bandwidth_category, dtype=object) |
|
|
duration_array = np.array(duration_values, dtype=np.float32) |
|
|
|
|
|
|
|
|
bandwidth_per_bin = {} |
|
|
x_labels = [] |
|
|
|
|
|
for i in range(len(bins) - 1): |
|
|
start, end = bins[i], bins[i + 1] |
|
|
|
|
|
mask = ( |
|
|
(duration_array >= start) & |
|
|
(duration_array < end) & |
|
|
np.array([x is not None and x != '' for x in bandwidth_category_array]) |
|
|
) |
|
|
|
|
|
|
|
|
categories_in_bin = bandwidth_category_array[mask] |
|
|
|
|
|
|
|
|
category_counts = {} |
|
|
for category in categories_in_bin: |
|
|
category_counts[category] = category_counts.get(category, 0) + 1 |
|
|
|
|
|
|
|
|
key = f"{start}-{end}" |
|
|
bandwidth_per_bin[key] = category_counts |
|
|
x_labels.append(key) |
|
|
|
|
|
|
|
|
with open("bandwidth_category_per_duration5_bin.json", "w") as f: |
|
|
json.dump(bandwidth_per_bin, f, indent=2) |
|
|
|
|
|
|
|
|
category_labels = list(set(cat for bin_data in bandwidth_per_bin.values() for cat in bin_data.keys())) |
|
|
category_counts = {category: [] for category in category_labels} |
|
|
|
|
|
for label in x_labels: |
|
|
bin_data = bandwidth_per_bin[label] |
|
|
for category in category_labels: |
|
|
category_counts[category].append(bin_data.get(category, 0)) |
|
|
|
|
|
|
|
|
plt.figure(figsize=(10, 6)) |
|
|
bar_width = 0.1 |
|
|
|
|
|
for idx, category in enumerate(category_labels): |
|
|
plt.bar( |
|
|
np.arange(len(x_labels)) + idx * bar_width, |
|
|
category_counts[category], |
|
|
width=bar_width, |
|
|
label=category |
|
|
) |
|
|
|
|
|
plt.xticks(np.arange(len(x_labels)) + bar_width * (len(category_labels) - 1) / 2, x_labels, rotation=45) |
|
|
plt.xlabel("Duration Bin (s)") |
|
|
plt.ylabel("Count") |
|
|
plt.title("Bandwidth Category per Duration Bin") |
|
|
plt.legend(title="Bandwidth Category") |
|
|
plt.tight_layout() |
|
|
|
|
|
plt.savefig("/home/sidd/Desktop/work/IME DATASET REVIEW/bandwidth_category/bandwidth_duration5-10_histogram.jpg") |
|
|
plt.show() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import numpy as np |
|
|
import matplotlib.pyplot as plt |
|
|
import json |
|
|
|
|
|
|
|
|
|
|
|
min_duration = 5 |
|
|
max_duration = 10 |
|
|
bin_width = 0.5 |
|
|
bins = np.arange(min_duration, max_duration + bin_width, bin_width) |
|
|
|
|
|
|
|
|
bandwidth_category_array = np.array(bandwidth_category, dtype=object) |
|
|
duration_array = np.array(duration_values, dtype=np.float32) |
|
|
|
|
|
|
|
|
bandwidth_per_bin = {} |
|
|
x_labels = [] |
|
|
|
|
|
for i in range(len(bins) - 1): |
|
|
start, end = bins[i], bins[i + 1] |
|
|
|
|
|
mask = ( |
|
|
(duration_array >= start) & |
|
|
(duration_array < end) & |
|
|
np.array([x is not None and x != '' for x in bandwidth_category_array]) |
|
|
) |
|
|
|
|
|
|
|
|
categories_in_bin = bandwidth_category_array[mask] |
|
|
|
|
|
|
|
|
category_counts = {} |
|
|
for category in categories_in_bin: |
|
|
category_counts[category] = category_counts.get(category, 0) + 1 |
|
|
|
|
|
|
|
|
key = f"{start}-{end}" |
|
|
bandwidth_per_bin[key] = category_counts |
|
|
x_labels.append(key) |
|
|
|
|
|
|
|
|
with open("bandwidth_category_per_duration10-15_bin.json", "w") as f: |
|
|
json.dump(bandwidth_per_bin, f, indent=2) |
|
|
|
|
|
|
|
|
category_labels = list(set(cat for bin_data in bandwidth_per_bin.values() for cat in bin_data.keys())) |
|
|
category_counts = {category: [] for category in category_labels} |
|
|
|
|
|
for label in x_labels: |
|
|
bin_data = bandwidth_per_bin[label] |
|
|
for category in category_labels: |
|
|
category_counts[category].append(bin_data.get(category, 0)) |
|
|
|
|
|
|
|
|
plt.figure(figsize=(10, 6)) |
|
|
bar_width = 0.1 |
|
|
|
|
|
for idx, category in enumerate(category_labels): |
|
|
plt.bar( |
|
|
np.arange(len(x_labels)) + idx * bar_width, |
|
|
category_counts[category], |
|
|
width=bar_width, |
|
|
label=category |
|
|
) |
|
|
|
|
|
plt.xticks(np.arange(len(x_labels)) + bar_width * (len(category_labels) - 1) / 2, x_labels, rotation=45) |
|
|
plt.xlabel("Duration Bin (s)") |
|
|
plt.ylabel("Count") |
|
|
plt.title("Bandwidth Category per Duration Bin") |
|
|
plt.legend(title="Bandwidth Category") |
|
|
plt.tight_layout() |
|
|
|
|
|
plt.savefig("/home/sidd/Desktop/work/IME DATASET REVIEW/bandwidth_category/bandwidth_duration10-15_histogram.jpg") |
|
|
plt.show() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import numpy as np |
|
|
import matplotlib.pyplot as plt |
|
|
import json |
|
|
|
|
|
|
|
|
|
|
|
min_duration = 15 |
|
|
max_duration = 20 |
|
|
bin_width = 0.5 |
|
|
bins = np.arange(min_duration, max_duration + bin_width, bin_width) |
|
|
|
|
|
|
|
|
bandwidth_category_array = np.array(bandwidth_category, dtype=object) |
|
|
duration_array = np.array(duration_values, dtype=np.float32) |
|
|
|
|
|
|
|
|
bandwidth_per_bin = {} |
|
|
x_labels = [] |
|
|
|
|
|
for i in range(len(bins) - 1): |
|
|
start, end = bins[i], bins[i + 1] |
|
|
|
|
|
mask = ( |
|
|
(duration_array >= start) & |
|
|
(duration_array < end) & |
|
|
np.array([x is not None and x != '' for x in bandwidth_category_array]) |
|
|
) |
|
|
|
|
|
|
|
|
categories_in_bin = bandwidth_category_array[mask] |
|
|
|
|
|
|
|
|
category_counts = {} |
|
|
for category in categories_in_bin: |
|
|
category_counts[category] = category_counts.get(category, 0) + 1 |
|
|
|
|
|
|
|
|
key = f"{start}-{end}" |
|
|
bandwidth_per_bin[key] = category_counts |
|
|
x_labels.append(key) |
|
|
|
|
|
|
|
|
with open("bandwidth_category_per_duration15-20_bin.json", "w") as f: |
|
|
json.dump(bandwidth_per_bin, f, indent=2) |
|
|
|
|
|
|
|
|
category_labels = list(set(cat for bin_data in bandwidth_per_bin.values() for cat in bin_data.keys())) |
|
|
category_counts = {category: [] for category in category_labels} |
|
|
|
|
|
for label in x_labels: |
|
|
bin_data = bandwidth_per_bin[label] |
|
|
for category in category_labels: |
|
|
category_counts[category].append(bin_data.get(category, 0)) |
|
|
|
|
|
|
|
|
plt.figure(figsize=(10, 6)) |
|
|
bar_width = 0.1 |
|
|
|
|
|
for idx, category in enumerate(category_labels): |
|
|
plt.bar( |
|
|
np.arange(len(x_labels)) + idx * bar_width, |
|
|
category_counts[category], |
|
|
width=bar_width, |
|
|
label=category |
|
|
) |
|
|
|
|
|
plt.xticks(np.arange(len(x_labels)) + bar_width * (len(category_labels) - 1) / 2, x_labels, rotation=45) |
|
|
plt.xlabel("Duration Bin (s)") |
|
|
plt.ylabel("Count") |
|
|
plt.title("Bandwidth Category per Duration Bin") |
|
|
plt.legend(title="Bandwidth Category") |
|
|
plt.tight_layout() |
|
|
plt.savefig("/home/sidd/Desktop/work/IME DATASET REVIEW/bandwidth_category/bandwidth_duration15-20_histogram.jpg") |
|
|
plt.show() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import numpy as np |
|
|
import matplotlib.pyplot as plt |
|
|
import json |
|
|
|
|
|
|
|
|
|
|
|
min_duration = 20 |
|
|
max_duration = 25 |
|
|
bin_width = 0.5 |
|
|
bins = np.arange(min_duration, max_duration + bin_width, bin_width) |
|
|
|
|
|
|
|
|
bandwidth_category_array = np.array(bandwidth_category, dtype=object) |
|
|
duration_array = np.array(duration_values, dtype=np.float32) |
|
|
|
|
|
|
|
|
bandwidth_per_bin = {} |
|
|
x_labels = [] |
|
|
|
|
|
for i in range(len(bins) - 1): |
|
|
start, end = bins[i], bins[i + 1] |
|
|
|
|
|
mask = ( |
|
|
(duration_array >= start) & |
|
|
(duration_array < end) & |
|
|
np.array([x is not None and x != '' for x in bandwidth_category_array]) |
|
|
) |
|
|
|
|
|
|
|
|
categories_in_bin = bandwidth_category_array[mask] |
|
|
|
|
|
|
|
|
category_counts = {} |
|
|
for category in categories_in_bin: |
|
|
category_counts[category] = category_counts.get(category, 0) + 1 |
|
|
|
|
|
|
|
|
key = f"{start}-{end}" |
|
|
bandwidth_per_bin[key] = category_counts |
|
|
x_labels.append(key) |
|
|
|
|
|
|
|
|
with open("bandwidth_category_per_duration20-25_bin.json", "w") as f: |
|
|
json.dump(bandwidth_per_bin, f, indent=2) |
|
|
|
|
|
|
|
|
category_labels = list(set(cat for bin_data in bandwidth_per_bin.values() for cat in bin_data.keys())) |
|
|
category_counts = {category: [] for category in category_labels} |
|
|
|
|
|
for label in x_labels: |
|
|
bin_data = bandwidth_per_bin[label] |
|
|
for category in category_labels: |
|
|
category_counts[category].append(bin_data.get(category, 0)) |
|
|
|
|
|
|
|
|
plt.figure(figsize=(10, 6)) |
|
|
bar_width = 0.1 |
|
|
|
|
|
for idx, category in enumerate(category_labels): |
|
|
plt.bar( |
|
|
np.arange(len(x_labels)) + idx * bar_width, |
|
|
category_counts[category], |
|
|
width=bar_width, |
|
|
label=category |
|
|
) |
|
|
|
|
|
plt.xticks(np.arange(len(x_labels)) + bar_width * (len(category_labels) - 1) / 2, x_labels, rotation=45) |
|
|
plt.xlabel("Duration Bin (s)") |
|
|
plt.ylabel("Count") |
|
|
plt.title("Bandwidth Category per Duration Bin") |
|
|
plt.legend(title="Bandwidth Category") |
|
|
plt.tight_layout() |
|
|
plt.savefig("/home/sidd/Desktop/work/IME DATASET REVIEW/bandwidth_category/bandwidth_duration20-25_histogram.jpg") |
|
|
plt.show() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import numpy as np |
|
|
import matplotlib.pyplot as plt |
|
|
import json |
|
|
|
|
|
|
|
|
|
|
|
min_duration = 20 |
|
|
max_duration = 25 |
|
|
bin_width = 0.5 |
|
|
bins = np.arange(min_duration, max_duration + bin_width, bin_width) |
|
|
|
|
|
|
|
|
bandwidth_category_array = np.array(bandwidth_category, dtype=object) |
|
|
duration_array = np.array(duration_values, dtype=np.float32) |
|
|
|
|
|
|
|
|
bandwidth_per_bin = {} |
|
|
x_labels = [] |
|
|
|
|
|
for i in range(len(bins) - 1): |
|
|
start, end = bins[i], bins[i + 1] |
|
|
|
|
|
mask = ( |
|
|
(duration_array >= start) & |
|
|
(duration_array < end) & |
|
|
np.array([x is not None and x != '' for x in bandwidth_category_array]) |
|
|
) |
|
|
|
|
|
|
|
|
categories_in_bin = bandwidth_category_array[mask] |
|
|
|
|
|
|
|
|
category_counts = {} |
|
|
for category in categories_in_bin: |
|
|
category_counts[category] = category_counts.get(category, 0) + 1 |
|
|
|
|
|
|
|
|
key = f"{start}-{end}" |
|
|
bandwidth_per_bin[key] = category_counts |
|
|
x_labels.append(key) |
|
|
|
|
|
|
|
|
with open("bandwidth_category_per_duration20-25_bin.json", "w") as f: |
|
|
json.dump(bandwidth_per_bin, f, indent=2) |
|
|
|
|
|
|
|
|
category_labels = list(set(cat for bin_data in bandwidth_per_bin.values() for cat in bin_data.keys())) |
|
|
category_counts = {category: [] for category in category_labels} |
|
|
|
|
|
for label in x_labels: |
|
|
bin_data = bandwidth_per_bin[label] |
|
|
for category in category_labels: |
|
|
category_counts[category].append(bin_data.get(category, 0)) |
|
|
|
|
|
|
|
|
plt.figure(figsize=(10, 6)) |
|
|
bar_width = 0.1 |
|
|
|
|
|
for idx, category in enumerate(category_labels): |
|
|
plt.bar( |
|
|
np.arange(len(x_labels)) + idx * bar_width, |
|
|
category_counts[category], |
|
|
width=bar_width, |
|
|
label=category |
|
|
) |
|
|
|
|
|
plt.xticks(np.arange(len(x_labels)) + bar_width * (len(category_labels) - 1) / 2, x_labels, rotation=45) |
|
|
plt.xlabel("Duration Bin (s)") |
|
|
plt.ylabel("Count") |
|
|
plt.title("Bandwidth Category per Duration Bin") |
|
|
plt.legend(title="Bandwidth Category") |
|
|
plt.tight_layout() |
|
|
plt.savefig("/home/sidd/Desktop/work/IME DATASET REVIEW/bandwidth_category/bandwidth_duration20-25_histogram.jpg") |
|
|
plt.show() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import numpy as np |
|
|
import matplotlib.pyplot as plt |
|
|
import json |
|
|
|
|
|
|
|
|
|
|
|
min_duration = 25 |
|
|
max_duration = 30 |
|
|
bin_width = 0.5 |
|
|
bins = np.arange(min_duration, max_duration + bin_width, bin_width) |
|
|
|
|
|
|
|
|
bandwidth_category_array = np.array(bandwidth_category, dtype=object) |
|
|
duration_array = np.array(duration_values, dtype=np.float32) |
|
|
|
|
|
|
|
|
bandwidth_per_bin = {} |
|
|
x_labels = [] |
|
|
|
|
|
for i in range(len(bins) - 1): |
|
|
start, end = bins[i], bins[i + 1] |
|
|
|
|
|
mask = ( |
|
|
(duration_array >= start) & |
|
|
(duration_array < end) & |
|
|
np.array([x is not None and x != '' for x in bandwidth_category_array]) |
|
|
) |
|
|
|
|
|
|
|
|
categories_in_bin = bandwidth_category_array[mask] |
|
|
|
|
|
|
|
|
category_counts = {} |
|
|
for category in categories_in_bin: |
|
|
category_counts[category] = category_counts.get(category, 0) + 1 |
|
|
|
|
|
|
|
|
key = f"{start}-{end}" |
|
|
bandwidth_per_bin[key] = category_counts |
|
|
x_labels.append(key) |
|
|
|
|
|
|
|
|
with open("bandwidth_category_per_duration25-30_bin.json", "w") as f: |
|
|
json.dump(bandwidth_per_bin, f, indent=2) |
|
|
|
|
|
|
|
|
category_labels = list(set(cat for bin_data in bandwidth_per_bin.values() for cat in bin_data.keys())) |
|
|
category_counts = {category: [] for category in category_labels} |
|
|
|
|
|
for label in x_labels: |
|
|
bin_data = bandwidth_per_bin[label] |
|
|
for category in category_labels: |
|
|
category_counts[category].append(bin_data.get(category, 0)) |
|
|
|
|
|
|
|
|
plt.figure(figsize=(10, 6)) |
|
|
bar_width = 0.1 |
|
|
|
|
|
for idx, category in enumerate(category_labels): |
|
|
plt.bar( |
|
|
np.arange(len(x_labels)) + idx * bar_width, |
|
|
category_counts[category], |
|
|
width=bar_width, |
|
|
label=category |
|
|
) |
|
|
|
|
|
plt.xticks(np.arange(len(x_labels)) + bar_width * (len(category_labels) - 1) / 2, x_labels, rotation=45) |
|
|
plt.xlabel("Duration Bin (s)") |
|
|
plt.ylabel("Count") |
|
|
plt.title("Bandwidth Category per Duration Bin") |
|
|
plt.legend(title="Bandwidth Category") |
|
|
plt.tight_layout() |
|
|
|
|
|
plt.show() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import numpy as np |
|
|
import matplotlib.pyplot as plt |
|
|
import json |
|
|
|
|
|
|
|
|
clipping_percentage = [example['audio_features']['clipping_percentage'] for example in data] |
|
|
duration_values = [example['audio_features']['duration'] for example in data] |
|
|
|
|
|
|
|
|
min_duration = 0 |
|
|
max_duration = 5 |
|
|
bin_width = 0.5 |
|
|
bins = np.arange(min_duration, max_duration + bin_width, bin_width) |
|
|
|
|
|
|
|
|
clipping_array = np.array([ |
|
|
float(x) if isinstance(x, (float, int)) and x is not None else np.nan |
|
|
for x in clipping_percentage |
|
|
], dtype=np.float32) |
|
|
|
|
|
duration_array = np.array([ |
|
|
float(x) if isinstance(x, (float, int)) and x is not None else np.nan |
|
|
for x in duration_values |
|
|
], dtype=np.float32) |
|
|
|
|
|
|
|
|
clipping_per_bin = {} |
|
|
x_labels = [] |
|
|
|
|
|
for i in range(len(bins) - 1): |
|
|
start, end = bins[i], bins[i + 1] |
|
|
mask = (duration_array >= start) & (duration_array < end) |
|
|
values_in_bin = clipping_array[mask] |
|
|
values_in_bin = values_in_bin[~np.isnan(values_in_bin)] |
|
|
|
|
|
avg_clip = float(np.mean(values_in_bin)) if len(values_in_bin) > 0 else None |
|
|
|
|
|
key = f"{start}-{end}" |
|
|
clipping_per_bin[key] = avg_clip |
|
|
x_labels.append(key) |
|
|
|
|
|
|
|
|
with open("clipping_percentage_per_duration0-5_bin.json", "w") as f: |
|
|
json.dump(clipping_per_bin, f, indent=2) |
|
|
|
|
|
|
|
|
heights = [clipping_per_bin[label] if clipping_per_bin[label] is not None else 0 for label in x_labels] |
|
|
|
|
|
plt.figure(figsize=(10, 6)) |
|
|
plt.bar(x_labels, heights, color='teal', edgecolor='black') |
|
|
plt.xlabel("Duration Bin (s)") |
|
|
plt.ylabel("Average Clipping Percentage") |
|
|
plt.title("Average Clipping Percentage per Duration Bin") |
|
|
plt.xticks(rotation=45) |
|
|
plt.tight_layout() |
|
|
|
|
|
plt.savefig("/home/sidd/Desktop/work/IME DATASET REVIEW/Avg_clipping_percentage/clipping_Percent_histogram0-5.jpg") |
|
|
plt.show() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import numpy as np |
|
|
import matplotlib.pyplot as plt |
|
|
import json |
|
|
|
|
|
|
|
|
min_duration = 5 |
|
|
max_duration = 10 |
|
|
bin_width = 0.5 |
|
|
bins = np.arange(min_duration, max_duration + bin_width, bin_width) |
|
|
|
|
|
|
|
|
clipping_array = np.array([ |
|
|
float(x) if isinstance(x, (float, int)) and x is not None else np.nan |
|
|
for x in clipping_percentage |
|
|
], dtype=np.float32) |
|
|
|
|
|
duration_array = np.array([ |
|
|
float(x) if isinstance(x, (float, int)) and x is not None else np.nan |
|
|
for x in duration_values |
|
|
], dtype=np.float32) |
|
|
|
|
|
|
|
|
clipping_per_bin = {} |
|
|
x_labels = [] |
|
|
|
|
|
for i in range(len(bins) - 1): |
|
|
start, end = bins[i], bins[i + 1] |
|
|
mask = (duration_array >= start) & (duration_array < end) |
|
|
values_in_bin = clipping_array[mask] |
|
|
values_in_bin = values_in_bin[~np.isnan(values_in_bin)] |
|
|
|
|
|
avg_clip = float(np.mean(values_in_bin)) if len(values_in_bin) > 0 else None |
|
|
|
|
|
key = f"{start}-{end}" |
|
|
clipping_per_bin[key] = avg_clip |
|
|
x_labels.append(key) |
|
|
|
|
|
|
|
|
with open("clipping_percentage_per_duration5-10_bin.json", "w") as f: |
|
|
json.dump(clipping_per_bin, f, indent=2) |
|
|
|
|
|
|
|
|
heights = [clipping_per_bin[label] if clipping_per_bin[label] is not None else 0 for label in x_labels] |
|
|
|
|
|
plt.figure(figsize=(10, 6)) |
|
|
plt.bar(x_labels, heights, color='teal', edgecolor='black') |
|
|
plt.xlabel("Duration Bin (s)") |
|
|
plt.ylabel("Average Clipping Percentage") |
|
|
plt.title("Average Clipping Percentage per Duration Bin") |
|
|
plt.xticks(rotation=45) |
|
|
plt.tight_layout() |
|
|
|
|
|
plt.savefig("/home/sidd/Desktop/work/IME DATASET REVIEW/Avg_clipping_percentage/clipping_Percent_histogram5-10.jpg") |
|
|
plt.show() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import numpy as np |
|
|
import matplotlib.pyplot as plt |
|
|
import json |
|
|
|
|
|
|
|
|
min_duration = 10 |
|
|
max_duration = 15 |
|
|
bin_width = 0.5 |
|
|
bins = np.arange(min_duration, max_duration + bin_width, bin_width) |
|
|
|
|
|
|
|
|
clipping_array = np.array([ |
|
|
float(x) if isinstance(x, (float, int)) and x is not None else np.nan |
|
|
for x in clipping_percentage |
|
|
], dtype=np.float32) |
|
|
|
|
|
duration_array = np.array([ |
|
|
float(x) if isinstance(x, (float, int)) and x is not None else np.nan |
|
|
for x in duration_values |
|
|
], dtype=np.float32) |
|
|
|
|
|
|
|
|
clipping_per_bin = {} |
|
|
x_labels = [] |
|
|
|
|
|
for i in range(len(bins) - 1): |
|
|
start, end = bins[i], bins[i + 1] |
|
|
mask = (duration_array >= start) & (duration_array < end) |
|
|
values_in_bin = clipping_array[mask] |
|
|
values_in_bin = values_in_bin[~np.isnan(values_in_bin)] |
|
|
|
|
|
avg_clip = float(np.mean(values_in_bin)) if len(values_in_bin) > 0 else None |
|
|
|
|
|
key = f"{start}-{end}" |
|
|
clipping_per_bin[key] = avg_clip |
|
|
x_labels.append(key) |
|
|
|
|
|
|
|
|
with open("clipping_percentage_per_duration10-15_bin.json", "w") as f: |
|
|
json.dump(clipping_per_bin, f, indent=2) |
|
|
|
|
|
|
|
|
heights = [clipping_per_bin[label] if clipping_per_bin[label] is not None else 0 for label in x_labels] |
|
|
|
|
|
plt.figure(figsize=(10, 6)) |
|
|
plt.bar(x_labels, heights, color='teal', edgecolor='black') |
|
|
plt.xlabel("Duration Bin (s)") |
|
|
plt.ylabel("Average Clipping Percentage") |
|
|
plt.title("Average Clipping Percentage per Duration Bin") |
|
|
plt.xticks(rotation=45) |
|
|
plt.tight_layout() |
|
|
|
|
|
plt.savefig("/home/sidd/Desktop/work/IME DATASET REVIEW/Avg_clipping_percentage/clipping_Percent_histogram10-15.jpg") |
|
|
plt.show() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import numpy as np |
|
|
import matplotlib.pyplot as plt |
|
|
import json |
|
|
|
|
|
|
|
|
min_duration = 15 |
|
|
max_duration = 20 |
|
|
bin_width = 0.5 |
|
|
bins = np.arange(min_duration, max_duration + bin_width, bin_width) |
|
|
|
|
|
|
|
|
clipping_array = np.array([ |
|
|
float(x) if isinstance(x, (float, int)) and x is not None else np.nan |
|
|
for x in clipping_percentage |
|
|
], dtype=np.float32) |
|
|
|
|
|
duration_array = np.array([ |
|
|
float(x) if isinstance(x, (float, int)) and x is not None else np.nan |
|
|
for x in duration_values |
|
|
], dtype=np.float32) |
|
|
|
|
|
|
|
|
clipping_per_bin = {} |
|
|
x_labels = [] |
|
|
|
|
|
for i in range(len(bins) - 1): |
|
|
start, end = bins[i], bins[i + 1] |
|
|
mask = (duration_array >= start) & (duration_array < end) |
|
|
values_in_bin = clipping_array[mask] |
|
|
values_in_bin = values_in_bin[~np.isnan(values_in_bin)] |
|
|
|
|
|
avg_clip = float(np.mean(values_in_bin)) if len(values_in_bin) > 0 else None |
|
|
|
|
|
key = f"{start}-{end}" |
|
|
clipping_per_bin[key] = avg_clip |
|
|
x_labels.append(key) |
|
|
|
|
|
|
|
|
with open("clipping_percentage_per_duration15-20_bin.json", "w") as f: |
|
|
json.dump(clipping_per_bin, f, indent=2) |
|
|
|
|
|
|
|
|
heights = [clipping_per_bin[label] if clipping_per_bin[label] is not None else 0 for label in x_labels] |
|
|
|
|
|
plt.figure(figsize=(10, 6)) |
|
|
plt.bar(x_labels, heights, color='teal', edgecolor='black') |
|
|
plt.xlabel("Duration Bin (s)") |
|
|
plt.ylabel("Average Clipping Percentage") |
|
|
plt.title("Average Clipping Percentage per Duration Bin") |
|
|
plt.xticks(rotation=45) |
|
|
plt.tight_layout() |
|
|
|
|
|
plt.savefig("/home/sidd/Desktop/work/IME DATASET REVIEW/Avg_clipping_percentage/clipping_Percent_histogram15-20.jpg") |
|
|
plt.show() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import numpy as np |
|
|
import matplotlib.pyplot as plt |
|
|
import json |
|
|
|
|
|
|
|
|
min_duration = 20 |
|
|
max_duration = 25 |
|
|
bin_width = 0.5 |
|
|
bins = np.arange(min_duration, max_duration + bin_width, bin_width) |
|
|
|
|
|
|
|
|
clipping_array = np.array([ |
|
|
float(x) if isinstance(x, (float, int)) and x is not None else np.nan |
|
|
for x in clipping_percentage |
|
|
], dtype=np.float32) |
|
|
|
|
|
duration_array = np.array([ |
|
|
float(x) if isinstance(x, (float, int)) and x is not None else np.nan |
|
|
for x in duration_values |
|
|
], dtype=np.float32) |
|
|
|
|
|
|
|
|
clipping_per_bin = {} |
|
|
x_labels = [] |
|
|
|
|
|
for i in range(len(bins) - 1): |
|
|
start, end = bins[i], bins[i + 1] |
|
|
mask = (duration_array >= start) & (duration_array < end) |
|
|
values_in_bin = clipping_array[mask] |
|
|
values_in_bin = values_in_bin[~np.isnan(values_in_bin)] |
|
|
|
|
|
avg_clip = float(np.mean(values_in_bin)) if len(values_in_bin) > 0 else None |
|
|
|
|
|
key = f"{start}-{end}" |
|
|
clipping_per_bin[key] = avg_clip |
|
|
x_labels.append(key) |
|
|
|
|
|
|
|
|
with open("clipping_percentage_per_duration20-25_bin.json", "w") as f: |
|
|
json.dump(clipping_per_bin, f, indent=2) |
|
|
|
|
|
|
|
|
heights = [clipping_per_bin[label] if clipping_per_bin[label] is not None else 0 for label in x_labels] |
|
|
|
|
|
plt.figure(figsize=(10, 6)) |
|
|
plt.bar(x_labels, heights, color='teal', edgecolor='black') |
|
|
plt.xlabel("Duration Bin (s)") |
|
|
plt.ylabel("Average Clipping Percentage") |
|
|
plt.title("Average Clipping Percentage per Duration Bin") |
|
|
plt.xticks(rotation=45) |
|
|
plt.tight_layout() |
|
|
|
|
|
plt.savefig("/home/sidd/Desktop/work/IME DATASET REVIEW/Avg_clipping_percentage/clipping_Percent_histogram20-25.jpg") |
|
|
plt.show() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import numpy as np |
|
|
import matplotlib.pyplot as plt |
|
|
import json |
|
|
|
|
|
|
|
|
min_duration = 25 |
|
|
max_duration = 30 |
|
|
bin_width = 0.5 |
|
|
bins = np.arange(min_duration, max_duration + bin_width, bin_width) |
|
|
|
|
|
|
|
|
clipping_array = np.array([ |
|
|
float(x) if isinstance(x, (float, int)) and x is not None else np.nan |
|
|
for x in clipping_percentage |
|
|
], dtype=np.float32) |
|
|
|
|
|
duration_array = np.array([ |
|
|
float(x) if isinstance(x, (float, int)) and x is not None else np.nan |
|
|
for x in duration_values |
|
|
], dtype=np.float32) |
|
|
|
|
|
|
|
|
clipping_per_bin = {} |
|
|
x_labels = [] |
|
|
|
|
|
for i in range(len(bins) - 1): |
|
|
start, end = bins[i], bins[i + 1] |
|
|
mask = (duration_array >= start) & (duration_array < end) |
|
|
values_in_bin = clipping_array[mask] |
|
|
values_in_bin = values_in_bin[~np.isnan(values_in_bin)] |
|
|
|
|
|
avg_clip = float(np.mean(values_in_bin)) if len(values_in_bin) > 0 else None |
|
|
|
|
|
key = f"{start}-{end}" |
|
|
clipping_per_bin[key] = avg_clip |
|
|
x_labels.append(key) |
|
|
|
|
|
|
|
|
with open("clipping_percentage_per_duration25-30bin.json", "w") as f: |
|
|
json.dump(clipping_per_bin, f, indent=2) |
|
|
|
|
|
|
|
|
heights = [clipping_per_bin[label] if clipping_per_bin[label] is not None else 0 for label in x_labels] |
|
|
|
|
|
plt.figure(figsize=(10, 6)) |
|
|
plt.bar(x_labels, heights, color='teal', edgecolor='black') |
|
|
plt.xlabel("Duration Bin (s)") |
|
|
plt.ylabel("Average Clipping Percentage") |
|
|
plt.title("Average Clipping Percentage per Duration Bin") |
|
|
plt.xticks(rotation=45) |
|
|
plt.tight_layout() |
|
|
|
|
|
plt.savefig("/home/sidd/Desktop/work/IME DATASET REVIEW/Avg_clipping_percentage/clipping_Percent_histogram25-30.jpg") |
|
|
plt.show() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import numpy as np |
|
|
import matplotlib.pyplot as plt |
|
|
import json |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
durations = [] |
|
|
speaker_counts = [] |
|
|
|
|
|
|
|
|
|
|
|
try: |
|
|
|
|
|
audio_features = data['audio_features'] |
|
|
|
|
|
|
|
|
if isinstance(audio_features, list): |
|
|
for features in audio_features: |
|
|
if features is not None: |
|
|
duration = features.get('duration') |
|
|
speaker_count = features.get('speaker_count') |
|
|
if duration is not None and speaker_count is not None: |
|
|
durations.append(duration) |
|
|
speaker_counts.append(speaker_count) |
|
|
else: |
|
|
|
|
|
for i in range(len(data)): |
|
|
features = data[i]['audio_features'] |
|
|
if features is not None: |
|
|
duration = features.get('duration') |
|
|
speaker_count = features.get('speaker_count') |
|
|
if duration is not None and speaker_count is not None: |
|
|
durations.append(duration) |
|
|
speaker_counts.append(speaker_count) |
|
|
except Exception as e: |
|
|
print(f"Error accessing dataset: {e}") |
|
|
|
|
|
|
|
|
print("Trying alternative approach...") |
|
|
|
|
|
|
|
|
if isinstance(data, list): |
|
|
for item in data: |
|
|
if isinstance(item, dict) and 'duration' in item and 'speaker_count' in item: |
|
|
duration = item.get('duration') |
|
|
speaker_count = item.get('speaker_count') |
|
|
if duration is not None and speaker_count is not None: |
|
|
durations.append(duration) |
|
|
speaker_counts.append(speaker_count) |
|
|
|
|
|
|
|
|
duration_array = np.array(durations) |
|
|
speaker_count_array = np.array(speaker_counts) |
|
|
|
|
|
|
|
|
print(f"Duration array shape: {duration_array.shape}") |
|
|
print(f"Speaker count array shape: {speaker_count_array.shape}") |
|
|
if len(durations) > 0: |
|
|
print(f"Duration range: {np.min(duration_array):.2f} to {np.max(duration_array):.2f} seconds") |
|
|
print(f"Speaker count range: {np.min(speaker_count_array)} to {np.max(speaker_count_array)} speakers") |
|
|
else: |
|
|
print("No valid data extracted!") |
|
|
|
|
|
|
|
|
|
|
|
min_duration = 0 |
|
|
max_duration = 5 |
|
|
bin_width = 0.5 |
|
|
bins = np.arange(min_duration, max_duration + bin_width, bin_width) |
|
|
|
|
|
|
|
|
speaker_per_bin = {} |
|
|
x_labels = [] |
|
|
y_values = [] |
|
|
|
|
|
for i in range(len(bins) - 1): |
|
|
mask = (duration_array >= bins[i]) & (duration_array < bins[i+1]) |
|
|
|
|
|
count = np.sum(mask) |
|
|
key = f"{bins[i]}-{bins[i+1]}" |
|
|
speaker_per_bin[key] = int(count) |
|
|
x_labels.append(key) |
|
|
y_values.append(count) |
|
|
|
|
|
|
|
|
print(f"Bin {key}: {count} audio files") |
|
|
|
|
|
|
|
|
with open("speaker_count_per_duration_bin0-5.json", "w") as f: |
|
|
json.dump(speaker_per_bin, f, indent=2) |
|
|
|
|
|
|
|
|
if sum(y_values) > 0: |
|
|
plt.figure(figsize=(10, 6)) |
|
|
plt.bar(x_labels, y_values, color='orange', edgecolor='black') |
|
|
plt.xticks(rotation=45) |
|
|
plt.xlabel("Duration Bin (s)") |
|
|
plt.ylabel("Count") |
|
|
plt.title("Number of Audio Files per Duration Bin") |
|
|
plt.grid(axis='y') |
|
|
plt.tight_layout() |
|
|
plt.savefig("/home/sidd/Desktop/work/IME DATASET REVIEW/audio_duration/SpeakerCountPerDurationBin0-5.jpg") |
|
|
plt.show() |
|
|
else: |
|
|
print("No data found in the specified duration range! Try adjusting your min_duration and max_duration.") |
|
|
|
|
|
|
|
|
print("\nAnalyzing your actual data distribution...") |
|
|
actual_min = np.min(duration_array) |
|
|
actual_max = np.max(duration_array) |
|
|
print(f"Your data ranges from {actual_min:.2f} to {actual_max:.2f} seconds") |
|
|
|
|
|
|
|
|
hist, bin_edges = np.histogram(duration_array, bins=10) |
|
|
print("Top duration ranges in your data:") |
|
|
for i in range(len(hist)): |
|
|
if hist[i] > 0: |
|
|
print(f"{bin_edges[i]:.2f}-{bin_edges[i+1]:.2f} seconds: {hist[i]} samples") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import numpy as np |
|
|
import matplotlib.pyplot as plt |
|
|
import json |
|
|
import os |
|
|
|
|
|
|
|
|
output_dir = "/home/sidd/Desktop/work/IME DATASET REVIEW/audio_duration" |
|
|
os.makedirs(output_dir, exist_ok=True) |
|
|
|
|
|
|
|
|
duration_ranges = [ |
|
|
(5, 10), |
|
|
(10, 15), |
|
|
(15, 20), |
|
|
(20, 25), |
|
|
(25, 30) |
|
|
] |
|
|
|
|
|
|
|
|
durations = [] |
|
|
speaker_counts = [] |
|
|
|
|
|
|
|
|
try: |
|
|
|
|
|
audio_features = data['audio_features'] |
|
|
|
|
|
if isinstance(audio_features, list): |
|
|
for features in audio_features: |
|
|
if features is not None: |
|
|
duration = features.get('duration') |
|
|
speaker_count = features.get('speaker_count') |
|
|
if duration is not None and speaker_count is not None: |
|
|
durations.append(duration) |
|
|
speaker_counts.append(speaker_count) |
|
|
else: |
|
|
|
|
|
for i in range(len(data)): |
|
|
features = data[i]['audio_features'] |
|
|
if features is not None: |
|
|
duration = features.get('duration') |
|
|
speaker_count = features.get('speaker_count') |
|
|
if duration is not None and speaker_count is not None: |
|
|
durations.append(duration) |
|
|
speaker_counts.append(speaker_count) |
|
|
except Exception as e: |
|
|
print(f"Error accessing dataset: {e}") |
|
|
|
|
|
|
|
|
print("Trying alternative approach...") |
|
|
|
|
|
|
|
|
if isinstance(data, list): |
|
|
for item in data: |
|
|
if isinstance(item, dict) and 'duration' in item and 'speaker_count' in item: |
|
|
duration = item.get('duration') |
|
|
speaker_count = item.get('speaker_count') |
|
|
if duration is not None and speaker_count is not None: |
|
|
durations.append(duration) |
|
|
speaker_counts.append(speaker_count) |
|
|
|
|
|
|
|
|
duration_array = np.array(durations) |
|
|
speaker_count_array = np.array(speaker_counts) |
|
|
|
|
|
|
|
|
print(f"Total data points extracted: {len(durations)}") |
|
|
if len(durations) > 0: |
|
|
print(f"Overall duration range: {np.min(duration_array):.2f} to {np.max(duration_array):.2f} seconds") |
|
|
print(f"Overall speaker count range: {np.min(speaker_count_array)} to {np.max(speaker_count_array)} speakers") |
|
|
else: |
|
|
print("No valid data extracted!") |
|
|
exit() |
|
|
|
|
|
|
|
|
for min_duration, max_duration in duration_ranges: |
|
|
print(f"\nProcessing duration range {min_duration}-{max_duration} seconds...") |
|
|
|
|
|
|
|
|
range_mask = (duration_array >= min_duration) & (duration_array < max_duration) |
|
|
range_count = np.sum(range_mask) |
|
|
|
|
|
print(f"Found {range_count} audio files in this range") |
|
|
|
|
|
|
|
|
if range_count == 0: |
|
|
print(f"No data in the {min_duration}-{max_duration} second range, skipping...") |
|
|
continue |
|
|
|
|
|
|
|
|
bin_width = 0.5 |
|
|
bins = np.arange(min_duration, max_duration + bin_width, bin_width) |
|
|
|
|
|
|
|
|
speaker_per_bin = {} |
|
|
x_labels = [] |
|
|
y_values = [] |
|
|
|
|
|
for i in range(len(bins) - 1): |
|
|
mask = (duration_array >= bins[i]) & (duration_array < bins[i+1]) |
|
|
|
|
|
count = np.sum(mask) |
|
|
key = f"{bins[i]}-{bins[i+1]}" |
|
|
speaker_per_bin[key] = int(count) |
|
|
x_labels.append(key) |
|
|
y_values.append(count) |
|
|
|
|
|
|
|
|
print(f"Bin {key}: {count} audio files") |
|
|
|
|
|
|
|
|
json_filename = f"speaker_count_per_duration_bin{min_duration}-{max_duration}.json" |
|
|
json_path = os.path.join(output_dir, json_filename) |
|
|
with open(json_path, "w") as f: |
|
|
json.dump(speaker_per_bin, f, indent=2) |
|
|
print(f"Saved results to {json_path}") |
|
|
|
|
|
|
|
|
plt.figure(figsize=(12, 6)) |
|
|
plt.bar(x_labels, y_values, color='orange', edgecolor='black') |
|
|
plt.xticks(rotation=90) |
|
|
plt.xlabel("Duration Bin (s)") |
|
|
plt.ylabel("Count") |
|
|
plt.title(f"Number of Audio Files per Duration Bin ({min_duration}-{max_duration}s)") |
|
|
plt.grid(axis='y') |
|
|
plt.tight_layout() |
|
|
|
|
|
|
|
|
plot_filename = f"SpeakerCountPerDurationBin{min_duration}-{max_duration}.jpg" |
|
|
plot_path = os.path.join(output_dir, plot_filename) |
|
|
plt.savefig(plot_path) |
|
|
print(f"Saved plot to {plot_path}") |
|
|
plt.close() |
|
|
|
|
|
print("\nAll duration ranges processed!") |
|
|
|
|
|
|
|
|
range_counts = [] |
|
|
range_labels = [] |
|
|
|
|
|
for min_duration, max_duration in duration_ranges: |
|
|
range_mask = (duration_array >= min_duration) & (duration_array < max_duration) |
|
|
range_count = np.sum(range_mask) |
|
|
range_counts.append(range_count) |
|
|
range_labels.append(f"{min_duration}-{max_duration}s") |
|
|
|
|
|
|
|
|
plt.figure(figsize=(10, 6)) |
|
|
plt.bar(range_labels, range_counts, color='blue', edgecolor='black') |
|
|
plt.xlabel("Duration Range (seconds)") |
|
|
plt.ylabel("Number of Audio Files") |
|
|
plt.title("Distribution of Audio Files Across Duration Ranges") |
|
|
plt.grid(axis='y') |
|
|
plt.tight_layout() |
|
|
|
|
|
|
|
|
summary_path = os.path.join(output_dir, "DurationRangeSummary.jpg") |
|
|
plt.savefig(summary_path) |
|
|
print(f"Saved summary plot to {summary_path}") |
|
|
plt.close() |
|
|
|
|
|
print("All processing completed successfully!") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|