locked
Audio recording using CaptureSource Class RRS feed

  • Question

  • Hi Forum,

    I have a requirement to capture voice and send it to a web service. 

    For this I have used below code (excerpt)

    • CaptureDeviceConfiguration.GetDefaultAudioCaptureDevice()
    • new CaptureSource() { AudioCaptureDevice = audioDevice };
    • _sink = new MemoryAudioSink(); _sink.CaptureSource = _captureSource; _captureSource.Start();
    I'm able to capture voice.
    But my requirement is to capture voice when user  speaks and the capturing should be stopped when user doesn't speak.
    Help is much appriciated..
    Thanks in advance..
    Regards,
    Suresh G
    Sunday, February 12, 2012 1:44 PM

Answers

All replies

  • Hi Suresh,

    Can we know why you want to stop capture when user doesn't speak? 

    Also give some detail of your project. It will help forum users to provide you appropriate solution. 

    Monday, February 13, 2012 12:50 AM
  • Thank you Darji for the response,

    My requirement is similar to Google Chrome Search through Voice recognition.

    I have an existing asp.net web site into which I need to add Voice recognition capabilities.

    I have to send the recorded voice to a web service which does the recognition.

    My user would be saying "New request", then my Silverlight control should record this and send it to the Webservice.

    After I get response from my web service my silverlight control should be ready to listen to the user.

    Regards,

    Suresh G

    Monday, February 13, 2012 1:14 AM
  • Hi,

    Thank you for the response.

    I have implemented my voice recognition sample using OOB feature & SAPI in SL4 for a new application starting from scratch.

    But in my Current requirement/scenerio, I cannot use OOB feature to an existing web application for embedding voice recognition feature.

    If I have to use OOB feature I have to redesign all the pages in the web application, Which I'm not supposed to do, so I have come up with this alternate approach of record the voice & send across the Web service.

    Is there a way to record the client voice when he speaks and not to record when he keeps quite.. which is similar to Google Voice search in Chrome.

    Thanks in advance.. 

    Regards,

    Suresh G

    Monday, February 13, 2012 5:57 AM
  • Hi Suresh Gorakala,

    But my requirement is to capture voice when user  speaks and the capturing should be stopped when user doesn't speak.

    You  can create a button in your page and click the button when you want to capture the voice. Please add the code to your button click event.

    CaptureDeviceConfiguration.GetDefaultAudioCaptureDevice()
    new CaptureSource() { AudioCaptureDevice = audioDevice };
    _sink = new MemoryAudioSink(); _sink.CaptureSource = _captureSource; _captureSource.Start();
    

    Then call the method CaptureSource.Stop when you don't speak.

    Besides, you can follow the threads below:

    http://forums.silverlight.net/p/249261/623509.aspx/1?Audio+Capturing+using+CaptureSource

    Tuesday, February 14, 2012 2:17 AM
  • Hi,

    Thank you for the response.

    Is there any way to stop the capture without using another button.( something similar to Voice search in Google Chrome).

    i.e. When there is no voice it should stop recording automatically.

    Also, What does Audioformat/AudioFrameSize/Bitspersample indicate.

    Thanks inadvance,

    Regards,

    Suresh G

     

    Tuesday, February 14, 2012 7:09 AM
  • Hi Suresh Gorakala,

    Based on your description above, I would suggest you try to keep recording but detect sound level. Please check the link below:

    http://stackoverflow.com/questions/6960481/how-to-visualize-microphone-sound-pressure-level-in-silverlight-4 

    When it exceeds certain level we can send data to web service, otherwise do nothing.

    Wednesday, February 15, 2012 2:50 AM
  • Thank you Catherine for the reply.

    Sunday, February 19, 2012 1:45 AM
  • Hi,

    Thank you for the reply..

    I have a question, in the list of byte[] data, how can I set to min base level (ex: surrounding sound level in my case)?

    Is there any algorithm to achieve this..

    Regards,

    Suresh G

     

    Monday, February 20, 2012 12:52 AM
  • Hi,

    how can I set to min base level (ex: surrounding sound level in my case)?

    Is there any algorithm to achieve this..

    In my opinion, it depends on your actual situation. You can do it manually. Please extract the sound volume when there is no people who speak. And set it as the min base level.

    Best wishes,

    Monday, February 20, 2012 2:41 AM
  • Does it mean to calculate something like RMS value for the sample of data recorded everytime?

    Tuesday, February 21, 2012 5:01 AM
  • Hi Suresh Gorakala,

    Yes, you can try to calculate it like RMS and set it as the min base level.

    Tuesday, February 21, 2012 10:56 PM