Language Model Action Set
Training an RNN Acoustic Model
This example is not available for the CAS programming language.
Training an RNN Acoustic Model
This example is not available for the Lua programming language.
Training an RNN Acoustic Model
This section contains Python code. For more information about coding in Python, see Getting Started with SAS Viya for Python and SAS Viya: System Programming Guide.
The following code shows how you can train an acoustic model that uses a recurrent neural network (RNN) in CAS:
casOut = {"name": "train_audio", "replace": True},
)
casOut = {"name": "dev_audio", "replace": True},
)
casOut = {"name": "train_trans", "replace": True},
importoptions = {"fileType": "CSV"}
)
casOut = {"name": "dev_trans", "replace": True},
importoptions = {"fileType": "CSV"}
)
vars2.append({"name": "y%d" % (ci)})
casout = {"name": "train_computefeatures_input", "replace": True},
jointype = "left",
left = {"maps": vars1, "table": {"name": "train_audio"}},
right = {"maps": vars2, "table": {"name": "train_trans"}}
casout = {"name": "dev_computefeatures_input", "replace": True},
jointype = "left",
left = {"maps": vars1, "table": {"name": "dev_audio"}},
right = {"maps": vars2, "table": {"name": "dev_trans"}}
vars_list.append("y%d" % (ci))
table = "train_computefeatures_input",
casOut = {"name": "train_dltrain_input", "replace": True},
audioColumn = "_audio_",
copyvars = vars_list,
frameExtractionOptions = {"frameShift": 10, "frameLength": 25, "dither": 0},
melBanksOptions = {"nBins": 40},
mfccOptions = {"nCeps": 40},
featureScalingMethod = "STANDARDIZATION",
nOutputFrames = nFrames,
table = "dev_computefeatures_input",
casOut = {"name": "dev_dltrain_input", "replace": True},
audioColumn = "_audio_",
copyvars = vars_list,
frameExtractionOptions = {"frameShift": 10, "frameLength": 25, "dither": 0},
melBanksOptions = {"nBins": 40},
mfccOptions = {"nCeps": 40},
featureScalingMethod = "STANDARDIZATION",
nOutputFrames = nFrames,
model = "asr",
name = "rnn11",
srclayers = ["data"],
layer = {"type": "recurrent", "n": 120, "dropout": 0.1,
"rnnType": "lstm", "init": "msra",
"outputType": "samelength", "reversed": False}
model = "asr",
name = "rnn12",
srclayers = ["data"],
layer = {"type": "recurrent", "n": 120, "dropout": 0.1,
"rnnType": "lstm", "init": "msra",
"outputType": "samelength", "reversed": True}
model = "asr",
name = "outlayer",
srclayers = ["rnn11", "rnn12"],
layer = {"type": "output", "act": "softmax", "error": "CTC"}
for vi in range(nToken):
inputs.append("_f%d_v%d_" % (fi, vi))
table = "train_dltrain_input",
validTable = "dev_dltrain_input",
model = "asr",
modelWeights = "trainedWeights",
bestWeights = "bestWeights",
targetSeq = targets,
inputs = inputs,
nominals = targets,
sequenceOpts = {"seqLen": "_num_frames_",
"tgtLen": "ylen",
"tokensize": nToken
},
optimizer = {"miniBatchSize": 16,
"logLevel": 3,
"maxEpochs": 1,
"snapshotFreq": 1,
"algorithm": {"method": "adam",
"clipGradMax": 10000,
"clipGradMin": -10000,
"learningRate": 0.001,
"lrpolicy": "step",
"stepsize": 30,
"gamma": 0.5
}
}
name = "speech/RNN_model",
replace = True
)
name = "speech/RNN_model_weights",
replace = True
)
name = "speech/RNN_model_weights_attr",
replace = True
)
In this example, the RNN model has only one bidirectional long short-term memory (LSTM) layer. For better performance, you could try different ways to extract features from audio files or try different architectures for the acoustic model. In addition, you might want to experiment with different parameters when calling the dlTrain action.
Training an RNN Acoustic Model
This example is not available for the R programming language.