Esempio n. 1
0
 public double GetDuration(LocalizedPhrase phrase, Sex speakerSex)
 {
     return(Enumerable.Range(0, Convert.ToInt32(phrase.TokensCount()))
            .Select(Convert.ToUInt32)
            .Select(phrase.Token)
            .Select(token => GetTokenDuration(token, phrase.Language(), speakerSex))
            .Sum() + 1.0);    //add secod like in IOS
 }
        void LocalizedSpeaker.Say(LocalizedPhrase phrase)
        {
            _logger.Method().Start(phrase.Text());

            try
            {
                _mediaElement.Stop();

                MediaPlaybackItem[] items = Enumerable.Range(0, Convert.ToInt32(phrase.TokensCount()))
                                            .Select(Convert.ToUInt32)
                                            .Select(phrase.Token)
                                            .Select(token => _voiceFileHelper.GetFileUri(token, phrase.Language(), _settingsRepository.GuideSpeakerSex))
                                            .Where(uri => uri != null)
                                            .Select(MediaSource.CreateFromUri)
                                            .Select(src => new MediaPlaybackItem(src))
                                            .ToArray();

                var playList = new MediaPlaybackList();
                items.ForEach(playList.Items.Add);

                _mediaElement.SetPlaybackSource(playList);
                _mediaElement.Play();
                _logger.Method().End();
            }
            catch (Exception exception)
            {
                _logger.Method().Exception(exception);
            }
        }