PB开发语音软件,如何设置男声或女声?
admin 发表于 2010-09-25 | 来源:互联网 | 阅读:

现在使用PB开发一个语音朗读软件, XP系统语音引擎有Microsoft Mary(女声), Microsoft Sam(男声) . 要指定使用其中一个声音. 但不知在PB下如何设置函数 tts.setvoice() 的参数?

附 源程序

1、先声明实例变量
oleobject tts

2、窗口打开时,实例化变量

 //调用SAPI语音,前提已装好SAPI
 long ll_status
 tts = CREATE OLEObject
 ll_status = tts.ConnectToNewObject("SAPI.SpVoice")
 
 IF ll_status <> 0 THEN
  messagebox(‘调用错误’,'您可能还未安装语音库!’)
  tts.DisconnectObject()
  DESTROY tts
 else
  wf_ini()
 end if
 //其中,Wf_ini为窗口函数
 /取得当前安装的语音引擎和输出的音频设备 
 //注意,像VB等语言,数组下标以’0′开始
 //返回1,正常;返回0,取得引擎失败;返回-1,取得音频设备失败(可能未安装声卡)
 integer n,m
 string ls_desp
 //取得引擎列表
 m = integer(tts.GetVoices.Count)
 if m < 1 then return 0
 for n=1 to m
  ls_desp = string(tts.GetVoices.Item[n - 1].GetDescription())
  if n=1 then ddlb_voice.text = ls_desp
  ddlb_voice.additem(ls_desp)
 next
 //取得音频输出列表
 m = tts.GetAudioOutputs.count
 if m < 1 then return -1
 for n=1 to m
  ls_desp =string(tts.GetAudioOutputs.Item[n - 1].GetDescription())
  if n=1 then ddlb_audio_out.text = ls_desp
  ddlb_audio_out.additem(ls_desp)
 next
 return 1

  tts.setvocie( ????? )

3、朗读
 string ls_read
 integer li_ret
 //终止先前朗读,如果有
 li_ret = tts.speak(" ","2")
 
 //异步朗读
 li_ret = tts.speak(mle_read.text,"1")

已经有12 个评论
  1. 徐咏波 说:

    帮顶  。。。。。。

  2. aw3fae 说:

    不知道,估计是男声/女声分别录音,再分别存放。。。

  3. mikeyao210 说:
  4. doing7 说:

    楼主是否应该从ddlb_voice中得到 引擎index然后设置tts.voice=tts.GetVoices.item(index -1)执行 tts.speak(context,11)即可

  5. boysee 说:

    楼上正解tts.voice=tts.GetVoices.item(index -1)来设置语音引擎Voice PropertyThe Voice property specifies the SpVoice object associated with the recognition context.SyntaxSet: SpeechRecoContext.Voice = SpVoice  

  6. wuwei04 说:

    帮顶!这个试过,感觉挺消

  7. hahamy 说:
  8. yyyy6 说:

    帮顶   。。。。。。

  9. nashliu 说:

    4楼, 5楼正解. 谢谢!

  10. 421056 说:

    学习中。。。

  11. 96789123 说:

    掌握真知

  12. dovemail 说:

    我已经回复过了。

我要评论

评论功能因故关闭!

请加入我们的QQ群一起参与讨论:群号59400482(500人超级群)


返回首页 | 关于我们 | 联系我们 | 广告合作 | 网站地图 | 友情链接 | 版权声明