Automatic model selection package for hidden Markov model is released in my GitHub. I wrote this code during my PhD.

I wrote the same version in R and MATLAB.