Skip to content

Commit 1174ad8

Browse files
chore: update audio.ipynb to reflect breadth of use cases
1 parent 327800b commit 1174ad8

File tree

1 file changed

+71
-0
lines changed

1 file changed

+71
-0
lines changed

examples/annotation_import/audio.ipynb

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,76 @@
11
{
22
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"id": "137b71f2",
6+
"metadata": {},
7+
"source": [
8+
"## Brief temporal audio examples (Text, Radio, Checklist, Nested)\n",
9+
"\n",
10+
"- This section shows minimal, class-based examples that serialize to NDJSON:\n",
11+
" - Text: `value` with `frames`\n",
12+
" - Radio: `name` with `frames`\n",
13+
" - Checklist: `name` with `frames`\n",
14+
" - Nested (1 level): child nested under closest containing parent `frames`\n",
15+
"\n",
16+
"Run this cell and the next one to see the NDJSON output only (no API calls).\n"
17+
]
18+
},
19+
{
20+
"cell_type": "code",
21+
"execution_count": null,
22+
"id": "f58dd5db",
23+
"metadata": {},
24+
"outputs": [],
25+
"source": [
26+
"import labelbox.types as lb_types\n",
27+
"from labelbox.data.serialization.ndjson.converter import NDJsonConverter\n",
28+
"\n",
29+
"# Minimal Text temporal example\n",
30+
"text_anns = [\n",
31+
" lb_types.AudioClassificationAnnotation(\n",
32+
" start_frame=1000, end_frame=1100, name=\"text_class\", value=lb_types.Text(answer=\"Hello\")\n",
33+
" ),\n",
34+
" lb_types.AudioClassificationAnnotation(\n",
35+
" start_frame=1200, end_frame=1300, name=\"text_class\", value=lb_types.Text(answer=\"World\")\n",
36+
" ),\n",
37+
"]\n",
38+
"\n",
39+
"# Minimal Radio temporal example\n",
40+
"radio_anns = [\n",
41+
" lb_types.AudioClassificationAnnotation(\n",
42+
" start_frame=200, end_frame=1500, name=\"radio_class\",\n",
43+
" value=lb_types.Radio(answer=lb_types.ClassificationAnswer(name=\"first_radio_answer\")),\n",
44+
" ),\n",
45+
"]\n",
46+
"\n",
47+
"# Minimal Checklist temporal example\n",
48+
"checklist_anns = [\n",
49+
" lb_types.AudioClassificationAnnotation(\n",
50+
" start_frame=1200, end_frame=1800, name=\"checklist_class\",\n",
51+
" value=lb_types.Checklist(answer=[lb_types.ClassificationAnswer(name=\"angry\")]),\n",
52+
" ),\n",
53+
"]\n",
54+
"\n",
55+
"# Minimal Nested (1 level) example: nested_text under parent text segment\n",
56+
"nested_anns = [\n",
57+
" lb_types.AudioClassificationAnnotation(\n",
58+
" start_frame=1500, end_frame=2400, name=\"text_class\", value=lb_types.Text(answer=\"parent\")\n",
59+
" ),\n",
60+
" lb_types.AudioClassificationAnnotation(\n",
61+
" start_frame=1600, end_frame=2000, name=\"nested_text\", value=lb_types.Text(answer=\"child\")\n",
62+
" ),\n",
63+
"]\n",
64+
"\n",
65+
"label = lb_types.Label(\n",
66+
" data={\"global_key\": \"audio_examples_demo\"},\n",
67+
" annotations=text_anns + radio_anns + checklist_anns + nested_anns,\n",
68+
")\n",
69+
"ndjson = list(NDJsonConverter.serialize([label]))\n",
70+
"for i, obj in enumerate(ndjson, 1):\n",
71+
" print(f\"{i}. {obj}\")\n"
72+
]
73+
},
374
{
475
"cell_type": "markdown",
576
"metadata": {},

0 commit comments

Comments
 (0)