Skip to content

Commit c375490

Browse files
Artyom Astafurovmthrok
andauthored
Add Waveforms for Testing Purposes section to test/README.md (#759)
* add Waveforms for Testing Purposes section * Update test/README.md use wrapper function for scipy.io.wavfile.read Co-authored-by: moto <[email protected]> * remove un-used files from the doc * Update test/README.md Rename variable Co-authored-by: moto <[email protected]> * fix indent; remove mentions of unused files * remove whitenoise* files from README.md Co-authored-by: moto <[email protected]>
1 parent 180ede8 commit c375490

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

test/README.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,58 @@ The following test modules are defined for corresponding `torchaudio` module/fun
4141
- [assets/kaldi](./assets/kaldi): Contains Kaldi format matrix files used in [./test_compliance_kaldi.py](./test_compliance_kaldi.py).
4242
- [compliance](./compliance): Scripts used to generate above Kaldi matrix files.
4343

44+
### Waveforms for Testing Purposes
45+
46+
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.
47+
48+
#### Load a Waveform from a File
49+
50+
```python
51+
filepath = common_utils.get_asset_path('filename.wav')
52+
waveform, sample_rate = common_utils.load_wav(filepath)
53+
```
54+
55+
*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).*
56+
57+
#### Pure Tone
58+
59+
Code:
60+
61+
```python
62+
waveform = common_utils.get_sinusoid(
63+
frequency=300,
64+
sample_rate=16000,
65+
duration=1, # seconds
66+
n_channels=1,
67+
dtype="float32",
68+
device="cpu",
69+
)
70+
```
71+
72+
#### Noise
73+
74+
Code:
75+
76+
```python
77+
tensor = common_utils.get_whitenoise()
78+
```
79+
80+
Files:
81+
82+
* `steam-train-whistle-daniel_simon.wav`
83+
84+
#### Voice
85+
86+
Files:
87+
88+
* `CommonVoice/cv-corpus-4-2019-12-10/tt/clips/common_voice_tt_00000000.mp3`
89+
* `LibriSpeech/dev-clean/1272/128104/1272-128104-0000.flac`
90+
* `LJSpeech-1.1/wavs/LJ001-0001.wav`
91+
* `SpeechCommands/speech_commands_v0.02/go/0a9f9af7_nohash_0.wav`
92+
* `VCTK-Corpus/wav48/p224/p224_002.wav`
93+
* `waves_yesno/0_1_0_1_0_1_1_0.wav`
94+
* `vad-go-stereo-44100.wav`
95+
* `vad-go-mono-32000.wav`
4496

4597
## Adding test
4698

0 commit comments

Comments
 (0)