Skip to content

Commit

Permalink
added .s16 support to moc.py
Browse files Browse the repository at this point in the history
  • Loading branch information
TheGrumpySnail01 committed Oct 21, 2024
1 parent 5733c02 commit b1f9d5c
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions dnn/torch/osce/stndrd/qualification/moc.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
"""
import sys

import numpy as np
import scipy.signal
Expand Down Expand Up @@ -172,14 +173,28 @@ def compare(x, y, apply_vad=False):
from scipy.io import wavfile

parser = argparse.ArgumentParser()
parser.add_argument('ref', type=str, help='reference wav file')
parser.add_argument('deg', type=str, help='degraded wav file')
parser.add_argument('ref', type=str, help='reference file (.wav or .s16)')
parser.add_argument('deg', type=str, help='degraded file (.wav or .s16)')
parser.add_argument('--apply-vad', action='store_true')
args = parser.parse_args()


fs1, x = wavfile.read(args.ref)
fs2, y = wavfile.read(args.deg)
if args.ref.endswith(".s16"):
x = np.fromfile(args.ref, dtype=np.int16)
fs1 = 16000
elif args.ref.endswith(".wav"):
fs1, x = wavfile.read(args.ref)
else:
parser.print_help()
sys.exit(1)

if args.deg.endswith(".s16"):
y = np.fromfile(args.deg, dtype=np.int16)
fs2 = 16000
elif args.ref.endswith(".wav"):
fs2, y = wavfile.read(args.deg)
else:
parser.print_help()
sys.exit(1)

if max(fs1, fs2) != 16000:
raise ValueError('error: encountered sampling frequency diffrent from 16kHz')
Expand Down

0 comments on commit b1f9d5c

Please sign in to comment.