|
128 | 128 | from sortedcontainers import SortedDict |
129 | 129 |
|
130 | 130 | from . import ( |
131 | | - PYANNOTE_URI, |
132 | | - PYANNOTE_MODALITY, |
133 | 131 | PYANNOTE_SEGMENT, |
134 | 132 | PYANNOTE_TRACK, |
135 | 133 | PYANNOTE_LABEL, |
136 | 134 | ) |
137 | | -from .json import PYANNOTE_JSON, PYANNOTE_JSON_CONTENT |
138 | 135 | from .segment import Segment, SlidingWindow |
139 | 136 | from .timeline import Timeline |
140 | 137 | from .feature import SlidingWindowFeature |
@@ -1499,47 +1496,6 @@ def discretize( |
1499 | 1496 |
|
1500 | 1497 | return SlidingWindowFeature(data, resolution, labels=labels) |
1501 | 1498 |
|
1502 | | - def for_json(self) -> Dict: |
1503 | | - """Serialization |
1504 | | -
|
1505 | | - See also |
1506 | | - -------- |
1507 | | - :mod:`pyannote.core.json` |
1508 | | - """ |
1509 | | - |
1510 | | - data = {PYANNOTE_JSON: self.__class__.__name__} |
1511 | | - content = [ |
1512 | | - {PYANNOTE_SEGMENT: s.for_json(), PYANNOTE_TRACK: t, PYANNOTE_LABEL: l} |
1513 | | - for s, t, l in self.itertracks(yield_label=True) |
1514 | | - ] |
1515 | | - data[PYANNOTE_JSON_CONTENT] = content |
1516 | | - |
1517 | | - if self.uri: |
1518 | | - data[PYANNOTE_URI] = self.uri |
1519 | | - |
1520 | | - if self.modality: |
1521 | | - data[PYANNOTE_MODALITY] = self.modality |
1522 | | - |
1523 | | - return data |
1524 | | - |
1525 | | - @classmethod |
1526 | | - def from_json(cls, data: Dict) -> "Annotation": |
1527 | | - """Deserialization |
1528 | | -
|
1529 | | - See also |
1530 | | - -------- |
1531 | | - :mod:`pyannote.core.json` |
1532 | | - """ |
1533 | | - uri = data.get(PYANNOTE_URI, None) |
1534 | | - modality = data.get(PYANNOTE_MODALITY, None) |
1535 | | - records = [] |
1536 | | - for record_dict in data[PYANNOTE_JSON_CONTENT]: |
1537 | | - segment = Segment.from_json(record_dict[PYANNOTE_SEGMENT]) |
1538 | | - track = record_dict[PYANNOTE_TRACK] |
1539 | | - label = record_dict[PYANNOTE_LABEL] |
1540 | | - records.append((segment, track, label)) |
1541 | | - return Annotation.from_records(records, uri, modality) |
1542 | | - |
1543 | 1499 | @classmethod |
1544 | 1500 | def from_records( |
1545 | 1501 | cls, |
|
0 commit comments