This paper proposes a new clustering method for context-dependent phoneme HMMs. This clustering method uses triphone context as far as training samples are sufficient, and automatically selects biphone and uniphone contexts if only a few training samples are given. Using this clustering method, context-dependent models were created and tested in phoneme recognition experiments and word spotting experiments. Compared with the context-independent models, the context-dependent models achieved 7.6% higher phoneme recognition accuracy and 7.0% higher word spotting accuracy.