Hi,
just wondered if anyone has any experience in what I'm trying to do at the moment. I want to record a message and then be able to create a script which plays that message then hangs up. At mo I have twilio working which I have managed to record a message but this is stored on the twilio server and I dont know how to reference it within a dialog voip script. Now this message was recorded from a phone using the sample script:
voipscript_record Script
I can see this on the twilio server in the list of recordings and it has a sid but not sure if i can access it using a voip script to play it back to the number or my drupal voip scipts choice.
Also on the drupal voip test page there is two record options the "audio record" and the "contact message" I presume these are uploaded locally not to the twilio server. again how are these messages stored and how are they indexed and how can they be used within a voip script.
Cheers
Fishboy1669
Comments
Re: record and playback in a message
Hi Fishboy1669,
The execution of the VoipScript::addRecord() command automatically transfers the recorded file to your Drupal server and returns the "local" location of that file in the "recording_path" script variable. The method also sets "recording_public_url" with the public url of the file (*).
To play that file back, simply use something like $my_script->addSay("Here is what you recorded: %recording_public_url"); as in:
$script = new VoipScript('my_script');$prompt = "Please record your message after the beep. When done, press the pound key.";
$timeout = 5;
$end_key = '#';
$max_length = 20;
$script->addRecord($prompt, $timeout, $end_key, $max_length);
$script->addSay('You said %recording_public_url');
Does that answer your question?
Best,
Leo
(*) Please check the documentation of addRecord() for additional information on parameters and return values associated with that method: http://drupalcode.org/project/voipdrupal.git/blob/refs/heads/6.x-1.x:/mo... or http://tinyurl.com/6dcwttu
Hi Leo, yes that helps a lot
Hi Leo,
yes that helps a lot thank you for your reply. I have managed to locate the recorded files on my drupal server and understand that they are saved both on the twilio and my drupal server.
I have a couple other questions if thats ok hopefully this will all add to an info base for new users.
On the drupal voip demo site the page "create audio recording demo" there is the option to upload, audio recorder, phone recorder how have you created these as a horizontal menu? Is it some functionality from an additional module? I have managed to add single recording links but not the ability to choose between the three.
The audio files that are recorded on both the twilio and the drupal server how do there filenames relate to the variables you mention. I wish to create a voip script that basically plays one of these back. I understand from you reply above that I use the addSay function but in your above example the %recording_pubic_url is generated in that script but not made public view. The other option is to use the recording_path variable I presume but still I don't know how this translates to the path and filename on the drupal server or on the twilio server. Is it possible just to clarify the how I would playback the recording at a later date by using filename or variable name and where I get this variable name from
e.g.
I make a recording its stored on twilio with recording SID xyz and on my server under the dir /sites/default/files/abc.mp3 how do I then reference this in a script such as:
$prompt = "Listen to this pre recorded message";
$loop = "1";
$script->addSay($prompt, $loop);
$loop = "1";
$script->addSay('recording reference', $loop); /this is where in struggle referencing it back what do i replace (recording reference with) does it need to be in single quotes etc.
$prompt = "Bye bye.";
$loop = "1";
$script->addSay($prompt, $loop);
$hangup_mode = "end_session";
$script->addHangup($hangup_mode);
Many thanks
fishboy1669
Re: record and playback in a message
Hi Fishboy1669,
Answering your questions:
1) To create a horizontal menu with the different recording widgets ((audiorecorderfield, phonerecorderfield, etc)) available to an audio field , use FileField Sources (http://drupal.org/project/filefield_sources). Both audiorecorderfield.module and phonerecorderfield.module bring instructions on how to work with filefield_sources in their respective README.txt files.
2) In order to playback prerecorded audio files, addSay() needs the public URL of those files. In your case, you should be able to use either the Twilio URL of that file, or the publicly accessible address of the copy that VoIP Drupal has stored in your local server (which is provided by %recording_public_url). To calculate the public URL of a local audio file that has not been recorded via VoIP Drupal, use the url() function provided by the Drupal API as in
$local_file_path = '/sites/default/files/abc.mp3';$public_url = url($local_file_path, array('absolute' => TRUE));
$script->addSay("Here's the recorded file: $public_url ");
Let me know if that helps!
Leo
Hi Leo, thats great I managed
Hi Leo,
thats great I managed to install the horizontal menu and see that there is some other stuff to install to do wav to mp3 conversations etc. So thats all good.
I was close I was using addPlay($filename) not addSay($filename) as soon as I changed that over it works. At the moment I'm just using the public URL from twilio and copy and pasting that into the $filename. Thats working good enough for testing.
I tried your example code at the bottom but it failed for both twilio and tropo. Not sure why though :(
Ash
Hello there, I tried your
Hello there,
It's hard to tell what is going on without actually seeing your full script. Are you able to paste the contents of $filename into a web browser and actually play the file?
Best,
Leo