Skip to content

Commit fec1cd3

Browse files
authored
Merge pull request #2124 from MTG/bst-improvements
Broad Sound Taoxnomy improvements
2 parents 1363980 + d2c2ec6 commit fec1cd3

11 files changed

Lines changed: 203 additions & 195 deletions

File tree

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
class_key,class_key_long,top_level,second_level,description,examples
2+
m,M,Music,,"Music excerpts, including melodies, singing, loops, fillers, drones, and short musical snippets.",
3+
m-sp,M/Solo-perc.,Music,Solo percussion,Music excerpts with solo percussive instruments.,"rhythmic patterns, unpitched percussion excerpt, drum passage, drum loop"
4+
m-si,M/Solo-instr.,Music,Solo instrument,"Music excerpts with only one instrument, excluding percussion.","isolated melody or sequence of notes, solo singing, chords from one instrument"
5+
m-m,M/Multi,Music,Multiple instruments,Music excerpts with more than one instrument.,"orchestra, band, duet, multi-instrument composition or loop"
6+
m-other,M/Other,Music,Other,Music that doesn't belong to any of the above categories.,
7+
is,Is,Instrument samples,,"Single notes from musical instruments, various versions of the same note, and scales.",
8+
is-p,Is/Perc.,Instrument samples,Percussion,Instrument samples that are percussive (idiophones or membraphones).,"drum, snare, gong, bell, xylophone"
9+
is-s,Is/String,Instrument samples,String,Instrument samples that belong to the string instrument family.,"guitar, violin, harp, mandolin"
10+
is-w,Is/Wind,Instrument samples,Wind,Instrument samples that belong to the wind instrument family (aerophones).,"woodwind, brass, flute, trumpet, saxophone"
11+
is-k,Is/Keyb.,Instrument samples,Piano / Keyboard instruments,"Instrument samples of piano or other keyboard instruments, not synthesized.","piano, harspichord, organ"
12+
is-e,Is/Electr.,Instrument samples,Synths / Electronic,Instrument samples synthesized or produced by electronic means.,"synthesizers (analog/digital), synthesized or electronic samples"
13+
is-other,Is/Other,Instrument samples,Other,Instrument samples that don't belong to any of the above categories.,
14+
sp,Sp,Speech,,Sounds where human voice is prominent.,
15+
sp-s,Sp/Solo,Speech,Solo speech,"Recording of a single voice speaking, excluding singing.","talking, script reading"
16+
sp-c,Sp/Crowd,Speech,Conversation / Crowd,"Several people talking, having a conversation or dialogue.","playground, people talking in public places, conversations"
17+
sp-p,Sp/Proc.,Speech,Processed / Synthetic,"Voice(s) from an indirect source (e.g. radio), heavily processed, or synthesized.","phone/radio recordings, robotic voice, text-to-speech"
18+
sp-other,Sp/Other,Speech,Other,Voice-predominant recordings that don't belong to any of the above categories.,
19+
fx,Fx,Sound effects,,"Isolated sound effects or sound events, each happening one at a time.",
20+
fx-o,Fx/Objects,Sound effects,Objects / House appliances,"Everyday objects, inside the home or smaller in size.","daily or small objects, tools, weapons, clothes, iron"
21+
fx-v,Fx/Vehicles,Sound effects,Vehicles,Sounds produced from a vehicle.,"car passing by, car screeching, wiper, car break, bike, plane, ship"
22+
fx-m,Fx/Machines,Sound effects,"Other mechanisms, engines, machines","Machine-like sounds, except vehicles and small house electric devices.","drill, lawn mower, gear, electric chainsaw"
23+
fx-h,Fx/Human,Sound effects,Human sounds and actions,"Sounds from the human body, excluding speech.","breath, heartbeat, sneeze, crying, walking, clapping"
24+
fx-a,Fx/Animals,Sound effects,Animals,Animal vocalizations or sounds.,"cat, insect, sheep, animal walk, growl, purr"
25+
fx-n,Fx/Natural,Sound effects,Natural elements and explosions,Sound events occuring by natural processes.,"single gusts of wind, fire flames, ice cracks, rocks, water splash, stones, explosions"
26+
fx-ex,Fx/Exper.,Sound effects,Experimental,Experimental sounds or heavily processed audio recordings.,"reversed sounds, weird effects, unusual record techniques or processing"
27+
fx-el,Fx/Electr.,Sound effects,Electronic / Design,Sound effects that are computer-made or designed for user interfaces or animations.,"sci-fi, laser, whoosh, boink, cartoon, ui, sound alerts or notifications"
28+
fx-other,Fx/Other,Sound effects,Other,Sound effects that don't belong to any of the above categories.,
29+
ss,Ss,Soundscapes,,"Ambiances, field-recordings with multiple events and sound environments.",
30+
ss-n,Ss/Nature,Soundscapes,Nature,Soundscapes from natural habitats.,"forest ambiance, seaside, river with surrounding nature, farmland"
31+
ss-i,Ss/Indoors,Soundscapes,Indoors,Soundscapes from closed or indoor spaces.,"closed room ambience, room tone, office, factory, bar"
32+
ss-u,Ss/Urban,Soundscapes,Urban,Soundscapes from cityscapes or outdoor places with human intervention.,"city ambience, outside airport, busy road"
33+
ss-s,Ss/Synth.,Soundscapes,Synthetic / Artificial,Soundscapes that are synthesized or computer-made ambiences.,"artificially-created soundscapes, soundscapes from imaginary places"
34+
ss-other,Ss/Other,Soundscapes,Other,Soundscapes that don't belong to any of the above categories.,

