Skip to content

Commit

Permalink
Fix bug with empty RTTMs (#81)
Browse files Browse the repository at this point in the history
* Update README.md

* Update README.md

* Fix bug with empty RTTMs

* Add uri to empty annotation for consistency

* Check non-empty annotation list in a more pythonic way

Co-authored-by: Juan Coria <[email protected]>
  • Loading branch information
zaouk and juanmc2005 authored Aug 17, 2022
1 parent a7befd7 commit 6bbc226
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
6 changes: 5 additions & 1 deletion src/diart/inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,11 @@ def __call__(self, pipeline: OnlineSpeakerDiarization, source: src.AudioSource)
# Stream audio through the pipeline
source.read()

return load_rttm(rttm_path)[source.uri]
annotations = load_rttm(rttm_path)
if source.uri in annotations:
return annotations[source.uri]
else:
return Annotation(uri=source.uri)


class Benchmark:
Expand Down
9 changes: 6 additions & 3 deletions src/diart/sinks.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,12 @@ def __init__(self, path: Union[Path, Text], patch_collar: float = 0.05):

def patch_rttm(self):
"""Stitch same-speaker turns that are close to each other"""
annotation = list(load_rttm(self.path).values())[0]
with open(self.path, 'w') as file:
annotation.support(self.patch_collar).write_rttm(file)

annotations = list(load_rttm(self.path).values())
if annotations:
annotation = annotations[0]
with open(self.path, 'w') as file:
annotation.support(self.patch_collar).write_rttm(file)

def on_next(self, value: Tuple[Annotation, SlidingWindowFeature]):
with open(self.path, 'a') as file:
Expand Down

0 comments on commit 6bbc226

Please sign in to comment.