ҡդӶ ʵŧ 纺촨շ٨絴͵ ᷹ФѺ

͵Դҷҧ Inbox Ѻ

˹ѡ
-
VB 6/VB.Net
ASP/ASP.Net
Ѻ¤
¹ҹ Flash Movie
ռͺش  
 RSS Feeds
 ǹŴ RSS Reader ...   Download  RSS Reader

Forum - www.g2gnet.com
Webmaster - www.g2gnet.com
Visitors - Session views
 5 6 1 6 1 7 1

7 ѹҤ ..2549
126 Users On-Line.
Visitors - Page views
 8 9 7 3 9 1 4
1 Ҿѹ ..2551

Google   
g2gnet.com
Ҵѡ:  

ᨡ VB6 ҹͤѧ§

Category »  VB 6/VB.Net
: Webmaster 23/12/2553   : 09:28
(ҹ : 33688) 
Text To Speech Synthesis ¡ TTS ӨӡѴ ŧͤ繤Ӿٴ ... 觷ҧҧҡѲҡѹҡ ˹§ҹҤѰͧ Ԩ¡ѹҹѺԺ ... ǹҤͧ͡¡պҧ ҡѡ ... ... ͧ仴٢ͧҧȷöҹФѺ www.oddcast.com ԴҵͧդѲҴ ҡѡԧ ¡شʹҡ ... ԧǡҹͤѧ Windows XP Ƿ Start -> Programs -> Accessories -> Accessibility -> Narrator 仴ٷ Control Panel -> Speech ҧФѺ ҡ礧ҹѹҷѹз еͧءªͧ TTS ¡¹ҹͧ ͡˹仨ҡ÷ö㹷ҧ֡ ѧջªѺԡ÷ҧµա 㹸áԨẺкͺѺ§ 觧ҹ§ ... 躷йʹǤԴͧûء෤ 㹴ҹ¹ ͹ѧɴ MS Visual Basic 6.0/SP6 ФѺ

    ͹ҹ TTS VB6 سͧӡôǹŴ Դͧ͹

    õԴҧ Default лҡ C:\Windows\Speech\ ФѺ ... ԴҤҡ

 

ǹŴ
ǹŴ Source Code Ѻ MS Visual Basic 6.0 - Service Pack 6
 ǹŴ Visual Basic 6.0 SP5: Run-Time Redistribution Pack
 ǹŴ Microsoft Data Access Object (MDAC) Jet 4.0 Update
 ǹŴ Microsoft Visual Basic Service Pack 6

Project --> Components ... Microsoft Direct Text-To-Speech


Project --> References ... ͡ Component º ǹѹѹѵѵ


͡Ẻ - Design Time


͹ӧҹ (Run Time) ... §ҡ ժ Microsoft Sam


ʴ駢ͤ ٻҾ § ... ö任ءѺ¹ͧͧѾҧ ...
Ҵ鴡ѹ ...

Option Explicit

' #####################################################
'  CommandButton е
' #####################################################
Private Sub cmdShowPicture_Click(Index As Integer)
    txtMessage.Visible = False
    
    ' ͡ Index  CommandButton 衴
    Select Case Index
        ' Dog
        Case 0:
            Call SpeakEnglish(cmdShowPicture(0).Caption)
            
        ' Cat
        Case 1:
            Call SpeakEnglish(cmdShowPicture(1).Caption)
            
        ' Pig
        Case 2:
            Call SpeakEnglish(cmdShowPicture(2).Caption)
            
        ' Ambulance
        Case 3:
            Call SpeakEnglish(cmdShowPicture(3).Caption)
        
    End Select

End Sub