freesound/settings.py

Lines changed: 27 additions & 188 deletions
Original file line numberDiff line numberDiff line change
@@ -417,194 +417,33 @@
417417
ANNOUNCEMENT_CACHE_KEY = "announcement_cache"
418418

419419
# -------------------------------------------------------------------------------
420-
# Broad Sound Taxonomy definition (internal v1.1 of BST description)
421-
422-
BROAD_SOUND_TAXONOMY = {
423-
"m": {
424-
"level": 1,
425-
"name": "Music",
426-
"description": "Music excerpts, including melodies, singing, loops, fillers, drones and short musical snippets.",
427-
},
428-
"m-sp": {
429-
"level": 2,
430-
"name": "Solo percussion",
431-
"description": "Music excerpts with solo percussive instruments.",
432-
"examples": "rhythmic patterns, unpitched percussion excerpts, drum passages",
433-
},
434-
"m-si": {
435-
"level": 2,
436-
"name": "Solo instrument",
437-
"description": "Music excerpts with only one instrument, excluding percussion.",
438-
"examples": "isolated melody or sequence of notes, solo singing, chords from one instrument",
439-
},
440-
"m-m": {
441-
"level": 2,
442-
"name": "Multiple instruments",
443-
"description": "Music excerpts with more than one instrument.",
444-
"examples": "orchestra, band, dueto, multi-instrument composition, multi-instrument loops",
445-
},
446-
"m-other": {
447-
"level": 2,
448-
"name": "Other",
449-
"description": "Music that doesn't belong to any of the above categories.",
450-
},
451-
"is": {
452-
"level": 1,
453-
"name": "Instrument samples",
454-
"description": "Single notes from musical instruments, various versions of the same note, and scales.",
455-
},
456-
"is-p": {
457-
"level": 2,
458-
"name": "Percussion",
459-
"description": "Instrument samples that are percussive (idiophones or membraphones).",
460-
"examples": "drum, snare, gong, bell, xylophone",
461-
},
462-
"is-s": {
463-
"level": 2,
464-
"name": "String",
465-
"description": "Instrument samples that belong to the string instrument family.",
466-
"examples": "guitar, violin, harp, mandolin",
467-
},
468-
"is-w": {
469-
"level": 2,
470-
"name": "Wind",
471-
"description": "Instrument samples that belong to the wind instrument family (aerophones).",
472-
"examples": "woodwind, brass, flute, trumpet, saxophone",
473-
},
474-
"is-k": {
475-
"level": 2,
476-
"name": "Piano / Keyboard instruments",
477-
"description": "Instrument samples of piano or other keyboard instruments, not synthesized.",
478-
"examples": "piano, harspichord, organ",
479-
},
480-
"is-e": {
481-
"level": 2,
482-
"name": "Synths / Electronic",
483-
"description": "Instrument samples synthesized or produced by electronic means.",
484-
"examples": "synthesizers (analog/digital), synthesized or electronic samples",
485-
},
486-
"is-other": {
487-
"level": 2,
488-
"name": "Other",
489-
"description": "Instrument samples that don't belong to any of the above categories.",
490-
},
491-
"sp": {"level": 1, "name": "Speech", "description": "Sounds where human voice is prominent."},
492-
"sp-s": {
493-
"level": 2,
494-
"name": "Solo speech",
495-
"description": "Recording of a single voice speaking, excluding singing.",
496-
"examples": "talking, script reading",
497-
},
498-
"sp-c": {
499-
"level": 2,
500-
"name": "Conversation / Crowd",
501-
"description": "Several people talking, having a conversation or dialogue.",
502-
"examples": "playground, people talking in public places, conversations",
503-
},
504-
"sp-p": {
505-
"level": 2,
506-
"name": "Processed / Synthetic",
507-
"description": "Voice(s) from an indirect source (e.g. radio), heavily processed, or synthesized.",
508-
"examples": "phone/radio recordings, robotic voice, text-to-speech",
509-
},
510-
"sp-other": {
511-
"level": 2,
512-
"name": "Other",
513-
"description": "Voice-predominant recordings that don't belong to any of the above categories.",
514-
},
515-
"fx": {
516-
"level": 1,
517-
"name": "Sound effects",
518-
"description": "Isolated sound effects or sound events, each happening one at a time.",
519-
},
520-
"fx-o": {
521-
"level": 2,
522-
"name": "Objects / House appliances",
523-
"description": "Everyday objects, inside the home or smaller in size.",
524-
"examples": "daily or small objects, tools, weapons, clothes, iron",
525-
},
526-
"fx-v": {
527-
"level": 2,
528-
"name": "Vehicles",
529-
"description": "Sounds produced from a vehicle.",
530-
"examples": "car passing by, car screeching, wiper, car brake, bike, plane, ship",
531-
},
532-
"fx-m": {
533-
"level": 2,
534-
"name": "Other mechanisms, engines, machines",
535-
"description": "Machine-like sounds, except vehicles and small house electric devices.",
536-
"examples": "drill, lawn mower, gear, electric chainsaw",
537-
},
538-
"fx-h": {
539-
"level": 2,
540-
"name": "Human sounds and actions",
541-
"description": "Sounds from the human body, excluding speech.",
542-
"examples": "breath, hearthbeat, sneeze, crying, walking, clapping",
543-
},
544-
"fx-a": {
545-
"level": 2,
546-
"name": "Animals",
547-
"description": "Animal vocalizations or sounds.",
548-
"examples": "cat, insect, sheep, animal walk, growl, purr",
549-
},
550-
"fx-n": {
551-
"level": 2,
552-
"name": "Natural elements and explosions",
553-
"description": "Sound events occurring by natural processes.",
554-
"examples": "wind, fire, ice, rocks, water, stones, explosions",
555-
},
556-
"fx-ex": {
557-
"level": 2,
558-
"name": "Experimental",
559-
"description": "Experimental sounds or heavily processed audio recordings.",
560-
"examples": "reversed sounds, weird effects, unusual recording techniques or processing",
561-
},
562-
"fx-el": {
563-
"level": 2,
564-
"name": "Electronic / Design",
565-
"description": "Sound effects that are computer-made or designed for user interfaces or animations.",
566-
"examples": "sci-fi, laser, whoosh, boink, cartoon, ui, sound alerts or notifications",
567-
},
568-
"fx-other": {
569-
"level": 2,
570-
"name": "Other",
571-
"description": "Sound effects that don't belong to any of the above categories.",
572-
},
573-
"ss": {
574-
"level": 1,
575-
"name": "Soundscapes",
576-
"description": "Ambiances, field-recordings with multiple events and sound environments.",
577-
},
578-
"ss-n": {
579-
"level": 2,
580-
"name": "Nature",
581-
"description": "Soundscapes from natural habitats.",
582-
"examples": "forest ambiance, seaside, river with surrounding nature, farmland",
583-
},
584-
"ss-i": {
585-
"level": 2,
586-
"name": "Indoors",
587-
"description": "Soundscapes from closed or indoor spaces.",
588-
"examples": "closed room ambience, room tone, office, factory, bar",
589-
},
590-
"ss-u": {
591-
"level": 2,
592-
"name": "Urban",
593-
"description": "Soundscapes from cityscapes or outdoor places with human intervention.",
594-
"examples": "city ambience, outside airport, busy road",
595-
},
596-
"ss-s": {
597-
"level": 2,
598-
"name": "Synthetic / Artificial",
599-
"description": "Soundscapes that are synthesized or computer-made ambiences.",
600-
"examples": "artificially-created soundscapes, soundscapes from imaginary places",
601-
},
602-
"ss-other": {
603-
"level": 2,
604-
"name": "Other",
605-
"description": "Soundscapes that don't belong to any of the above categories.",
606-
},
607-
}
420+
# Broad Sound Taxonomy definition
421+
422+
423+
def load_broad_sound_taxonomy_from_csv(path):
424+
import csv
425+
426+
taxonomy = {}
427+
with open(path, newline="", encoding="utf-8") as csvfile:
428+
reader = csv.DictReader(csvfile)
429+
for row in reader:
430+
key = row["class_key"]
431+
taxonomy[key] = {
432+
"level": 2 if "-" in key else 1,
433+
"name": row["second_level"] if "-" in key else row["top_level"],
434+
"top_level": row["top_level"],
435+
"second_level": row["second_level"],
436+
"description": row["description"],
437+
"examples": row.get("examples", ""),
438+
}
439+
return taxonomy
440+
441+
442+
BROAD_SOUND_TAXONOMY_CSV_FILENAME = "bst_description_v1.1_250725.csv"
443+
BROAD_SOUND_TAXONOMY_CSV_DEFINITION_PATH = os.path.join(
444+
os.path.dirname(__file__), "../_docs/", BROAD_SOUND_TAXONOMY_CSV_FILENAME
445+
)
446+
BROAD_SOUND_TAXONOMY = load_broad_sound_taxonomy_from_csv(BROAD_SOUND_TAXONOMY_CSV_DEFINITION_PATH)
608447

