C#播报语音:检索 COM 类工厂中 CLSID 为 {00024500-0000-0000-C000-000000000046} 的组件时失败...

解决语音播报难题
本文介绍了在实现语音播报功能过程中遇到的问题及解决方案。针对COM类工厂中特定CLSID组件检索失败的错误进行了探讨,并提供了两种实现语音播报的方法:一种使用System.Speech.Synthesis,另一种使用SpeechLib,最终证实后者有效。

 

在做语音播报功能的时候遇到下面的错误,摸索很久

检索 COM 类工厂 CLSID 为 {00024500-0000-0000-C000-000000000046} 的组件时失败,原因是出现以下错误: 80070005

在网上搜索说在VS中添加Microsoft Speech Object Library引用,但是在COM中找了半天都没有找到这个,没有找到这个咱也不怕,去百度下载一个SpeechLib.dll并且引入就可以了

播报语音的方法有两种

1.using System.Speech.Synthesis;

 1 using System;
 2 using System.Collections.Generic;
 3 using System.Linq;
 4 using System.Text;
 5 using System.Speech.Synthesis;
 6 
 7 namespace Com.HuaQin.Restaurant.Tools
 8 {
 9     
10      
11 
12     public class SpeechUtil
13     {
14         
15         public static void SpeekText(string sptext)
16         {
17             try
18             {
19                 SpeechSynthesizer reader = new SpeechSynthesizer();
20                 reader.SpeakAsync(sptext);
21             }
22             catch (Exception ex)
23             { 
24             }
25 
26         }
27     }
28 }
View Code

但是这种方法还是失败了!没有测试成功,

2.using SpeechLib;

 1 using System;
 2 using System.Collections.Generic;
 3 using System.Linq;
 4 using System.Text;
 5 using SpeechLib;
 6 
 7 namespace Com.HuaQin.Restaurant.Tools
 8 {
 9     public class SpeechUtil
10     {      
11         public static void SpeekText(string sptext)
12         {
13             try
14             {
15                 SpVoice voice = new SpVoice();
16                 voice.Speak(sptext, SpeechVoiceSpeakFlags.SVSFlagsAsync);
17                 //SpeechSynthesizer reader = new SpeechSynthesizer();
18                 //reader.SpeakAsync(sptext);
19             }
20             catch (Exception ex)
21             { 
22             }
23 
24         }
25     }
26 }
View Code

这个方法亲测是可以的!

转载于:https://www.cnblogs.com/xcswswswws/p/5257663.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值