VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Plays wav files based on the selected number.

by Muhammad Zeeshan Naeem (2 Submissions)
Category: Sound/MP3
Compatability: Visual Basic 5.0
Difficulty: Unknown Difficulty
Originally Published: Sun 24th November 2002
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Plays wav files based on the selected number.

API Declarations


' [email protected]
'make folder name "voice" and keep it where u make a project

Private Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
Dim ln As Integer
Const SND_SYNC = &H0
Const SND_ASYNC = &H1
Const SND_NODEFAULT = &H2
Const SND_LOOP = &H8
Const SND_NOSTOP = &H10

Rate Plays wav files based on the selected number.



[email protected]
'copy this code in the code window
' make one text box and three command button make the caption of the buttons
'as 1: speak , 2: stop   3:  continue
   ' to get the voices mail me at ([email protected])

  
  

Private Sub Command1_Click()
If Val(Text1.Text) >= 0 And Val(Text1.Text) < 19 Then
Call Unit(Text1.Text)
ElseIf Val(Text1.Text) > 20 And Val(Text1.Text) < 100 Then
Call Ten(Text1.Text)
ElseIf Val(Text1.Text) > 100 And Val(Text1.Text) < 999 Then
Call Hund(Text1.Text)
ElseIf Val(Text1.Text) > 999 And Val(Text1.Text) < 99999 Then
Call Thous(Text1.Text)
ElseIf Val(Text1.Text) > 99999 And Val(Text1.Text) < 9999999 Then
Call lac(Text1.Text)
Else
MsgBox "plz use continues button for longe number", vbInformation, "longe number"
End If
End Sub

Private Sub Command2_Click()
End
End Sub
Sub Unit(i As String)
sndplay = sndPlaySound(App.Path & "\voice\" & i & ".wav", 1)
End Sub
Sub Ten(i As String)
Dim a As Integer
Dim b As Integer
a = Mid(i, 1, 1)
b = Mid(i, 2, 1)
If b <> 0 Then
wflags = SND_SYNC
sndplay = sndPlaySound(App.Path & "\voice\" & a & "0.wav", wflags)
sndplay = sndPlaySound(App.Path & "\voice\" & b & ".wav", 1)
End If
End Sub
Sub Hund(i As String)
Dim a As Integer, b As Integer, c As Integer
a = Mid$(i, 1, 1)
b = Mid$(i, 2, 1)
c = Mid$(i, 3, 1)
wflags = SND_SYNC
If b = 0 And c = 0 Then
sndplay = sndPlaySound(App.Path & "\voice\" & a & ".wav", wflags)
sndplay = sndPlaySound(App.Path & "\voice\100.wav", wflags)
ElseIf c = 0 Then
sndplay = sndPlaySound(App.Path & "\voice\" & a & ".wav", wflags)
sndplay = sndPlaySound(App.Path & "\voice\100.wav", wflags)
sndplay = sndPlaySound(App.Path & "\voice\" & b & "0.wav", wflags)
ElseIf b = 0 Then
sndplay = sndPlaySound(App.Path & "\voice\" & a & ".wav", wflags)
sndplay = sndPlaySound(App.Path & "\voice\100.wav", wflags)
sndplay = sndPlaySound(App.Path & "\voice\" & c & ".wav", wflags)
ElseIf b = 1 Then
sndplay = sndPlaySound(App.Path & "\voice\" & a & ".wav", wflags)
sndplay = sndPlaySound(App.Path & "\voice\100.wav", wflags)
sndplay = sndPlaySound(App.Path & "\voice\" & b & c & ".wav", wflags)
Else
sndplay = sndPlaySound(App.Path & "\voice\" & a & ".wav", wflags)
sndplay = sndPlaySound(App.Path & "\voice\100.wav", wflags)
sndplay = sndPlaySound(App.Path & "\voice\" & b & "0.wav", wflags)
sndplay = sndPlaySound(App.Path & "\voice\" & c & ".wav", wflags)
End If
End Sub

Private Sub Command3_Click()
ln = Len(Text1.Text)
For i = 1 To ln
a = Mid(Text1.Text, i, 1)
If a = "." Then
sndplay = sndPlaySound(App.Path & "\voice\p.wav ", wflags)
Else
sndplay = sndPlaySound(App.Path & "\voice\" & a & ".wav", wflags)
End If
Next i
End Sub

Private Sub Text1_Change()
If Mid(Text1.Text, 1, 1) = 0 Then
Text1.Text = Clear
End If
End Sub

Sub Thous(i As String)
Dim k As Integer, l As Integer, bc As String
wflags = SND_SYNC
k = Mid$(i, 1, 1)
''
If Len(i) = 4 Then
bc = Mid$(i, 2, 4)
sndplay = sndPlaySound(App.Path & "\voice\" & k & ".wav", wflags)
sndpaly = sndPlaySound(App.Path & "\voice\1000.wav", wflags)
Call Hund(bc)
ElseIf Len(i) = 5 Then
l = Mid$(i, 2, 1)
bc = Mid$(i, 3, 5)
If k = 1 Then
sndplay = sndPlaySound(App.Path & "\voice\" & k & l & ".wav", wflags)
sndpaly = sndPlaySound(App.Path & "\voice\1000.wav", wflags)
Call Hund(bc)
Else

sndplay = sndPlaySound(App.Path & "\voice\" & k & "0.wav", wflags)
sndplay = sndPlaySound(App.Path & "\voice\" & l & ".wav", wflags)
sndpaly = sndPlaySound(App.Path & "\voice\1000.wav", wflags)
Call Hund(bc)
End If
End If
end sub


Private Sub Text1_LostFocus()
If IsNumeric(Text1.Text) = False Then
MsgBox "Right only numeric value", vbCritical, "error"
Text1.SetFocus
SendKeys "{home}+{end}"
End If
End Sub
Sub lac(i As String)
Dim m As Integer, n As Integer, ab As String
wflags = SND_SYNC
m = Mid(i, 1, 1)
If Len(i) = 6 Then
ab = Mid(i, 2, 6)
sndplay = sndPlaySound(App.Path & "\voice\" & m & ".wav", wflags)
sndpaly = sndPlaySound(App.Path & "\voice\100000.wav", wflags)
Call Thous(ab)
ElseIf Len(i) = 7 Then
n = Mid(i, 2, 1)
ab = Mid(i, 3, 7)
If m = 1 Then
sndplay = sndPlaySound(App.Path & "\voice\" & m & n & ".wav", wflags)
sndpaly = sndPlaySound(App.Path & "\voice\100000.wav", wflags)
Call Thous(ab)
Else
sndplay = sndPlaySound(App.Path & "\voice\" & m & "0.wav", wflags)
sndpaly = sndPlaySound(App.Path & "\voice\" & n & ".wav", wflags)
sndpaly = sndPlaySound(App.Path & "\voice\100000.wav", wflags)
Call Thous(ab)
End If
End If
End Sub


' u can make it enable by record the voices with extention .wav
'u will be record these words eg. u say one and record it by Ms redorder in ur voice and so all these words that i write 
' ( 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,30,4,50,60,70,80,90,100
' 1000,100000)
  ' save their name eg.  "1.wav", "2.wav", "30.wav" and so on 
' thanx 4 using my code 
  ' mail me and asked if any question u have
   '
        ' [email protected]


Download this snippet    Add to My Saved Code

Plays wav files based on the selected number. Comments

No comments have been posted about Plays wav files based on the selected number.. Why not be the first to post a comment about Plays wav files based on the selected number..

Post your comment

Subject:
Message:
0/1000 characters