609448
BST_CATEGORY_CHOICES = [
610449
(key, value["name"]) for key, value in BROAD_SOUND_TAXONOMY.items() if "-" not in key

freesound/static/bw-frontend/styles/pages/index.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@
1212
@import 'upload';
1313
@import 'bulkDescribe';
1414
@import 'moderation';
15+
@import 'taxonomy';
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
.bst-taxonomy{
2+
.node {
3+
4+
padding: 5px;
5+
border-radius: 5px;
6+
margin: 5px;
7+
text-align: center;
8+
9+
&.topcat {
10+
color: white;
11+
font-weight: bold;
12+
font-size: 120%;
13+
padding: 10px;
14+
15+
}
16+
17+
&.subcat {
18+
position: relative;
19+
overflow: hidden;
20+
color: black;
21+
22+
// Apply brightness only to a background layer, not to text.
23+
&::before {
24+
content: "";
25+
position: absolute;
26+
inset: 0;
27+
background-color: inherit;
28+
border-radius: inherit;
29+
filter: brightness(160%);
30+
pointer-events: none;
31+
}
32+
33+
.label {
34+
position: relative;
35+
z-index: 1;
36+
}
37+
}
38+
}
39+
}
40+

freesound/urls.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@
136136
),
137137
path("", include("ratings.urls")),
138138
path("comments/", include("comments.urls")),
139+
path("help/broad-sound-taxonomy/", sounds.views.broad_sound_taxonomy_info_page, name="bst-info-page"),
139140
path("help/", include("wiki.urls")),
140141
path("forum/", include("forum.urls")),
141142
path("geotags/", include("geotags.urls")),

