示例#1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="synthesizer"></param>
        /// <param name="player"></param>
        /// <param name="text"></param>
        /// <param name="cancellationToken"></param>
        /// <exception cref="ArgumentNullException"></exception>
        /// <exception cref="ArgumentException"></exception>
        /// <returns></returns>
        public static async Task PlayAsync(
            this ISynthesizer synthesizer,
            IPlayer player,
            string text,
            CancellationToken cancellationToken = default)
        {
            synthesizer = synthesizer ?? throw new ArgumentNullException(nameof(synthesizer));
            player      = player ?? throw new ArgumentNullException(nameof(player));
            text        = text ?? throw new ArgumentNullException(nameof(text));

            var settings = synthesizer.SupportedSettings.First();

            var bytes = await synthesizer.ConvertAsync(text, settings, cancellationToken)
                        .ConfigureAwait(false);

            await player.PlayAsync(bytes, settings, cancellationToken)
            .ConfigureAwait(false);
        }
示例#2
0
 public void SetSynthesizer(ISynthesizer synthesizer)
 {
     Contract.Assert(null == _synthesizer);
     Contract.Assert(null != synthesizer);
     _synthesizer = synthesizer;
 }
示例#3
0
            private bool _disposedValue = false; // To detect redundant calls

            #endregion Fields

            #region Constructors

            public Tracker(PointerHandler parent, ISynthesizer synthesizer)
            {
                _parent = parent;
                _synthesizer = synthesizer;
            }