feat: add pyannote.audio.sample.SAMPLE_FILE (#1629)

This commit is contained in:
Hervé BREDIN authored and GitHub committed 2024-01-25 10:42:32 +01:00
1 parent c0b9e79aa8
commit e43138278a
6 files changed
+97

No files matched your search

+1
View File
@@ -7,6 +7,7 @@
- feat(task): add option to cache task training metadata to speed up training
- feat(pipeline): add `Waveform` and `SampleRate` preprocessors
- feat(model): add `num_frames`, `receptive_field`, and `dimension` properties to segmentation models
- feat(sample): add sample file at `pyannote.audio.sample.SAMPLE_FILE`
### Fixes
+2
View File
@@ -1,4 +1,6 @@
recursive-include pyannote *.py
recursive-include pyannote *.yaml
recursive-include pyannote *.wav
recursive-include pyannote *.rttm
global-exclude *.pyc
global-exclude __pycache__
+56
View File
@@ -0,0 +1,56 @@
# MIT License
#
# Copyright (c) 2024- CNRS
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
from pathlib import Path
from pyannote.core import Annotation, Segment, Timeline
from pyannote.database.util import load_rttm
from pyannote.audio.core.io import Audio, AudioFile
def _sample() -> AudioFile:
sample_wav = Path(__file__).parent / "sample.wav"
uri = "sample"
audio = Audio()
waveform, sample_rate = audio(sample_wav)
sample_rttm = Path(__file__).parent / "sample.rttm"
annotation: Annotation = load_rttm(sample_rttm)[uri]
duration = audio.get_duration(sample_wav)
annotated: Timeline = Timeline([Segment(0.0, duration)], uri=uri)
return {
"audio": sample_wav,
"uri": "sample",
"waveform": waveform,
"sample_rate": sample_rate,
"annotation": annotation,
"annotated": annotated,
}
SAMPLE_FILE = _sample()
+10
View File
@@ -0,0 +1,10 @@
SPEAKER sample 1 6.690 0.430 <NA> <NA> speaker90 <NA> <NA>
SPEAKER sample 1 7.550 0.800 <NA> <NA> speaker91 <NA> <NA>
SPEAKER sample 1 8.320 1.700 <NA> <NA> speaker90 <NA> <NA>
SPEAKER sample 1 9.920 1.110 <NA> <NA> speaker91 <NA> <NA>
SPEAKER sample 1 10.570 4.130 <NA> <NA> speaker90 <NA> <NA>
SPEAKER sample 1 14.490 3.430 <NA> <NA> speaker91 <NA> <NA>
SPEAKER sample 1 18.050 3.440 <NA> <NA> speaker90 <NA> <NA>
SPEAKER sample 1 18.150 0.440 <NA> <NA> speaker91 <NA> <NA>
SPEAKER sample 1 21.780 6.720 <NA> <NA> speaker91 <NA> <NA>
SPEAKER sample 1 27.850 2.150 <NA> <NA> speaker90 <NA> <NA>
Binary file not shown.
+28
View File
@@ -0,0 +1,28 @@
# The MIT License (MIT)
#
# Copyright (c) 2024- CNRS
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
def test_sample():
from pyannote.audio.sample import SAMPLE_FILE
assert "annotation" in SAMPLE_FILE
assert "annotated" in SAMPLE_FILE