general/templatetags/util.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,11 @@ def element_at_index(l, index):
119119
return l[index]
120120

121121

122+
@register.filter
123+
def dict_element(d, key):
124+
return d[key]
125+
126+
122127
@register.filter
123128
def strip_unnecessary_br(value):
124129
# In HTMLCleaningFields some HTML tags are allowed. When the contents of these fields are passed to Django's |linebreaks

sounds/forms.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ class SoundEditAndDescribeForm(forms.Form):
274274
bst_category = forms.ChoiceField(
275275
choices=settings.BST_SUBCATEGORY_CHOICES,
276276
help_text="Choose the most appropriate <i>Category</i> and <i>Subcategory</i> for the sound. "
277-
'These categories come from the <a class="bw-link--grey" href="/help/faq/#the-broad-sound-taxonomy">Broad Sound Taxonomy</a>, '
277+
'These categories come from the <a class="bw-link--grey" href="/help/broad-sound-taxonomy">Broad Sound Taxonomy</a>, '
278278
"and are used to improve Freesound search capabilities.",
279279
error_messages={"invalid_choice": "Please select a valid category and a subcategory."},
280280
required=True,

sounds/templatetags/bst_category.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,7 @@ def bst_taxonomy_category_names_to_category_key(top_level_name, second_level_nam
7171
@register.filter
7272
def get_bst_taxonomy_top_level_category_key(value):
7373
"""
74-
Extract the top level category key from the given value.
75-
The top level category is the part before the '-' in value.
74+
Extract the top level category key from the given value. The top level category is the part before the '-' in value.
7675
E.g.: "m-sp" -> "m"
7776
"""
7877
return value.split("-")[0] if "-" in value else value
@@ -81,7 +80,10 @@ def get_bst_taxonomy_top_level_category_key(value):
8180
@register.filter
8281
def get_bst_taxonomy_description(value):
8382
"""
84-
Return BST taxonomy class description for a given taxonomy
85-
cateogory/subcategory key.
83+
Return BST taxonomy class description for a given taxonomy category/subcategory key.
8684
"""
87-
return settings.BROAD_SOUND_TAXONOMY[value]["description"]
85+
bst_node_data = settings.BROAD_SOUND_TAXONOMY[value]
86+
if bst_node_data["examples"]:
87+
return f'{bst_node_data["description"]} <span class="text-light-grey">E.g. {bst_node_data["examples"]}.</span>'
88+
else:
89+
return bst_node_data["description"]

sounds/views.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1279,3 +1279,24 @@ def pack_downloaders(request, username, pack_id):
12791279
tvars = {"username": username, "pack": pack, "download_list": download_list}
12801280
tvars.update(pagination)
12811281
return render(request, "sounds/modal_downloaders.html", tvars)
1282+
1283+
1284+
def broad_sound_taxonomy_info_page(request):
1285+
# Note: the colors below are currently hard-coded here, but in the future they should be
1286+
# added to the CSV file that defines the taxonomy and loaded from there.
1287+
taxonomy_node_colors = {
1288+
"m": "rgb(228,34,30)",
1289+
"is": "rgb(249,164,48)",
1290+
"sp": "rgb(39,161,132)",
1291+
"fx": "rgb(20,107,173)",
1292+
"ss": "rgb(50,167,40)",
1293+
}
1294+
taxonomy = settings.BROAD_SOUND_TAXONOMY
1295+
for key, node in taxonomy.items():
1296+
if key in taxonomy_node_colors:
1297+
node["color"] = taxonomy_node_colors[key]
1298+
tvars = {
1299+
"bst": taxonomy,
1300+
"bst_top_level_categories": settings.BST_CATEGORY_CHOICES,
1301+
}
1302+
return render(request, "sounds/broad_sound_taxonomy_info_page.html", tvars)

templates/molecules/bst_category_form_field.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
{% for value, label in form.fields.bst_category.choices %}
2222
<button type="button" class="btn no-hover {% if value == form.bst_category.value %}btn-primary{% else %}btn-inverse{% endif %} btn-subcategory tooltip_top" top_level="{{ value|get_bst_taxonomy_top_level_category_key }}" data_value="{{ value }}">
2323
{{ label }}
24-
<span class="tooltiptext">{{ value|get_bst_taxonomy_description }}</span>
24+
<span class="tooltiptext">{{ value|get_bst_taxonomy_description|safe }}</span>
2525
</button>
2626
{% endfor %}
2727
</div>

0 commit comments

Comments
 (0)