Speech discrimination by dynamic programming