-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tests for by_phrase and speaker warning
- Loading branch information
1 parent
057cafc
commit 09fc310
Showing
1 changed file
with
21 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,44 @@ | ||
import math | ||
import json | ||
import numpy.testing as nptest | ||
import pytest | ||
import textgrid | ||
import warnings | ||
|
||
import formatter | ||
|
||
class TestFormatter(): | ||
Format = formatter.Formatter() | ||
|
||
def test_to_TextGrid(self): | ||
for input_fname, _ in self.provide_to_TextGrid(): | ||
for input_fname, by_phrase in self.provide_to_TextGrid(): | ||
with open(input_fname) as f: | ||
case = json.load(f) | ||
observed = self.Format.to_TextGrid(case, by_phrase=False) | ||
observed = self.Format.to_TextGrid(case, by_phrase=by_phrase) | ||
|
||
assert observed.maxTime is not None | ||
assert len(observed.tiers) > 0 | ||
|
||
def test_no_speaker_warning(self): | ||
for input_fname in self.provide_no_speaker_warning(): | ||
with open(input_fname) as f: | ||
case = json.load(f) | ||
with pytest.warns(UserWarning, match="No speaker for segment") as record: | ||
_ = self.Format.to_TextGrid(case, by_phrase=False) | ||
|
||
def provide_to_TextGrid(self): | ||
return [ | ||
( | ||
'tests/data/TestAudio_SnoopDogg_85SouthMedia_WhisperTimestampSegments.json', | ||
'' | ||
True | ||
), | ||
( | ||
'tests/data/TestAudio_SnoopDogg_85SouthMedia_WhisperTimestampSegments.json', | ||
False | ||
), | ||
] | ||
|
||
def provide_no_speaker_warning(self): | ||
return [ | ||
'tests/data/TestAudio_SnoopDogg_85SouthMedia.json', | ||
] |