Skip to content

Commit

Permalink
add new instructions on how to get manifest *.tsv file (#5207)
Browse files Browse the repository at this point in the history
Co-authored-by: Andros Tjandra <androstj@fb.com>
  • Loading branch information
androstj and androstj committed Jun 17, 2023
1 parent 91c364b commit 8deb43a
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
6 changes: 4 additions & 2 deletions examples/mms/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,12 @@ dev.ltr
dev.uid
# dev.tsv each line contains <audio> <number_of_sample>
# if user don't have this information, please run misc/get_sample_size.py
$ cat dev.tsv
/
/path/to/audio_1 180000
/path/to/audio_2 200000
/path/to/audio_1.wav 180000
/path/to/audio_2.wav 200000
$ cat dev.ltr
t h i s | i s | o n e |
Expand Down
29 changes: 29 additions & 0 deletions examples/mms/misc/get_sample_size.py
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}')

0 comments on commit 8deb43a

Please sign in to comment.