基于Windows TTS的语音实时播报终端

语音播报终端基于Windows TTS SDK,即Text To Speech。使用ActiveMQ作为播报数据消息服务,各终端通过实时监听数据广播地址获取数据信息,再通过TTS进行语音播报。

语音播报终端主要功能:

1.通过CMS监听消息服务广播地址,

2.通过TTS播报文本数据信息。

源程序:

1.监听广播地址

         public void startListener(string url, string username, string password, string receiveQueueStr)
        {
            try
            {
                //Create the Connection Factory  
                IConnectionFactory factory = new ConnectionFactory(url);
                IConnection connection = factory.CreateConnection(username, password);
                connection.Start();
                //Create the Session  
                session = connection.CreateSession();
                //Create the Consumer  
                consumer = session.CreateConsumer(new Apache.NMS.ActiveMQ.Commands.ActiveMQTopic(receiveQueueStr), null);
                consumer.Listener += new MessageListener(consumer_Listener);
            }
            catch
            {
                throw;
            }
        }



2.播放语音

        /*
         * 
         * 
         * 播放声音
         * 
         * 
         */
        public void play(string text)
        {
            SpeechSynthesizer reader = new SpeechSynthesizer();
            try
            {
                reader.Rate = defaultSpeed;
                reader.SelectVoice(defaultVoice);
                reader.SpeakAsync(text);
               
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            finally
            {
                reader.Dispose();
            }
        }


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值