Skip to content

Commit

Permalink
Add Waveforms for Testing Purposes section to test/README.md (#759)
Browse files Browse the repository at this point in the history
* add Waveforms for Testing Purposes section

* Update test/README.md

use wrapper function for scipy.io.wavfile.read

Co-authored-by: moto <855818+mthrok@users.noreply.github.com>

* remove un-used files from the doc

* Update test/README.md

Rename variable

Co-authored-by: moto <855818+mthrok@users.noreply.github.com>

* fix indent; remove mentions of unused files

* remove whitenoise* files from README.md

Co-authored-by: moto <855818+mthrok@users.noreply.github.com>
  • Loading branch information
Artyom Astafurov and mthrok committed Jul 8, 2020
1 parent 180ede8 commit c375490
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,58 @@ The following test modules are defined for corresponding `torchaudio` module/fun
- [assets/kaldi](./assets/kaldi): Contains Kaldi format matrix files used in [./test_compliance_kaldi.py](./test_compliance_kaldi.py).
- [compliance](./compliance): Scripts used to generate above Kaldi matrix files.

### Waveforms for Testing Purposes

When testing transforms we often need waveforms of specific type (ex: pure tone, noise, or voice), with specific bitrate (ex. 8 or 16 kHz) and number of channels (ex. mono, stereo). Below are some tips on how to construct waveforms and guidance around existing audio files.

#### Load a Waveform from a File

```python
filepath = common_utils.get_asset_path('filename.wav')
waveform, sample_rate = common_utils.load_wav(filepath)
```

*Note: Should you choose to contribute an audio file, please leave a comment in the issue or pull request, mentioning content source and licensing information. WAV files are preferred. Other formats should be used only when there is no alternative. (i.e. dataset implementation comes with hardcoded non-wav extension).*

#### Pure Tone

Code:

```python
waveform = common_utils.get_sinusoid(
frequency=300,
sample_rate=16000,
duration=1, # seconds
n_channels=1,
dtype="float32",
device="cpu",
)
```

#### Noise

Code:

```python
tensor = common_utils.get_whitenoise()
```

Files:

* `steam-train-whistle-daniel_simon.wav`

#### Voice

Files:

* `CommonVoice/cv-corpus-4-2019-12-10/tt/clips/common_voice_tt_00000000.mp3`
* `LibriSpeech/dev-clean/1272/128104/1272-128104-0000.flac`
* `LJSpeech-1.1/wavs/LJ001-0001.wav`
* `SpeechCommands/speech_commands_v0.02/go/0a9f9af7_nohash_0.wav`
* `VCTK-Corpus/wav48/p224/p224_002.wav`
* `waves_yesno/0_1_0_1_0_1_1_0.wav`
* `vad-go-stereo-44100.wav`
* `vad-go-mono-32000.wav`

## Adding test

Expand Down

0 comments on commit c375490

Please sign in to comment.