Results 1 to 9 of 9

Thread: changing/saving text-to-speech settings

  1. #1

    Thread Starter
    Frenzied Member longwolf's Avatar
    Join Date
    Oct 2002
    Posts
    1,343

    changing/saving text-to-speech settings

    I want to make a small app to set the speed and pitch of the current text-to-speech engine.
    I've found how to change them, but it doesn't keep the new settings after the app closes.

    anyone know how to save the new settings?

  2. #2
    Addicted Member
    Join Date
    Apr 2006
    Posts
    155

    Re: changing/saving text-to-speech settings

    Can you show the part where you're saving and editing these values.

  3. #3

    Thread Starter
    Frenzied Member longwolf's Avatar
    Join Date
    Oct 2002
    Posts
    1,343

    Re: changing/saving text-to-speech settings

    Here's my code.

    VB Code:
    1. Option Explicit
    2.  
    3. Private m_lOrgPitch As Long
    4. Private m_lOrgSpeed As Long
    5. Private m_bReset As Boolean
    6.  
    7. Private Sub cmdAction_Click(Index As Integer)
    8.     Select Case Index
    9.         Case 0 'test
    10.             TestVoice
    11.         Case 1 'save
    12.            
    13.         Case 2 'reset
    14.             m_bReset = True
    15.             Reset
    16.     End Select
    17. End Sub
    18.  
    19. Private Sub TestVoice()
    20.     Dim lSpeed As Long
    21.     Dim lPitch As Long
    22.    
    23.     lSpeed = Val(txtSpeed.Text)
    24.     If lSpeed < DirectSS1.MinSpeed Then lSpeed = DirectSS1.MinSpeed
    25.     If lSpeed > DirectSS1.MaxSpeed Then lSpeed = DirectSS1.MaxSpeed
    26.    
    27.     lPitch = Val(txtPitch.Text)
    28.     If lPitch < DirectSS1.MinPitch Then lPitch = DirectSS1.MinPitch
    29.     If lPitch > DirectSS1.MaxPitch Then lPitch = DirectSS1.MaxPitch
    30.    
    31.     DirectSS1.Pitch = lPitch
    32.     DirectSS1.Speed = lSpeed
    33.     m_bReset = False
    34.     LoadTxtBoxes
    35.     DirectSS1.Speak txtTest.Text
    36. End Sub
    37.  
    38. Private Sub Form_Load()
    39.     m_lOrgPitch = DirectSS1.Pitch
    40.     m_lOrgSpeed = DirectSS1.Speed
    41.     LoadTxtBoxes
    42. End Sub
    43.  
    44. Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
    45.     If m_lOrgPitch <> DirectSS1.Pitch Or m_lOrgSpeed <> DirectSS1.Speed Then
    46.         Select Case MsgBox("Would you like to keep the new settings?", vbYesNo Or vbQuestion Or vbDefaultButton1, App.Title)
    47.             Case vbYes
    48. '                DirectSS1.Pitch.save 'not a valid command
    49.                 DirectSS1.Speak "New settings have been saved!"
    50. 'she just lied, it's not saving the settings
    51.             Case vbNo
    52.                 Reset
    53.                 DirectSS1.Speak "The old settings have been reset."
    54.         End Select
    55.     End If
    56. End Sub
    57.  
    58. Private Sub Reset()
    59.     DirectSS1.Pitch = m_lOrgPitch
    60.     DirectSS1.Speed = m_lOrgSpeed
    61.     LoadTxtBoxes
    62. End Sub
    63.  
    64. Private Sub LoadTxtBoxes()
    65.     txtPitch.Text = CStr(DirectSS1.Pitch)
    66.     txtSpeed.Text = CStr(DirectSS1.Speed)
    67. End Sub

  4. #4
    PowerPoster Keithuk's Avatar
    Join Date
    Jan 2004
    Location
    Staffordshire, England
    Posts
    2,236

    Re: changing/saving text-to-speech settings

    You can save these settings to an ini file or you can use the dirty method using the registry SaveSetting and GetSetting.
    Keith

    I've been programming with VB for 25 years. Started with VB4 16bit Pro, VB5 Pro, VB6 Pro/Enterprise and now VB3 Pro. But I'm no expert, I'm still learning.

  5. #5

    Thread Starter
    Frenzied Member longwolf's Avatar
    Join Date
    Oct 2002
    Posts
    1,343

    Re: changing/saving text-to-speech settings

    thanks Keith,

    But the point of the app is to change the voice settings so that they stay that way no matter which program uses the voice.

    For example, the default Mary voice sounds really bad.
    But if you change both her pitch and speed to about 170, she doesn't sound too bad at all.
    But not all programs that use TTS allow you to change or save the settings.

  6. #6
    PowerPoster Keithuk's Avatar
    Join Date
    Jan 2004
    Location
    Staffordshire, England
    Posts
    2,236

    Re: changing/saving text-to-speech settings

    Quote Originally Posted by longwolf
    But not all programs that use TTS allow you to change or save the settings.
    It does for me, I save my settings to an ini file.
    Keith

    I've been programming with VB for 25 years. Started with VB4 16bit Pro, VB5 Pro, VB6 Pro/Enterprise and now VB3 Pro. But I'm no expert, I'm still learning.

  7. #7

    Thread Starter
    Frenzied Member longwolf's Avatar
    Join Date
    Oct 2002
    Posts
    1,343

    Re: changing/saving text-to-speech settings

    which ini are you talking about?

    let me explain better.
    I want this app only to adjust the settings.

    Then if I open another program like Casino Verite, which uses msagent, the new setting will be heard there as well.

  8. #8
    PowerPoster Keithuk's Avatar
    Join Date
    Jan 2004
    Location
    Staffordshire, England
    Posts
    2,236

    Re: changing/saving text-to-speech settings

    You make your own ini file for the app your using.

    By default the DirectSS1.Speed = 150, DirectSS1.Pitch = 125, DirectSS1.MaxSpeed = 250, DirectSS1.MinSpeed = 50

    So when your app starts get these settings from the ini file and when it closes save them back to the ini file.

    You have to watch out using the Speed and Pitch as sometimes it will give errors.
    Keith

    I've been programming with VB for 25 years. Started with VB4 16bit Pro, VB5 Pro, VB6 Pro/Enterprise and now VB3 Pro. But I'm no expert, I'm still learning.

  9. #9

    Thread Starter
    Frenzied Member longwolf's Avatar
    Join Date
    Oct 2002
    Posts
    1,343

    Re: changing/saving text-to-speech settings

    Yes Keith,

    I know I could do that for my own program.

    But I want to change the default settings of the speech engine itself so that after changing them EVERY program I have that uses TTS will be using the new settings.

    For example the Verite program I mentioned doesn't have an ini file for voice settings.
    And I don't want to backward engineer it just to add one

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width