Building a New Record Audio Activity

One of the key activities missing from UCMA that we used in Speech Sever 2007 is the Record Audio Activity. This was one of my “go to” tools in the Speech Server arsenal, so I’ve been hurting without. So to eliminate my pain, and hopefully some other’s, I’ve started building a replacement.  While what I’ve built so far isn’t nearly feature-complete, it will hopefully provide a suitable starting point for those looking to simply record some audio. Trust me, starting from scratch wasn’t much fun. It may seem simple (and it really is) but it was extremely unclear when I started. A special thanks to Marshall Harrison who helped me put this together.

What’s Included

  • InitialSilenceTimeout – How long should we record silence before we decide the calling isn’t going to start talking
  • EndingSilenceTimeout – How long should we record silence before we decided the caller has stopped talking
  • FilePath – Full path where we should save the file (this is new, it wasn’t definable in Speech Server)
  • AudioEncoding – Format to encode the saved file as (Wma16Kbps,Wma48Kbps, Pcm16Khz or Pcm8Khz)
  • RecordedLength – The length of the recorded made

What’s Not Included

  • LeadingSilenceTrimmedLength – We’re just saving the raw audio, there is no post-processing of the file
  • TrailingSilenceTrimmedLength – See above
  • PlayBeep – This object simply records audio, it doesn’t play any prompts or tones
  • Prompts  – See above
  • TerminationDigits  – The only method used for stopping recording at this point is silence from the caller
  • CanBargeIn – Given the lack of prompts, there was nothing to “barge in” on

I’ve included the full project (and the compiled Debug and Release versions) here:  AudioRecordingActivity1.2

UPDATE: I’ve fixed a few issues and updated the download to v1.1.

Update: We’re now at v1.2. This version solves some problems with Properties when multiple copies of the activity are in the same workflow

  • Pingback: Speaking From The Edge : Building a New Record Audio Activity()

  • Pingback: Building a New Record Audio Activity - Soapbox 2.0()

  • http://Website Adam

    Wow, great to see this Marc. I’ve been using audio recording to replace answering machine detection in MSS 2007.

    I don’t usually save the audio anywhere though, I just use it’s “statistics” (i.e. how long did the person talk before hitting the end silence limit) to determine when to start talking to them and if I think they are an answering machine (most people have shorter greetings than machines of course). This will be handy as we continue to shift over to UCMA 3.

    As usual, thanks for the great work!

    • Marc LaFleur

      I’m glad you found it helpful. I too use it purely for Voice Mail detection and delivery (which is why I didn’t bother implementing the prompting features found in the Speech Server version yet). If you run into any issues, please let me know.

  • sebastien crocquesel


    I found a little issue in the code. It appears you detach the recorder twice. One in the Stop() method and another one in the Execute method just after the Loop.
    Sometimes, it makes the action throw an exception when detaching in the Execute method (Recorder property is null).

    Anyway, great and usefull work.

    Also, what about pushing this on github or codeplex ?

    • Marc LaFleur

      Good catch! I’ll post some updated code.

      I’m also working on getting something into codeplex.

  • Doug

    Hello Marc. When I came across this I was extremely relieved. I appreciate that you shared your work but I am having trouble getting this to work. I always get this error when trying to build your sample application as well as an application that I have referenced the activity in:

    Error 1 System.Workflow.ComponentModel.Serialization.WorkflowMarkupSerializationException: Could not deserialize object. The type ‘AudioRecordingActivity.AudioRecording’ could not be resolved. 5 5

    I’m curious if you have seen this before and know of a way to solve it. Many thanks in advance!