Solved

Play a wav file over phone line

Posted on 2002-06-01
19
450 Views
Last Modified: 2012-06-21
Hi
I am workig on a little demo oriject
i am dialiing a specific telephone number, now when the user picks up the phone, i need to play a wav file so the user on the ohone hears te wav file.

is there a way to do this

thanx

Craig
0
Comment
Question by:CraigLazar
19 Comments
 
LVL 17

Accepted Solution

by:
inthedark earned 16 total points
ID: 7049205
Have you found your way to the TAPI documentation yet?

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tapi/tapi30portal_75t1.asp

If you subscribe to the MSDN Microsoft send you about a million CDs each year one of them is the Windows SDK which includes the documentation for TAPI.

You will find some code snippets here:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tapi/callover_5fqk.asp
0
 
LVL 17

Expert Comment

by:inthedark
ID: 7049210
0
 
LVL 17

Expert Comment

by:inthedark
ID: 7049217
0
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 
LVL 4

Author Comment

by:CraigLazar
ID: 7049266
thanx guys
i will have a good look

cheers
0
 
LVL 4

Author Comment

by:CraigLazar
ID: 7050775
Hi Guys
thanx for the input, i have had a brief look at the urls thnax , do any of u guiys maybe have sample code or anything, i am not to clued up the the Tapi functions and calls

thanx
Craig
0
 
LVL 17

Expert Comment

by:inthedark
ID: 7052998
0
 
LVL 4

Author Comment

by:CraigLazar
ID: 7053218
Hi there intheDark
I went to the url u gave me last, i am trying to find the TAPI30 sdk, i am running win 2000, anyway your url said i must go to the micrisift site under telephony and download the TAPI30 sdk, but i could not find it,
do u perhaps know where i could find it ?

thanx

Craig
0
 
LVL 17

Expert Comment

by:inthedark
ID: 7053982
It looks like they have moved it. I posted a question to Microsoft to see where they put it.
0
 
LVL 17

Expert Comment

by:inthedark
ID: 7061257
The TAPI SDK is included in the core SDK download:

http://www.microsoft.com/msdownload/platformsdk/sdkupdate/

0
 
LVL 4

Author Comment

by:CraigLazar
ID: 7061381
Thanx allot

I will check it this weekend

have a good one

Craig
0
 
LVL 17

Expert Comment

by:inthedark
ID: 7061469
I hope yo have a fast link its a 250M download
0
 
LVL 4

Author Comment

by:CraigLazar
ID: 7069693
hi inthedark
sorry i have not gotton back to u sooner,
got the day of for the next 2 days, so i can sit sown and spend some time on it

thanx

Craig
0
 

Expert Comment

by:fdecker
ID: 7194652
Have you looked at a toolkit to make this much easier for you?  With a good one, you could basically write this much code and get what you want:

enable device
go off hook
ondialtone, dial number
open wavefile
play wave file

TeleTools just upgraded to v3.7 with pretty sophisticated wave tools with ffw, rewind, pause, play from a certain point, etc.  Depending on how big or small your project is, you might want to look at having the hard work done for you and avoiding TAPI and API stuff yourself.

Fred
0
 

Expert Comment

by:jpconver
ID: 7377037
Hi I4m also working on a small project like you and I
think this code will help you...

If you don4t have the Telephony control in your code maybe you need to install the Microsoft Speech SDK 4.0 and after that you need to add the component to a form on your code.

After that create a wav file of 8 Khz,8 bits called msg9.wav and paste this code on a form:


'This is a very simple answering machine.
'It just takes a message and writes it to a wave file in a subdirectory of the application directory.
'You can just double click on the messages and they will be played by the system sound player.

Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" _
         (hpvDest As Any, hpvSource As Any, ByVal cbCopy As Long)
         

Private Sub ViewDirectory()
'This function simply causes the Explorer to display the Messages directory (and creates it if needed),
'so each time a new message is recorded, an icon appears that can be double clicked on.
'First we try command as if we are in windows 9x, and if that doesn't work, try NT's cmd function.
On Error Resume Next
Dim slash As String
If Right(App.Path, 1) = "\" Then
    slash = ""
Else
    slash = "\"
End If
    mdir = App.Path + slash + "Messages"
    MkDir mdir
    ChDrive mdir
    ChDir mdir
    Shell "command.com /c start .", vbMinimizedNoFocus
    Shell "cmd /c start .", vbMinimizedNoFocus
End Sub

Private Sub Command1_Click()

    phone1.Initialized = 1 'run on emulator
    phone1.CallDialog
End

End Sub

Private Sub Command2_Click()

   phone1.Initialized = 2 'run on real phone
   phone1.CallDialog
End

End Sub

Private Sub Form_Load()
    ViewDirectory
End Sub

