mirror of https://github.com/drowe67/LPCNet.git
added arguments to plot-pulaw
parent
a2cf8736f5
commit
a4dd9c2199
|
|
@ -1,15 +1,21 @@
|
|||
#!/usr/bin/python3
|
||||
# Utility to inspect packed ulaw samples before training from sw2packedulaw.c
|
||||
# Utility to inspect packed ulaw samples from sw2packedulaw.c (or dump_data.c) before training
|
||||
|
||||
import numpy as np
|
||||
import matplotlib.pyplot as plt
|
||||
import sys
|
||||
import ulaw
|
||||
import argparse
|
||||
|
||||
data = np.fromfile(sys.argv[1], dtype='uint8')
|
||||
nb_samples = 8000
|
||||
parser = argparse.ArgumentParser(description='Plot LPCNet training packed ulaw samples')
|
||||
parser.add_argument('file1', help='pulaw file of packed ulaw samples')
|
||||
parser.add_argument('--file2', help='optional second packed ulaw file to compare')
|
||||
parser.add_argument('--nb_samples', type=int, default=-1, help='Optional number of samples to plot')
|
||||
args = parser.parse_args()
|
||||
|
||||
#data = data[:nb_samples*20]
|
||||
data = np.fromfile(args.file1, dtype='uint8')
|
||||
nb_samples = args.nb_samples
|
||||
data = data[:nb_samples]
|
||||
|
||||
sig = np.array(data[0::4], dtype='float')
|
||||
pred = np.array(data[1::4], dtype='float')
|
||||
|
|
@ -18,15 +24,6 @@ out_exc = np.array(data[3::4], dtype='float')
|
|||
|
||||
print("exc var: %4.3e" % (np.var(ulaw.ulaw2lin(in_exc))))
|
||||
|
||||
"""
|
||||
s_in = 32000*np.sin(np.arange(0,8000)*np.pi*2/100)
|
||||
s_out = ulaw.ulaw2lin(ulaw.lin2ulaw(s_in))
|
||||
plt.figure(1)
|
||||
plt.plot(s_in)
|
||||
plt.plot(s_out)
|
||||
plt.show(block=False)
|
||||
"""
|
||||
|
||||
plt.figure(1)
|
||||
plt.subplot(211)
|
||||
plt.plot(ulaw.ulaw2lin(sig), label='sig')
|
||||
|
|
@ -41,8 +38,9 @@ plt.show(block=False)
|
|||
plt.figure(2)
|
||||
plt.subplot(211)
|
||||
plt.plot(ulaw.ulaw2lin(in_exc), label='in_exc')
|
||||
if len(sys.argv) == 3:
|
||||
data2 = np.fromfile(sys.argv[2], dtype='uint8')
|
||||
if args.file2:
|
||||
data2 = np.fromfile(args.file2, dtype='uint8')
|
||||
data2 = data2[:nb_samples]
|
||||
in_exc2 = np.array(data2[2::4], dtype='float')
|
||||
plt.plot(ulaw.ulaw2lin(in_exc2), label='in_exc2')
|
||||
plt.ylim((-30000,30000))
|
||||
|
|
|
|||
Loading…
Reference in New Issue