forked from facebookresearch/fairseq
-
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.
add new instructions on how to get manifest *.tsv file (facebookresea…
…rch#5207) Co-authored-by: Andros Tjandra <[email protected]>
- Loading branch information
Showing
2 changed files
with
33 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/usr/bin/env python -u | ||
# Copyright (c) Facebook, Inc. and its affiliates. | ||
# | ||
# This source code is licensed under the MIT license found in the | ||
# LICENSE file in the root directory of this source tree. | ||
|
||
""" | ||
Usage: | ||
$ python misc/get_sample_size.py <input_file> > <output_file> | ||
<input_file> contains list of wav files | ||
$ cat <input_file> | ||
/path/to/audio_1.wav | ||
/path/to/audio_2.wav | ||
<output_file> contains list of wav files paired with their number of samples | ||
$ cat <output_file> | ||
/path/to/audio_1.wav 180000 | ||
/path/to/audio_2.wav 120000 | ||
""" | ||
import sys | ||
import soundfile as sf | ||
|
||
if __name__ == "__main__": | ||
files = sys.argv[1] | ||
with open(files) as fr: | ||
for fi in fr: | ||
fi = fi.strip() | ||
print(f'{fi}\t{sf.SoundFile(fi).frames}') |