Beispiel #1
0
        /// <summary>
        /// Builds the Phoneme maps from the compressed form.
        /// </summary>
        private static PhoneMap[] DecompressPhoneMaps(PhoneMapCompressed[] pmComps)
        {
            PhoneMap[] phoneMaps = new PhoneMap[pmComps.Length];

            // Build the phoneme maps
            for (int i = 0; i < pmComps.Length; i++)
            {
                PhoneMapCompressed pmCompressed = pmComps[i];
                PhoneMap           pm           = phoneMaps[i] = new PhoneMap();
                pm._lcid     = pmCompressed._lcid;
                pm._phoneIds = new PhoneId[pmCompressed._count];

                int posPhone = 0;
                int posCp    = 0;
                for (int j = 0; j < pm._phoneIds.Length; j++)
                {
                    pm._phoneIds[j] = new PhoneId();
                    // Count the number of chars in the phoneme string
                    int lastPhone;
                    int multi_phones = 0;
                    for (lastPhone = posPhone; pmCompressed._phones[lastPhone] != 0; lastPhone++)
                    {
                        // All phoneme code points are assumed to be of length == 1
                        // if the length is greater, then a marker of -1 is set for each additional code points
                        if (pmCompressed._phones[lastPhone] == unchecked ((byte)-1))
                        {
                            multi_phones++;
                        }
                    }

                    // Build the phoneme string
                    int    strLen = lastPhone - posPhone - multi_phones;
                    char[] phone  = new char[strLen];
                    for (int l = 0; l < strLen; l++)
                    {
                        phone[l] = (char)pmCompressed._phones[posPhone++];
                    }

                    // Update the index for the next phoneme string
                    posPhone += multi_phones + 1;

                    // Copy the code points for this phoneme
                    pm._phoneIds[j]._phone = new string(phone);
                    pm._phoneIds[j]._cp    = new char[multi_phones + 1];
                    for (int l = 0; l < pm._phoneIds[j]._cp.Length; l++)
                    {
                        pm._phoneIds[j]._cp[l] = pmCompressed._cps[posCp++];
                    }
                }

                // Ensure that the table is built properly
                System.Diagnostics.Debug.Assert(posPhone == pmCompressed._phones.Length);
                System.Diagnostics.Debug.Assert(posCp == pmCompressed._cps.Length);
            }
            return(phoneMaps);
        }
Beispiel #2
0
 private PhonemeConverter(PhoneMap phoneMap)
 {
     _phoneMap = phoneMap;
 }