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?
Printable View
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?
Can you show the part where you're saving and editing these values.
Here's my code.
VB Code:
Option Explicit Private m_lOrgPitch As Long Private m_lOrgSpeed As Long Private m_bReset As Boolean Private Sub cmdAction_Click(Index As Integer) Select Case Index Case 0 'test TestVoice Case 1 'save Case 2 'reset m_bReset = True Reset End Select End Sub Private Sub TestVoice() Dim lSpeed As Long Dim lPitch As Long lSpeed = Val(txtSpeed.Text) If lSpeed < DirectSS1.MinSpeed Then lSpeed = DirectSS1.MinSpeed If lSpeed > DirectSS1.MaxSpeed Then lSpeed = DirectSS1.MaxSpeed lPitch = Val(txtPitch.Text) If lPitch < DirectSS1.MinPitch Then lPitch = DirectSS1.MinPitch If lPitch > DirectSS1.MaxPitch Then lPitch = DirectSS1.MaxPitch DirectSS1.Pitch = lPitch DirectSS1.Speed = lSpeed m_bReset = False LoadTxtBoxes DirectSS1.Speak txtTest.Text End Sub Private Sub Form_Load() m_lOrgPitch = DirectSS1.Pitch m_lOrgSpeed = DirectSS1.Speed LoadTxtBoxes End Sub Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer) If m_lOrgPitch <> DirectSS1.Pitch Or m_lOrgSpeed <> DirectSS1.Speed Then Select Case MsgBox("Would you like to keep the new settings?", vbYesNo Or vbQuestion Or vbDefaultButton1, App.Title) Case vbYes ' DirectSS1.Pitch.save 'not a valid command DirectSS1.Speak "New settings have been saved!" 'she just lied, it's not saving the settings Case vbNo Reset DirectSS1.Speak "The old settings have been reset." End Select End If End Sub Private Sub Reset() DirectSS1.Pitch = m_lOrgPitch DirectSS1.Speed = m_lOrgSpeed LoadTxtBoxes End Sub Private Sub LoadTxtBoxes() txtPitch.Text = CStr(DirectSS1.Pitch) txtSpeed.Text = CStr(DirectSS1.Speed) End Sub
You can save these settings to an ini file or you can use the dirty method using the registry SaveSetting and GetSetting. ;)
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.
It does for me, I save my settings to an ini file. ;)Quote:
Originally Posted by longwolf
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.
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. ;)
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 :)