added save function to export to json
This commit is contained in:
@@ -1,8 +1,9 @@
|
|||||||
from pyannote.audio import Pipeline
|
from .audio import Pipeline
|
||||||
from pyannote.audio.pipelines.speaker_diarization import SpeakerDiarization
|
from pyannote.audio.pipelines.speaker_diarization import SpeakerDiarization
|
||||||
from torch import Tensor
|
from torch import Tensor
|
||||||
import os
|
import os
|
||||||
from typing import TypeVar, Union
|
from typing import TypeVar, Union
|
||||||
|
import json
|
||||||
|
|
||||||
Annotation = TypeVar('Annotation')
|
Annotation = TypeVar('Annotation')
|
||||||
|
|
||||||
@@ -88,6 +89,18 @@ class Diariser:
|
|||||||
diarization_output["speakers"].append(outp[2])
|
diarization_output["speakers"].append(outp[2])
|
||||||
return diarization_output
|
return diarization_output
|
||||||
|
|
||||||
|
def save(self, path : str, *args, **kwargs) -> None:
|
||||||
|
"""
|
||||||
|
Save diarization output to a file
|
||||||
|
|
||||||
|
:param path: path to save file
|
||||||
|
:type path: str
|
||||||
|
"""
|
||||||
|
with open(path, "w") as f:
|
||||||
|
json.dump(self.transcript, f, *args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _get_token():
|
def _get_token():
|
||||||
# check ig .pyannotetoken.txt exists
|
# check ig .pyannotetoken.txt exists
|
||||||
|
|||||||
Reference in New Issue
Block a user