Add audio source event vector field
This commit is contained in:
parent
c0108094a5
commit
0384df9f57
7 changed files with 508 additions and 1 deletions
|
|
@ -7,8 +7,11 @@ import numpy as np
|
|||
from audio_field.cultcache_audio import (
|
||||
SPATIAL_AUDIO_SCHEMA_ID,
|
||||
frame_to_numpy,
|
||||
get_live_audio_source_events,
|
||||
get_live_spatial_audio_frame,
|
||||
make_audio_source_events,
|
||||
make_spatial_audio_frame,
|
||||
put_live_audio_source_events,
|
||||
put_live_spatial_audio_frame,
|
||||
)
|
||||
|
||||
|
|
@ -44,6 +47,27 @@ class SpatialAudioCultCacheTests(unittest.TestCase):
|
|||
self.assertEqual(2048, loaded.start_sample)
|
||||
np.testing.assert_allclose(block, frame_to_numpy(loaded))
|
||||
|
||||
def test_live_source_events_round_trip_through_cultcache(self):
|
||||
events = make_audio_source_events(
|
||||
frame_id=7,
|
||||
sample_rate=48000,
|
||||
start_sample=4096,
|
||||
frame_count=1024,
|
||||
audio_time_ns=123,
|
||||
events=[{"eventId": 1, "positionMeters": [1.0, 2.0, 3.0], "confidence": 0.8}],
|
||||
voice_focus=[{"anchorChannel": 4, "weight": 1.0}],
|
||||
)
|
||||
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
path = Path(tmp) / "audio-events.msgpack"
|
||||
put_live_audio_source_events(path, events)
|
||||
loaded = get_live_audio_source_events(path)
|
||||
|
||||
self.assertIsNotNone(loaded)
|
||||
self.assertEqual(48000, loaded.sample_rate)
|
||||
self.assertEqual(1, loaded.events[0]["eventId"])
|
||||
self.assertEqual(4, loaded.voice_focus[0]["anchorChannel"])
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
|
|
|||
Loading…
Reference in a new issue