Microsoft Speech SDK中多声卡切换的方法
在开发一个语音报警的程序中,要用到多声卡切换功能,在网上查找了好久都没有这介绍,普通运用到是不少。通过MSDN及不断的尝试,终于找到了切换方法,发出来供大家参考:
1、首先确定电脑中声卡的数量,提取声卡名称:
|
1 2 3 4 5 6 7 8 |
procedure TForm2.FormCreate(Sender: TObject); var i,count:Integer; begin count:= SpVoice1.GetAudioOutputs('','').Count; for I := 0 to count-1 do ComboBox1.Items.Add(SpVoice1.GetAudioOutputs('','').Item(i).GetDescription(0)); end; |
2、根据需要选择声卡:
|
1 2 3 4 |
procedure TForm2.ComboBox1Change(Sender: TObject); begin SpVoice1.AudioOutput := SpVoice1.GetAudioOutputs('','').Item(ComboBox1.ItemIndex); end; |
3、最后就可以根据你的选择,从不同的音箱播放内容了:
|
1 2 3 4 |
procedure TForm2.btn2Click(Sender: TObject); begin SpVoice1.Speak('BG6RSH的博客,网址:www.tansoo.cn',SVSFlagsAsync); end; |