Solved

Play a wav file over phone line

Posted on 2002-06-01
19
445 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
Comment Utility
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
Comment Utility
0
 
LVL 17

Expert Comment

by:inthedark
Comment Utility
0
 
LVL 4

Author Comment

by:CraigLazar
Comment Utility
thanx guys
i will have a good look

cheers
0
 
LVL 4

Author Comment

by:CraigLazar
Comment Utility
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
Comment Utility
0
 
LVL 4

Author Comment

by:CraigLazar
Comment Utility
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
Comment Utility
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
Comment Utility
The TAPI SDK is included in the core SDK download:

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

0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 4

Author Comment

by:CraigLazar
Comment Utility
Thanx allot

I will check it this weekend

have a good one

Craig
0
 
LVL 17

Expert Comment

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

Author Comment

by:CraigLazar
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

728 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now