forked from coqui-ai/STT
-
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.
Merge pull request coqui-ai#2236 from coqui-ai/data_checker
Add ability to read audio from paths via util.audio
- Loading branch information
Showing
6 changed files
with
198 additions
and
100 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
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
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 |
---|---|---|
|
@@ -36,6 +36,7 @@ RUN apt-get update && \ | |
git \ | ||
wget \ | ||
libopus0 \ | ||
libvorbisfile3 \ | ||
libopusfile0 \ | ||
libsndfile1 \ | ||
sox \ | ||
|
Binary file not shown.
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 |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import unittest | ||
from argparse import Namespace | ||
from pathlib import Path | ||
|
||
from coqui_stt_training.util import audio | ||
|
||
|
||
def from_here(path): | ||
here = Path(__file__) | ||
return here.parent / path | ||
|
||
|
||
class TestValidateReadAudio(unittest.TestCase): | ||
def test_flac(self): | ||
audio_path = from_here("../data/smoke_test/LDC93S1.flac") | ||
audio_type = audio.get_loadable_audio_type_from_extension(audio_path.suffix) | ||
result = audio.read_audio(audio_type, str(audio_path)) | ||
self.assertIsInstance(result[0], audio.AudioFormat) | ||
|
||
def test_wav(self): | ||
audio_path = from_here("../data/smoke_test/LDC93S1.wav") | ||
audio_type = audio.get_loadable_audio_type_from_extension(audio_path.suffix) | ||
result = audio.read_audio(audio_type, str(audio_path)) | ||
self.assertIsInstance(result[0], audio.AudioFormat) | ||
|
||
def test_ogg_opus(self): | ||
audio_path = from_here("../data/smoke_test/LDC93S1.opus") | ||
audio_type = audio.get_loadable_audio_type_from_extension(audio_path.suffix) | ||
result = audio.read_audio(audio_type, str(audio_path)) | ||
self.assertIsInstance(result[0], audio.AudioFormat) | ||
|
||
|
||
class TestValidateReadDuration(unittest.TestCase): | ||
def test_flac(self): | ||
audio_path = from_here("../data/smoke_test/LDC93S1.flac") | ||
audio_type = audio.get_loadable_audio_type_from_extension(audio_path.suffix) | ||
result = audio.read_duration(audio_type, str(audio_path)) | ||
self.assertIsInstance(result, float) | ||
|
||
def test_wav(self): | ||
audio_path = from_here("../data/smoke_test/LDC93S1.wav") | ||
audio_type = audio.get_loadable_audio_type_from_extension(audio_path.suffix) | ||
result = audio.read_duration(audio_type, str(audio_path)) | ||
self.assertIsInstance(result, float) | ||
|
||
def test_ogg_opus(self): | ||
audio_path = from_here("../data/smoke_test/LDC93S1.opus") | ||
audio_type = audio.get_loadable_audio_type_from_extension(audio_path.suffix) | ||
result = audio.read_duration(audio_type, str(audio_path)) | ||
self.assertIsInstance(result, float) | ||
|
||
|
||
if __name__ == "__main__": | ||
unittest.main() |
Oops, something went wrong.