none
VBA Code to set SAPI Voice Pitch under Windows Vista

    Question

  • Windows Vista allows you to change the pitch of the single voice provided by going through the Control Panel. Is there a SAPI (Speech Application Programming Interface) speech engine property that can be set in VBA code to change pitch? Below is a VBA code example of how I am using SAPI in an MS Access text-to-speech program I am developing.

    Thanks.

     

    Set VObj = CreateObject("SAPI.SpVoice")

    VObj.Volume = CInt(volumeSetting)

    VObj.Speak strText

     

    Thursday, June 17, 2010 6:24 PM

All replies

  • Hello,

    I looked at the properties of VObj in VBA (Debug mode, Locals window) - looks like there is none related to pitch. You can set Volume and Rate, other settings are picked up from whatever you do from Control Panel - Sound - (Device). Changes made from Control Panel for pitch have no effect on VObj.

    Nadia

    • Proposed as answer by NadiaSz Friday, June 18, 2010 1:13 PM
    Thursday, June 17, 2010 8:03 PM
  • Thank you for your response. I was hoping to be able to change the voice, similar to the 3-voice options available in Windows XP. Microsoft Anna speaks well, but its too bad Vista only offers one voice.

    Jerry

    Thursday, June 17, 2010 8:36 PM
  • Actually, Vista offers a range of settings from Control Panel. If you go to Control Panel-Sounds-Speaker-Properties, then on the Enhancements tab you can select Pitch Shift check box and then, using Settings combo box change value to -3 or -4 to have a man's voice. There are also settings for Equalizer, Environment and more.

    After doing some research, I found the way to change the pitch in VBA - you can do it using XML tag:

    VObj.Speak "<pitch middle = '-10'/>" + strText  'low pitch

    VObj.Speak "<pitch middle = '-10'/>" + strText  'high pitch

    Look at the http://blogs.msdn.com/b/speech/ to find more about the speech APIs.

    In addition, in VBE you can set a Reference to "Microsoft Speech Object Library" and then use its objects in VBA code.

    Nadia

     

    • Proposed as answer by NadiaSz Friday, June 18, 2010 1:13 PM
    Friday, June 18, 2010 2:53 AM
  • Thanks for enlightening me with the examples for changing SAPI voice pitch with XML. I tried it and it works.

    Jerry

    Friday, June 18, 2010 7:28 PM
  • You are welcome,

    Nadia

     

    Friday, June 18, 2010 11:06 PM