15
15
def test_audio_classification_creation ():
16
16
"""Test creating audio classification with direct frame specification"""
17
17
annotation = AudioClassificationAnnotation (
18
- frame = 2500 , # 2.5 seconds in milliseconds
18
+ start_frame = 2500 , # 2.5 seconds in milliseconds
19
19
name = "speaker_id" ,
20
20
value = Radio (answer = ClassificationAnswer (name = "john" )),
21
21
)
22
22
23
- assert annotation .frame == 2500
23
+ assert annotation .start_frame == 2500
24
24
assert annotation .end_frame is None
25
25
assert annotation .segment_index is None
26
26
assert annotation .name == "speaker_id"
@@ -31,41 +31,41 @@ def test_audio_classification_creation():
31
31
def test_audio_classification_with_time_range ():
32
32
"""Test creating audio classification with start and end frames"""
33
33
annotation = AudioClassificationAnnotation (
34
- frame = 2500 , # Start at 2.5 seconds
34
+ start_frame = 2500 , # Start at 2.5 seconds
35
35
end_frame = 4100 , # End at 4.1 seconds
36
36
name = "speaker_id" ,
37
37
value = Radio (answer = ClassificationAnswer (name = "john" )),
38
38
)
39
39
40
- assert annotation .frame == 2500
40
+ assert annotation .start_frame == 2500
41
41
assert annotation .end_frame == 4100
42
42
assert annotation .name == "speaker_id"
43
43
44
44
45
45
def test_audio_classification_creation_with_segment ():
46
46
"""Test creating audio classification with segment index"""
47
47
annotation = AudioClassificationAnnotation (
48
- frame = 10000 ,
48
+ start_frame = 10000 ,
49
49
end_frame = 15000 ,
50
50
name = "language" ,
51
51
value = Radio (answer = ClassificationAnswer (name = "english" )),
52
52
segment_index = 1 ,
53
53
)
54
54
55
- assert annotation .frame == 10000
55
+ assert annotation .start_frame == 10000
56
56
assert annotation .end_frame == 15000
57
57
assert annotation .segment_index == 1
58
58
59
59
60
60
def test_audio_classification_text_type ():
61
61
"""Test creating audio classification with Text value"""
62
62
annotation = AudioClassificationAnnotation (
63
- frame = 5000 , # 5.0 seconds
63
+ start_frame = 5000 , # 5.0 seconds
64
64
name = "quality" ,
65
65
value = Text (answer = "excellent" ),
66
66
)
67
67
68
- assert annotation .frame == 5000
68
+ assert annotation .start_frame == 5000
69
69
assert annotation .name == "quality"
70
70
assert isinstance (annotation .value , Text )
71
71
assert annotation .value .answer == "excellent"
@@ -74,15 +74,15 @@ def test_audio_classification_text_type():
74
74
def test_audio_object_creation ():
75
75
"""Test creating audio object annotation"""
76
76
annotation = AudioObjectAnnotation (
77
- frame = 10000 ,
77
+ start_frame = 10000 ,
78
78
end_frame = 12500 ,
79
79
name = "transcription" ,
80
80
value = lb_types .TextEntity (
81
81
start = 0 , end = 11
82
82
), # "Hello world" has 11 characters
83
83
)
84
84
85
- assert annotation .frame == 10000
85
+ assert annotation .start_frame == 10000
86
86
assert annotation .end_frame == 12500
87
87
assert annotation .keyframe is True
88
88
assert annotation .segment_index is None
@@ -95,13 +95,13 @@ def test_audio_object_creation():
95
95
def test_audio_object_creation_with_classifications ():
96
96
"""Test creating audio object with sub-classifications"""
97
97
sub_classification = AudioClassificationAnnotation (
98
- frame = 10000 ,
98
+ start_frame = 10000 ,
99
99
name = "confidence" ,
100
100
value = Radio (answer = ClassificationAnswer (name = "high" )),
101
101
)
102
102
103
103
annotation = AudioObjectAnnotation (
104
- frame = 10000 ,
104
+ start_frame = 10000 ,
105
105
end_frame = 12500 ,
106
106
name = "transcription" ,
107
107
value = lb_types .TextEntity (start = 0 , end = 11 ),
@@ -110,20 +110,20 @@ def test_audio_object_creation_with_classifications():
110
110
111
111
assert len (annotation .classifications ) == 1
112
112
assert annotation .classifications [0 ].name == "confidence"
113
- assert annotation .classifications [0 ].frame == 10000
113
+ assert annotation .classifications [0 ].start_frame == 10000
114
114
115
115
116
116
def test_audio_object_direct_creation ():
117
117
"""Test creating audio object directly with various options"""
118
118
annotation = AudioObjectAnnotation (
119
- frame = 7500 , # 7.5 seconds
119
+ start_frame = 7500 , # 7.5 seconds
120
120
name = "sound_event" ,
121
121
value = lb_types .TextEntity (start = 0 , end = 11 ),
122
122
keyframe = False ,
123
123
segment_index = 2 ,
124
124
)
125
125
126
- assert annotation .frame == 7500
126
+ assert annotation .start_frame == 7500
127
127
assert annotation .end_frame is None
128
128
assert annotation .keyframe is False
129
129
assert annotation .segment_index == 2
@@ -136,27 +136,27 @@ def test_frame_precision():
136
136
137
137
for milliseconds in test_cases :
138
138
annotation = AudioClassificationAnnotation (
139
- frame = milliseconds ,
139
+ start_frame = milliseconds ,
140
140
end_frame = milliseconds + 1000 ,
141
141
name = "test" ,
142
142
value = Text (answer = "test" ),
143
143
)
144
- assert annotation .frame == milliseconds
144
+ assert annotation .start_frame == milliseconds
145
145
assert annotation .end_frame == milliseconds + 1000
146
146
147
147
148
148
def test_audio_label_integration ():
149
149
"""Test audio annotations work with Label container"""
150
150
# Create audio annotations
151
151
speaker_annotation = AudioClassificationAnnotation (
152
- frame = 1000 ,
152
+ start_frame = 1000 ,
153
153
end_frame = 2000 ,
154
154
name = "speaker" ,
155
155
value = Radio (answer = ClassificationAnswer (name = "john" )),
156
156
)
157
157
158
158
transcription_annotation = AudioObjectAnnotation (
159
- frame = 1000 ,
159
+ start_frame = 1000 ,
160
160
end_frame = 2000 ,
161
161
name = "transcription" ,
162
162
value = lb_types .TextEntity (start = 0 , end = 5 ),
@@ -194,7 +194,7 @@ def test_audio_annotation_validation():
194
194
# Test frame must be int
195
195
with pytest .raises (ValueError ):
196
196
AudioClassificationAnnotation (
197
- frame = "invalid" , # Should be int
197
+ start_frame = "invalid" , # Should be int
198
198
name = "test" ,
199
199
value = Text (answer = "test" ),
200
200
)
@@ -205,7 +205,7 @@ def test_audio_annotation_extra_fields():
205
205
extra_data = {"source" : "automatic" , "confidence_score" : 0.95 }
206
206
207
207
annotation = AudioClassificationAnnotation (
208
- frame = 3000 , name = "quality" , value = Text (answer = "good" ), extra = extra_data
208
+ start_frame = 3000 , name = "quality" , value = Text (answer = "good" ), extra = extra_data
209
209
)
210
210
211
211
assert annotation .extra ["source" ] == "automatic"
@@ -215,7 +215,7 @@ def test_audio_annotation_extra_fields():
215
215
def test_audio_annotation_feature_schema ():
216
216
"""Test audio annotations with feature schema IDs"""
217
217
annotation = AudioClassificationAnnotation (
218
- frame = 4000 ,
218
+ start_frame = 4000 ,
219
219
name = "language" ,
220
220
value = Radio (answer = ClassificationAnswer (name = "spanish" )),
221
221
feature_schema_id = "1234567890123456789012345" ,
@@ -228,14 +228,14 @@ def test_audio_annotation_mixed_types():
228
228
"""Test label with mixed audio and other annotation types"""
229
229
# Audio annotation
230
230
audio_annotation = AudioClassificationAnnotation (
231
- frame = 2000 ,
231
+ start_frame = 2000 ,
232
232
name = "speaker" ,
233
233
value = Radio (answer = ClassificationAnswer (name = "john" )),
234
234
)
235
235
236
236
# Video annotation
237
237
video_annotation = lb_types .VideoClassificationAnnotation (
238
- frame = 10 , name = "quality" , value = Text (answer = "good" )
238
+ start_frame = 10 , name = "quality" , value = Text (answer = "good" )
239
239
)
240
240
241
241
# Image annotation
@@ -280,7 +280,7 @@ def test_audio_annotation_mixed_types():
280
280
def test_audio_annotation_serialization ():
281
281
"""Test audio annotations can be serialized to dict"""
282
282
annotation = AudioClassificationAnnotation (
283
- frame = 6000 ,
283
+ start_frame = 6000 ,
284
284
end_frame = 8000 ,
285
285
name = "emotion" ,
286
286
value = Radio (answer = ClassificationAnswer (name = "happy" )),
@@ -317,7 +317,7 @@ def test_audio_annotation_from_dict():
317
317
318
318
annotation = AudioClassificationAnnotation (** annotation_data )
319
319
320
- assert annotation .frame == 7000
320
+ assert annotation .start_frame == 7000
321
321
assert annotation .end_frame == 9000
322
322
assert annotation .name == "topic"
323
323
assert annotation .segment_index == 2
@@ -328,32 +328,32 @@ def test_audio_annotation_edge_cases():
328
328
"""Test audio annotation edge cases"""
329
329
# Test very long audio (many hours)
330
330
long_annotation = AudioClassificationAnnotation (
331
- frame = 3600000 , # 1 hour in milliseconds
331
+ start_frame = 3600000 , # 1 hour in milliseconds
332
332
end_frame = 7200000 , # 2 hours in milliseconds
333
333
name = "long_audio" ,
334
334
value = Text (answer = "very long" ),
335
335
)
336
336
337
- assert long_annotation .frame == 3600000
337
+ assert long_annotation .start_frame == 3600000
338
338
assert long_annotation .end_frame == 7200000
339
339
340
340
# Test very short audio (milliseconds)
341
341
short_annotation = AudioClassificationAnnotation (
342
- frame = 1 , # 1 millisecond
342
+ start_frame = 1 , # 1 millisecond
343
343
end_frame = 2 , # 2 milliseconds
344
344
name = "short_audio" ,
345
345
value = Text (answer = "very short" ),
346
346
)
347
347
348
- assert short_annotation .frame == 1
348
+ assert short_annotation .start_frame == 1
349
349
assert short_annotation .end_frame == 2
350
350
351
351
# Test zero time
352
352
zero_annotation = AudioClassificationAnnotation (
353
- frame = 0 , name = "zero_time" , value = Text (answer = "zero" )
353
+ start_frame = 0 , name = "zero_time" , value = Text (answer = "zero" )
354
354
)
355
355
356
- assert zero_annotation .frame == 0
356
+ assert zero_annotation .start_frame == 0
357
357
assert zero_annotation .end_frame is None
358
358
359
359
@@ -368,7 +368,7 @@ def test_temporal_annotation_grouping():
368
368
end_frame = start_frame + 900 # 900ms duration each
369
369
370
370
annotation = AudioClassificationAnnotation (
371
- frame = start_frame ,
371
+ start_frame = start_frame ,
372
372
end_frame = end_frame ,
373
373
name = "tokens" , # Same name for grouping
374
374
value = Text (answer = token ),
@@ -380,8 +380,8 @@ def test_temporal_annotation_grouping():
380
380
assert all (ann .name == "tokens" for ann in annotations )
381
381
assert annotations [0 ].value .answer == "Hello"
382
382
assert annotations [1 ].value .answer == "world"
383
- assert annotations [0 ].frame == 0
384
- assert annotations [1 ].frame == 1000
383
+ assert annotations [0 ].start_frame == 0
384
+ assert annotations [1 ].start_frame == 1000
385
385
assert annotations [0 ].end_frame == 900
386
386
assert annotations [1 ].end_frame == 1900
387
387
@@ -390,7 +390,7 @@ def test_audio_object_types():
390
390
"""Test different types of audio object annotations"""
391
391
# Text entity (transcription)
392
392
text_obj = AudioObjectAnnotation (
393
- frame = 1000 ,
393
+ start_frame = 1000 ,
394
394
name = "transcription" ,
395
395
value = TextEntity (start = 0 , end = 5 ), # "hello"
396
396
)
@@ -401,7 +401,7 @@ def test_audio_object_types():
401
401
402
402
# Test with keyframe and segment settings
403
403
keyframe_obj = AudioObjectAnnotation (
404
- frame = 2000 ,
404
+ start_frame = 2000 ,
405
405
end_frame = 3000 ,
406
406
name = "segment" ,
407
407
value = TextEntity (start = 10 , end = 15 ),
@@ -411,5 +411,5 @@ def test_audio_object_types():
411
411
412
412
assert keyframe_obj .keyframe is True
413
413
assert keyframe_obj .segment_index == 1
414
- assert keyframe_obj .frame == 2000
414
+ assert keyframe_obj .start_frame == 2000
415
415
assert keyframe_obj .end_frame == 3000
0 commit comments