Skip to content

Commit

Permalink
Merge pull request coqui-ai#2236 from coqui-ai/data_checker
Browse files Browse the repository at this point in the history
Add ability to read audio from paths via util.audio
  • Loading branch information
reuben authored Jun 7, 2022
2 parents 22ca7ba + 9d1cefd commit 114d3b1
Show file tree
Hide file tree
Showing 6 changed files with 198 additions and 100 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ jobs:
python-version: ${{ matrix.pyver }}
- name: Run training unittests
run: |
sudo apt-get install -y --no-install-recommends libopusfile0 libopus-dev libopusfile-dev
./ci_scripts/train-unittests.sh
pre-commit-checks:
name: "Lin|Pre-commit checks"
runs-on: ubuntu-20.04
Expand Down
1 change: 1 addition & 0 deletions Dockerfile.build
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
libbz2-dev \
libboost-all-dev \
libgsm1-dev \
libopusfile0 \
libltdl-dev \
liblzma-dev \
libmagic-dev \
Expand Down
1 change: 1 addition & 0 deletions Dockerfile.train
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ RUN apt-get update && \
git \
wget \
libopus0 \
libvorbisfile3 \
libopusfile0 \
libsndfile1 \
sox \
Expand Down
Binary file added tests/Example.ogg
Binary file not shown.
54 changes: 54 additions & 0 deletions tests/test_audio_utils.py
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()
Loading

0 comments on commit 114d3b1

Please sign in to comment.