record function isn't recording audio
I am trying to wrap my head around why this won't work. I'me recording an incoming call's audio and saving some call information using ActiveRecord. Everything is working. My database is getting hit and sees the call. My applications "Sounds" tab shows a file with the correct name and matching timestamp to my logs, my database, and itself. Unfortunately, all the files shown on the "Sounds" tab are 44kb in size and have no audio contained in them. What am I missing? No errors, all the correct tones get returned. Here's my code.
default {
execute "swift", '"Welcome to Phone Caster. Press the one key to begin recording. Press pound to end recording."'
rec = Recording.new
stamp = Time.new.to_i
rec_file = 'recording_' + stamp.to_s + '.gsm'
rec.filename = rec_file
rec_start = input 1
if (rec_start == "1")
rec.callerid_num = callerid
rec.callerid_name = calleridname
rec.save
record_result = record 'sounds/' + rec_file
ahn_log record_result
else
execute 'swift', '"Goodbye"'
end
}
This code is in dialplan.rb and gets executed on incoming calls. Please help!!!
Comments are currently closed for this discussion. You can start a new one.
Support Staff 2 Posted by Troy on 03 Mar, 2010 12:02 AM
Hi za,
Thanks for the email and the code sample. Can you paste the output of the
ahn_log command (ie, one of the generated filenames)?
Also, if it's feasible, can you add another ahn_log line after the if
statement ends, and see whether that executes while (on the phone call)
recording still seems to be taking place? I'm wondering whether the call
still seems to be recording while program execution continues, or whether
both the phone call and the dialplan code are both sitting at Record.
Finally, this is probably obvious but I'll ask it out anyway -- can you
confirm that you're the person calling, and that you're connected and
talking (or otherwise making noise) when the recording starts? Just want to
make sure it's not strangers who might have already hung up prior to
recording. Probably a non-issue.
Thanks,
Troy
Cloudvox
3 Posted by za on 03 Mar, 2010 12:38 AM
Thanks for the response.
I just realized that the code should have been recording ".wav" files so here is the newly modified code. The log shows:
The new code is as follows:
No one else should be calling the app and I record the caller id and caller id name every time so can verify the validity of the calls.
4 Posted by za on 03 Mar, 2010 09:53 PM
Any ideas? I need to demo. this app to a client soon and can't see why this isn't working.
Support Staff 5 Posted by Troy on 04 Mar, 2010 03:57 PM
Hi za,
This code looks good. When you call in and record, what do you actually get in lieu of record? That is, do you hear the "Press pound to end recording" and then "goodbye" immediately, or does it seem to work? If the latter, do you hear "goodbye" only after you record something and press pound?
Second, is there nothing at all in the files (0 seconds of audio), or a couple seconds of silence, or something else?
Just for experimenting, can you try specifying an explicit duration and silence detection threshold, like:
record 'sounds/myfile.wav', :maxduration => 120, :silence => 30
Is there any chance that your caller isn't saying anything (or the mic isn't picking anything up), and the silence detection is kicking in? I believe the default silence detection is ~10 seconds, so it works the same as most voicemail systems.
Thanks,
Troy
Cloudvox
Support Staff 6 Posted by Troy on 04 Mar, 2010 11:19 PM
As an aside, za, if you're on IM, feel free to ping me - troy@sevenscale.com on Google Talk/Jabber.
Happy to troubleshoot interactively via IM as your availability allows, or schedule a time for web chat (we use 37signals Campfire, at campfirenow.com). I'm around most of the day on Friday, and in Pacific timezone.
Cheers,
Troy
Cloudvox
7 Posted by za on 04 Mar, 2010 11:26 PM
That might work for me in a bit. I'm currently working through some of the debugging steps you advised above and will post my results later. If I can't get anything going I'll hit you up on one of those chat services. My company uses 37signals and I'm on Jabber.
8 Posted by za on 04 Mar, 2010 11:30 PM
Wow…I'm feeling pretty dumb at this point. My input was set to line in for some reason and my mic input was turned down. The app is recording and working perfectly now. Thanks for all of your help and I apologize for being so out of it.
Support Staff 9 Posted by Troy on 05 Mar, 2010 12:49 AM
No problem at all, I'm just glad it's working. And just yell if we can
assist, either here or IM/phone/Campfire.
Troy
10 Posted by za on 09 Mar, 2010 05:57 PM
I've almost got this thing working but I have yet another problem. I swiched my code over to using the 'mp3' format since the Flash component I built to play these sounds can only load this file type. I used the same code as above but changed the rec_file declaration to read:
rec_file = 'recording_' + stamp.to_s + '.mp3'Now when I call into my app and hit 1 to record the recording tone sounds but then the call hangs up immediately. the ahn_log is still outputting the correct filename and my database is being hit but the sound never gets recorded. Any ideas?
11 Posted by za on 09 Mar, 2010 05:57 PM
Oh, and I already checked my microphone. ;-)
Support Staff 12 Posted by Troy on 11 Mar, 2010 04:51 PM
Hi Zachary,
I'm checking on this. It may actually be that you need to record to wav, and then link to mp3 using a transcoder. If you had to record to .wav but then were still able to generate a .mp3 link URL (ie for giving to a Flash component), would that work for you?
Troy
Cloudvox
13 Posted by za on 11 Mar, 2010 05:43 PM
As long as the file is an mp3 that should work. It is a step in the right direction.
Support Staff 14 Posted by Troy on 12 Mar, 2010 02:12 AM
Hi Zachary,
The good news is that we have on-the-fly MP3 encoding on our short term horizon. The bad news is that it's not done or live yet. Are you able to record a WAV file and pass a WAV URL into the Flash player? That sounds almost too easy, but I've been surprised how frequently WAV is actually supported (and at 8KHz mono, the bandwidth use isn't actually too bad).
As another alternative, would you be able to fetch the file locally (using the static sounds URL) and then MP3 it on your end? If you wanted to get really slick, I could even see passing the Cloudvox sound URL into http://dev.drop.io/rest-api-reference/actions/
That would be similar to http://gist.github.com/292251 , and I think it would let you link/download the MP3 from drop.io, effectively using it an in-the-network WAV to MP3 encoder.
The thing we're working on is an on-the-fly encoder that returns the MP3 bits when you get *.mp3. Until that exists, do any of those workarounds above work?
Cheers,
Troy
Cloudvox
Troy resolved this discussion on 09 Jun, 2010 03:42 PM.