private void ConvertCompleteUnit() { if (_lastComplete == 0) { return; } if (_phonemeQueue.Count == 0) { Trace.TraceError("Failed to convert phonemes. Phoneme queue is empty."); return; } char[] array = new char[_lastComplete]; _phonemes.CopyTo(0, array, 0, _lastComplete); _phonemes.Remove(0, _lastComplete); char[] value = (_conversion != 0) ? _alphabetConverter.SapiToIpa(array) : _alphabetConverter.IpaToSapi(array); TTSEvent tTSEvent = null; long num = 0L; tTSEvent = (TTSEvent)_phonemeQueue.Peek(); TTSEvent tTSEvent2; for (int i = 0; i < _lastComplete; i += tTSEvent2.Phoneme.Length) { tTSEvent2 = (TTSEvent)_phonemeQueue.Dequeue(); num += tTSEvent2.PhonemeDuration.Milliseconds; } TTSEvent evt = TTSEvent.CreatePhonemeEvent(new string(value), "", TimeSpan.FromMilliseconds(num), tTSEvent.PhonemeEmphasis, tTSEvent.Prompt, tTSEvent.AudioPosition); SendToQueue(evt); }
internal string ConvertPronunciation(string pronunciation, int langId) { if (_alphabetConverter == null) { _alphabetConverter = new AlphabetConverter(langId); } else { _alphabetConverter.SetLanguageId(langId); } char[] array = _alphabetConverter.SapiToIpa(pronunciation.ToCharArray()); if (array != null) { pronunciation = new string(array); } else { Trace.TraceError("Cannot convert the pronunciation to IPA alphabet."); } return(pronunciation); }