' #####################################################
' ÷ӧҹ¡ѹ ӡѹ ¡͡«д
' 觤 Caption ͧе
' #####################################################
Sub SpeakEnglish(cmdName As String)
  
    Dim ctl As Control
    ' Ǩͺ͹աҧ Image  Label Control ѧ ҡź͡
    For Each ctl In Controls
        If ctl.Name = "imageTemp" Then
            Controls.Remove "imageTemp"
            Controls.Remove "LabelTemp"
            Exit For
        End If
    Next
    
    ' Сҹ Image Control  Label Control
    Dim img As Image
    Dim lbl As Label

    ' ҧ Image Control Ẻ Run Time
    Set img = Controls.Add("VB.Image", "imageTemp")
    ' 駤Ҥسѵ (Properties) Ẻ Run Time
    With img
        ' Ѵҧ˹觷ҧºش
        .Move 60, 90
        .Visible = True
    End With
    
    ' ҧ Label Control Ẻ Run Time
    Set lbl = Controls.Add("VB.Label", "LabelTemp")
    ' 駤Ҥسѵ (Properties) Ẻ Run Time
    With lbl
        ' Ѵҧ˹觵ѡ㹡ʴ
        .Move 60, sldSpeed.Top - 800
        .Font.Name = "Tahoma"
        .Font.Size = 16
        .FontBold = True
        ' ѺʹաѺͤ
        .AutoSize = True
        ' ѺբͺẺ Fixed Single
        .BorderStyle = 1
        ' յѡ
        .ForeColor = vbRed
        ' վѧ
        .BackColor = vbYellow
        .Visible = True
    End With
    
    ' ͡¡õ (Caption) ͧ (CommandButton) е
    Select Case LCase(cmdName)
        Case "dog"
            img.Picture = LoadPicture(App.Path & "\images\dog.jpg")
            lbl.Caption = "THEY ARE THE DOGS."
        Case "cat"
            img.Picture = LoadPicture(App.Path & "\images\cat.jpg")
            lbl.Caption = "IT IS A CAT."
        Case "pig"
            img.Picture = LoadPicture(App.Path & "\images\pig.jpg")
            lbl.Caption = "PIG, MOO NOI NOI."
        Case "ambulance"
            img.Picture = LoadPicture(App.Path & "\images\ambulance.jpg")
            lbl.Caption = "THIS IS AN AMBULANCE."
    End Select
    
    ' §͹ Ҩ§ҧ
    dssSpeak.AudioReset
    ' ҹͤ Caption ͧ Label Control
    dssSpeak.Speak lbl.Caption

End Sub

' #####################################################
' ҹ¤ TextBox Control (txtMessage)
' #####################################################
Private Sub cmdSpeakMessage_Click()

    txtMessage.Visible = True
    ' §͹ Ҩ§ҧ
    dssSpeak.AudioReset
    ' ҹͤ TextBox
    dssSpeak.Speak txtMessage.Text

End Sub

' #####################################################
' 鹡÷ӧҹ  ҸԵõ駤ҤسѵԢͧ Control Ẻ Run Time
' #####################################################
Private Sub Form_Load()
    Me.Move (Screen.Width - Width) \ 2, (Screen.Height - Height) \ 2

    ' õ駤ҤسѵԢͧ Control Ẻ Run Time
    With dssSpeak
        .MaxPitch = 200
        .MinPitch = 50
        .Pitch = 100
        .MaxSpeed = 450
        .MinSpeed = 30
        .Speed = 150
    End With
    
    ' 駤 Speed SliderBar çѺ Speed ͧ DirectSS
    With sldSpeed
        .Max = 450
        .Min = 30
        .Value = 150
    End With
    
    ' 駤 Pitch SliderBar çѺ Pitch ͧ DirectSS
    With sldPitch
        .Max = 200
        .Min = 50
        .Value = 100
    End With
    
    ' ˹¤Ѻ TextBox ͧ  , зشѡ
    txtMessage.Text = "Hello world, my name is thongkorn."
    
End Sub

' #####################################################
' ѺдѺ§
' #####################################################
Private Sub sldPitch_Change()
    dssSpeak.Pitch = sldPitch.Value
End Sub

' #####################################################
' Ѻ§
' #####################################################
Private Sub sldSpeed_Change()
    dssSpeak.Speed = sldSpeed.Value
End Sub

Private Sub cmdExit_Click()
    
    ' §͹ Ҩ§ҧ
    dssSpeak.AudioReset
    '    55555+
    dssSpeak.Speak "Ja Joob, Program, chai maii, ha ha ha"
    'dssSpeak.Speak "Ja Joob, Program, Click OK, ha ha ha"
    
    If MsgBox("سҵͧè÷ӧҹͧ ?", vbQuestion + _
        vbOKCancel + vbDefaultButton2, "׹ѹè") = vbOK Then
        Set frmTextToSpeech = Nothing
        End
    End If
End Sub
Conclusion:
ùʹͺҧ ҧ͹ҹͧФѺ ͤ Ҩҹ㴷͹ѧ »ꧡЩٴ 任ء 㹡èѴ͡¹ ͹ Ѳҷѡ 駴ҹÿѧ ҹ 駴ҹѾ ա ... ҡоѲաҹ 礧ͧ֡ ¹кҹ (DataBase) Ҵ ͪ¨Ѵ红ŤѾ ͸Ժ ˹ٻҾ ˹觡§ (Ѵ§ҡ www.oddcast.com ... ͧ Դ١ѹͧФѺ ... ͧ

͵ - g2gNet Dot Com
Ţ¹ҳԪ硷͹ԡ 0407314800231
CopyLeft © 2004 - 2099 g2gNet.Com All rights reserved.
Email: [email protected] . 08-6862-6560