Private Sub phone1_DoPhoneCall(ByVal lineID As Long)
'This function gets called each time the phone is answered, for each phone line.
'Because Telephony supports multiple phone lines, this function may be called simultaneously
'several times, each version (identified by lineID) running on a different thread.
Dim result As Long
Dim size As Long
Dim wave As Long
Dim wavefile() As Byte
Dim filename As String

On Error Resume Next
    size = 0

    'this line causes a recorded wave file to be used in place of the text wherever it is spoken.
    '(if you comment out this line, the text-to-speech engine would be used instead)
    'This feature exists so you can prototype your program with text-to-speech, then use
    'the wave list editor to do recordings of the string.  See the docs for more details.
   
    phone1.WaveAddFromListString lineID, "[FromFile]" + vbNewLine + App.Path + _
        "\msg9.wav=Hi. We can't come to the phone right now. Please leave a message at the beep."

    'this is the heart of the program.  The prompts are spoken (or played if the waveadd worked),
    'and the callers message is stored in wave.  See the docs for definitions of the settings used.
    'phone1.RecordFromString lineID, "[Prompts]" + vbNewLine + _
    '                            "Main=Hi. We can't come to the phone right now. Please leave a message at the beep." + vbNewLine + _
    '                            "[Settings]" + vbNewLine + _
    '                            "BetweenUtt=10000" + vbNewLine + _
    '                            "InitialBuf=30000" + vbNewLine + _
    '                            "ReallocBuf=30000" + vbNewLine + _
    '                            "MaxBuf=300000" + vbNewLine + _
    '                            "NoAnswerTime=10" + vbNewLine _
    '                            , result, wave, size
                               
    phone1.ExtensionFromString lineID, "[Prompts]" + vbNewLine + _
                                "Main=Hi. We can't come to the phone right now. Please leave a message at the beep." + vbNewLine + _
                                "[Settings]" + vbNewLine + _
                                "BetweenUtt=10000" + vbNewLine + _
                                "InitialBuf=30000" + vbNewLine + _
                                "ReallocBuf=30000" + vbNewLine + _
                                "MaxBuf=300000" + vbNewLine + _
                                "NoAnswerTime=10" + vbNewLine _
                                , result, "test"
   
       
    If (size <> 0) Then
        'The following "casts" the wave to an array (by making a copy of it) so we can save it out to disk.
        ReDim wavefile(size)
        CopyMemory wavefile(0), ByVal wave, size
   
        'free the wave as soon as possible so we dont pig up memory
        phone1.FreeWave wave
   
        'use the date and time as the filename, and put into the Messages directory
        filename = App.Path + "\Messages" + "\Message left at " + Format(Now, "hh mm ss AMPM") + " " + Format(Now, " mmm d yyyy") + ".wav"
   
        'write the wave data out to disk. you can double click on the file to play it with sound recorder.
        Open filename For Binary Access Write As #1
        Put #1, , wavefile
        Close #1
    End If
    'hang up and wait for next call
End Sub



0
 
LVL 4

Author Comment

by:CraigLazar
ID: 7377266
Hi Jpconver

thanx for the input
i still not managed to get it working at the moment, i just gave the app to the client for now just so they had something to work with, i will take a look and see if you code will help

thanx allot again

cheers

Craig
0
 
LVL 1

Expert Comment

by:kodiakbear
ID: 7522862
Dear fdecker
I've rejected your proposed answer as Experts Exchange holds an experiment to work without the answer button.

See: <http://www.experts-exchange.com/jsp/communityNews.jsp>
Paragraph: Site Update for Wednesday, November 06, 2002

By this rejection the Asker will be notified by mail and hopefully he will take his responsibility to finalize the question or post an additional comment.
The Asker sees a button beside every post which says "Accept This Comment As Answer" (including rejected answers) -- so if he/she thinks yours is the best, you'll be awarded the points and the grade.

EXPERTS: I will return in seven days to close this question.
Please leave your thoughts and recommendations here

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER !

Thanks !

kodiakbear
Experts Exchange Moderator
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 7851369
Hi CraigLazar,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:

    Accept jpconver's comment(s) as an answer.

CraigLazar, if you think your question was not answered at all or if you need help, just post a new comment here; Community Support will help you.  DO NOT accept this comment as an answer.

EXPERTS: If you disagree with that recommendation, please post an explanatory comment.
==========
DanRollins -- EE database cleanup volunteer
0
 
LVL 4

Author Comment

by:CraigLazar
ID: 7858215
Hi Dan
Sorry fpr not getting back top this question
unfortunatley i was unable to get the app working the way i needed, please can u split the points to the people that tried to help me with this question

thanx

Craig
0
 

Expert Comment

by:SpideyMod
ID: 7913037
Split points.

SpideyMod
Community Support Moderator @Experts Exchange

jpconver points for you at:
http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/Q_20506488.html

fdecker points for you at:
http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/Q_20506486.html
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

785 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question