コード例 #1
0
ファイル: json.py プロジェクト: Parisson/pyannote-core
def object_hook(d):
    """
    Usage
    -----
    >>> import simplejson as json
    >>> with open('file.json', 'r') as f:
    ...   json.load(f, object_hook=object_hook)
    """

    from segment import Segment
    from timeline import Timeline
    from annotation import Annotation
    from transcription import Transcription

    if PYANNOTE_JSON_SEGMENT in d:
        return Segment.from_json(d)

    if PYANNOTE_JSON_TIMELINE in d:
        return Timeline.from_json(d)

    if PYANNOTE_JSON_ANNOTATION in d:
        return Annotation.from_json(d)

    if PYANNOTE_JSON_TRANSCRIPTION in d:
        return Transcription.from_json(d)

    return d
コード例 #2
0
def object_hook(d):
    """
    Usage
    -----
    >>> import simplejson as json
    >>> with open('file.json', 'r') as f:
    ...   json.load(f, object_hook=object_hook)
    """

    from segment import Segment
    from timeline import Timeline
    from annotation import Annotation
    from transcription import Transcription

    if PYANNOTE_JSON_SEGMENT in d:
        return Segment.from_json(d)

    if PYANNOTE_JSON_TIMELINE in d:
        return Timeline.from_json(d)

    if PYANNOTE_JSON_ANNOTATION in d:
        return Annotation.from_json(d)

    if PYANNOTE_JSON_TRANSCRIPTION in d:
        return Transcription.from_json(d)

    return d
コード例 #3
0
ファイル: annotation.py プロジェクト: kLm8/pyannote-core
 def from_json(cls, data):
     uri = data.get(PYANNOTE_URI, None)
     modality = data.get(PYANNOTE_MODALITY, None)
     annotation = cls(uri=uri, modality=modality)
     for s, track, label in data[PYANNOTE_JSON_ANNOTATION]:
         segment = Segment.from_json(s)
         annotation[segment, track] = label
     return annotation
コード例 #4
0
ファイル: annotation.py プロジェクト: gw17/pyannote-core
    def from_json(cls, data):

        uri = data.get(PYANNOTE_URI, None)
        modality = data.get(PYANNOTE_MODALITY, None)
        annotation = cls(uri=uri, modality=modality)
        for one in data[PYANNOTE_JSON_CONTENT]:
            segment = Segment.from_json(one[PYANNOTE_SEGMENT])
            track = one[PYANNOTE_TRACK]
            label = one[PYANNOTE_LABEL]
            annotation[segment, track] = label

        return annotation
コード例 #5
0
ファイル: timeline.py プロジェクト: gw17/pyannote-core
 def from_json(cls, data):
     uri = data.get(PYANNOTE_URI, None)
     segments = [Segment.from_json(s) for s in data[PYANNOTE_JSON_CONTENT]]
     return cls(segments=segments, uri=uri)
コード例 #6
0
ファイル: timeline.py プロジェクト: Parisson/pyannote-core
 def from_json(cls, data):
     segments = [Segment.from_json(s) for s in data[PYANNOTE_JSON_TIMELINE]]
     uri = data.get(PYANNOTE_URI, None)
     return cls(segments=segments, uri=uri)
コード例 #7
0
 def from_json(cls, data):
     segments = [Segment.from_json(s) for s in data[PYANNOTE_JSON_TIMELINE]]
     uri = data.get(PYANNOTE_URI, None)
     return cls(segments=segments, uri=uri)