Coder Social home page Coder Social logo

naterickard / plugin.audiorecorder Goto Github PK

View Code? Open in Web Editor NEW
164.0 14.0 68.0 1.03 MB

Audio Recorder plugin for Xamarin and Windows

License: MIT License

C# 100.00%
xamarin xamarin-plugin xamarin-ios xamarin-android windows uwp xamarin-forms nuget ios android

plugin.audiorecorder's Introduction

Plugin.AudioRecorder

Audio Recorder plugin for Xamarin and Windows NuGet

Features:

  • Records audio on a device's microphone input
  • Allows access to recorded audio via file or Stream
  • Configurable silence detection to automatically end recording
  • Simple event and Task-based APIs
  • Cross platform AudioPlayer included

Setup

Platform Support

Platform Supported Version Notes
Xamarin.iOS Yes iOS 7+
Xamarin.Android Yes API 16+ Project should target Android framework 8.1+
Windows UWP Yes 10.0 Build 15063 and up

Notes:

  • Supports both native Xamarin.iOS / Xamarin.Android and Xamarin.Forms projects.
  • Contains reference assemblies to use the library from PCL projects (profile 111) and .NET Standard 2.0 projects.
    • Please note the PCL/.NET Standard support is via "bait & switch", and this will ONLY work alongside the proper platform-specific DLLs/NuGet packages in place.

Required Permissions & Capabilities

The following permissions/capabilities are required to be configured on each platform:

Android

<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />

Additionally, on OS versions Marshmallow and above, you may need to perform a runtime check to ask the user to access their microphone.

Example:

Do this in your main activity or at the point you'll be needing access to record audio:

if (ContextCompat.CheckSelfPermission (this, Manifest.Permission.RecordAudio) != Permission.Granted)
{
	ActivityCompat.RequestPermissions (this, new String [] { Manifest.Permission.RecordAudio }, 1);
}

iOS

For iOS 10 and above, you must set the NSMicrophoneUsageDescription in your Info.plist:

<key>NSMicrophoneUsageDescription</key>
<string>The [app name] wants to use your microphone to record audio.</string>

UWP

You must check the Internet and Microphone capabilities in your app's Package.appxmanifest file.

Usage

In a controller/activity/page, initialize a new AudioRecorderService.

Example:

recorder = new AudioRecorderService
{
	StopRecordingOnSilence = true, //will stop recording after 2 seconds (default)
	StopRecordingAfterTimeout = true,  //stop recording after a max timeout (defined below)
	TotalAudioTimeout = TimeSpan.FromSeconds (15) //audio will stop recording after 15 seconds
};

More settings and properties are defined below

Recording

To begin recording, use the StartRecording () and StopRecording () methods as shown:

async void RecordButton_Click (object sender, EventArgs e)
{
	await RecordAudio ();
}

async Task RecordAudio ()
{
	try
	{
		if (!recorder.IsRecording)
		{
			await recorder.StartRecording ();
		}
		else
		{
			await recorder.StopRecording ();
		}
	}
	catch (Exception ex)
	{
	...
	}
}

In lieu of calling StopRecording (), you can also make use of the StopRecordingAfterTimeout and/or StopRecordingOnSilence settings, which are explained below.

Using the Audio Data

Once recording has begun, there are two different ways to determine when recording has finished:

Task-based API

To use the Task-based API, you can grab the returned Task from the call to StartRecording (). This allows you to await the result of the Task, which will complete when recording is complete and return the path to the recorded audio file.

Example:

var recordTask = await recorder.StartRecording ();

... maybe do some other things like toggle your 'mic' button off while recording

//await the returned Task... this will complete once recording has been stopped
var audioFile = await recordTask;

if (audioFile != null) //non-null audioFile indicates audio was successfully recorded
{
	//do something with the file
}

Event-based API

The AudioInputReceived is raised when recording is complete, and the full filepath of the recorded audio file is passed along.

Example:

recorder.AudioInputReceived += Recorder_AudioInputReceived;

...

await recorder.StartRecording ();

...

private async void Recorder_AudioInputReceived(object sender, string audioFile)
{
	//do something with the file
}

NOTE: This event is raised on a background thread to allow for further file processing as needed. If the audioFile is null or empty, no audio was recorded.

--

There are also multiple ways to use the recorded (or recording) audio data:

Accessing the Recorded File

There are multiple ways to access the recorded audio file path:

  • The Task-based API will return the file path when the task completes. The Task can be awaited or use standard Task continuation APIs.
  • The Event-based API will return the full path to the recorded audio file in the audioFile parameter of the AudioInputReceived event handler.
  • The GetAudioFilePath () method on the AudioRecorderService class will return the recorded audio file path.

These will all return null in the case that no audio has been recorded yet or no audio was recorded/detected in the last recording session.

Once you have the path to the recorded audio file, you can use standard file operations (for native/.NET Standard) and/or a cross platform file system abstraction like PCLStorage to get a stream to the file data.

Concurrent Streaming

It's also possible to get a stream to the recording audio data as it's being recorded, once StartRecording () has been called.

To access this readonly stream of audio data, you may call the GetAudioFileStream () method. This is useful in the case you want to immediately begin streaming the audio data to a server or other consumer.

NOTE: Since the WAV header is written after recording, once the audio length is known, the provided Stream data will contain the PCM audio data only and will not contain a WAV header. If your use case requires a WAV header, you can call AudioFunctions.WriteWaveHeader (Stream stream, int channelCount, int sampleRate, int bitsPerSample), which will write a WAV header to the stream with an unknown length.

Since GetAudioFileStream () will return a Stream that is also being populated concurrently, it can be useful to know when the recording is complete - the Stream will continue to grow! This can be accomplished with either the Event-based API or the Task-based API (which is often more useful).

An example of the Task-based API and concurrent writing and reading of the audio data is shown in the sample accompanying the Xamarin.Cognitive.Speech library. This speech client will stream audio data to the server until the AudioRecordTask completes, signaling that the recording is finished.

Properties and Settings

  • IsRecording

    bool IsRecording

    Returns a value indicating if the AudioRecorderService is currently recording audio.

  • StopRecordingAfterTimeout / TotalAudioTimeout

    bool StopRecordingAfterTimeout

    Gets/sets a value indicating if the AudioRecorderService should stop recording after a certain amount of time. Default is true.

    TimeSpan TotalAudioTimeout

    If StopRecordingAfterTimeout is set to true, this TimeSpan indicates the total amount of time to record audio for before recording is stopped. Defaults to 30 seconds.

  • StopRecordingOnSilence / AudioSilenceTimeout

    bool StopRecordingOnSilence

    Gets/sets a value indicating if the AudioRecorderService should stop recording after silence (low audio signal) is detected. Default is true.

    TimeSpan AudioSilenceTimeout

    If StopRecordingOnSilence is set to true, this TimeSpan indicates the amount of 'silent' time is required before recording is stopped. Defaults to 2 seconds.

  • SilenceThreshold

    float SilenceThreshold

    Gets/sets a value indicating the signal threshold that determines silence. If the recorder is being over or under aggressive when detecting silence for your use case, you can alter this value to achieve different results. Defaults to .15. Value should be between 0 and 1.

  • FilePath

    string FilePath

    Gets/sets the desired file path. If null it will be set automatically to a temporary file.

  • ConfigureAVAudioSession (iOS only)

    static bool ConfigureAVAudioSession

    Gets/sets whether the AudioRecorderService should attempt to control the shared AVAudioSession category. This can be set from the AppDelegate (example) or other iOS-specific class. When set to true, the AudioRecorderService will attempt to set the category to Record before recording, and restore the category to its previous value after recording is complete. This can help this plugin coexist with other media plugins that try to unilaterally set the category. Defaults to false.

Limitations

  • Currently this is only recording in WAV audio format (due to original use case this was developed for).

Samples

Complete samples demonstrating audio recording (AudioRecorderService) and playback (AudioPlayer) of the recorded file are available in the /Samples folder:

  • Xamarin.Forms (.NET Standard) containing iOS, Android, and UWP apps.
  • Native iOS, Android, and UWP apps.

Contributing

Contributions are welcome. Feel free to file issues and pull requests on the repo and they'll be reviewed as time permits.

Building

This solution requires the following environment/config:

  • Visual Studio 2017 or above
    • You may be able to load and build the iOS/Android targets on Visual Studio for Mac
  • If you want to build the NuGet package (for some reason):

Debugging

The easiest way to debug this library is to clone this repo and copy the shared library + platform project (of the platform you're debugging with) into your solution folder, then include the projects in your solution and reference them directly, rather than referencing the NuGet package.

About

License

Licensed under the MIT License (MIT). See LICENSE for details.

plugin.audiorecorder's People

Contributors

naterickard avatar ryanwersal avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

plugin.audiorecorder's Issues

Please put the current release

There is a lot of changes which is "a must have" but they are still not presenting as official release.
Please update a version which contains the recent changes.

Thanks in advance.

Insert and overwrite to the current recording

It would be very good to have the features of inserting or attaching a new recording right at the end of the current existing (paused) recording. Also, to overwrite the current existing (paused) recording from a specific position. Any thoughts on how to implement these features?

Null exception for parameter "Path" in UWP

Using the plugin in UWP (Windows 10 for desktop and a Windows 10 mobile device)
I get the following exception when calling await recorder.StartRecording();

"{System.ArgumentNullException: Path cannot be null.Parameter name: path at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options) at Plugin.AudioRecorder.WaveRecorder.d__6.MoveNext()--- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Plugin.AudioRecorder.AudioRecorderService.d__43.MoveNext()--- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult() at atWork.ViewModels.HomeViewModel.d__40.MoveNext()}"

I have granted microphone and storage permissions, but the devices dont have external SD card.

Record in compressed format

Hi, I am trying to modify the code to record directly in AAC format. I’ve tried to change parameters at AudioStreamBasicDescrption for iOS but no success.

I think this would be possible, do you?. Any advice to continue or is there a possibility to enhance the code?

Thanks a lot.

Stream is closed in WriteWavHeader

I want to use MemoryStream with "WriteWavHeader".
but Stream is closed inside "WriteWavHeader".

using (var writer = new BinaryWriter (stream, Encoding.UTF8))

Streams not cleaned up in WaveRecorder when Exception occurs

Problem Statement:
While using the AudioRecorder plugin, if a situation occurs where the AudioStream implementation throws an exception (the easiest one to replicate is to deny access to the Microphone), the WaveRecorder does not dispose of the FileStream and BinaryWriter objects. This makes it so you cannot clean up the directory and file that is requested the wav file to be saved to.

Concurrent Streaming

I am trying to get the stream while recording is going on. I noticed that as much as the Audio Stream is growing, there's no event to notify when changes take place in the stream unless you keep manually checking the stream.

Also, I am having trouble writing to the WAV header while checking the stream.

Could you please share a sample or guide me in the right direction. I checked out the Xamarin.Cognitive.Speech sample but it does not fit my problem since the Library takes in the stream as well as the recordingTask for concurrent streaming to work.

The idea is to get the stream and send it to Azure while recording is still ongoing without using Xamarin.Cognitive.Speech since it does not return the audio response.

At the same time, I can't work with the Cognitive Service SDK out of the box since two processes cannot access the microphone at the same time and I also want to save both the recorded audio and the audio response from Azure.

Your help will be highly appreciated.

Can't change the default filepath

Hello I am using your Plugin to record and save an audio file. If I leave the Filepath parameter blank it works fine, but if I set the parameter to "Filepath = PCLStorage.FileSystem.Current.LocalStorage.Path" I always get the error that I don't have permission to access that directory. That occurs in UWP and Android, even though I followed your instructions.

Is there any way I can solve that problem?

saving mp3 or aac

I would like to use it but I want to choose the export file type.

I would be glad to try to do it, but I'd like to have a small advice from you: what is the best way to do it?
Maybe add a Mp3Recorder to be switched with the WaveRecorder?

iOS Recording Not Completing

First, thank you for making this great plugin. However, I am having an issue with iOS (UWP and Android are unaffected).

Almost every other time I execute StartRecording (the frequency is actually intermittent), the recording doesn't complete automatically. I have tried both the Task and event-driven approaches. When I manually stop recording by calling StopRecording, the result is always null in these instances.

As a rundown of the process that I can see:

  • StartRecording is called
  • IsRecording changes to true
  • StopRecordingOnSilence has no effect (Task is not completed/AudioInputReceived does not fire)
  • StopRecordingAfterTimeout has no effect (Task is not completed/AudioInputReceived does not fire)
  • StopRecording is called
  • IsRecording changes to false
  • Task is completed/AudioInputReceived fires
  • FilePath is null (always)

The next time I execute StartRecording everything might work perfectly, but I will quickly run into another occurrence of the problem. As a reference, here are the settings I configure on the service:

StopRecordingOnSilence = true,
AudioSilenceTimeout = TimeSpan.FromSeconds(2),
SilenceThreshold = 0.1f,
StopRecordingAfterTimeout = true,
TotalAudioTimeout = TimeSpan.FromSeconds(5),
PreferredSampleRate = 8000

I hope this makes sense. Thanks.

Quiet voice results in null audio file.

I'm building an app where recording the user is part of the functionality (for accent analysis) and for the most part this competent works well.

However, for some devices (P20 Pro, I'm looking at you), the microphone input is very quiet unless the user shouts into the primary mike. The secondary mike seems not to be used.

When a user is too quiet, typically this results in recorder.GetAudioFilePath() being NULL. This is frustrating for the users to have to repeat themselves and raise their voice.

Is there any way around this?
Will changing the silence threshold help (we are using manual start/stop record)?
Can we activate all the microphones on a users phone (there is another on the top)?

Any advice from anyone would help.

Will not be recorded while talking softly

Hi
Unfortunately, it's not working if you try to talk quietly. To record any sound or voice it has to be loud enough to be recorded.
In general, if you record something and even if you don't say anything, you're still able to hear some background noises.
But in this case, using (Plugin.AudioRecorder), it's not working.

Do I only have this problem ???

Thanks

Record OK, but share it to messenger not always play

Hi to you
i am trying to share the audio recorded, but in some mobiles just cannot play.
My code is just simple:
`

        AudioRecorderService _recoder = new AudioRecorderService();
        
        await _recoder.StartRecording();
        await TextToSpeech.SpeakAsync(MainTextArea.Text, settings, cancelToken: cts.Token);
        await _recoder.StopRecording();
        
        await Share.RequestAsync(new ShareFileRequest
        {
            File = new ShareFile(_recoder.FilePath)
        });

`

In Whats'up it says "not supported audio file"
In Facebook messenger in some mobiles can play in some others (included my own) not.
Any ideas?

This plugin does not work

I spent one week and did not manage to launch this plugin.
It is compiled and deployed onto the device, but it does not work. In debag mode, it returns the name of the file, but it does not exist on the device. All permissions are set correctly.

Xiaomi Redmi 5 Plus Android 7.1.

Set the filepath

It would be really helpful if there will be an option to change the filepath from the default one.

On android Path is null

Hi,

Ive upgraded my project from VS2017 to VS2019 and now i am experiencing 2 types of crashes when stopping the recorder.

1 - Path is null (Auto path (string) in the on recorder stopped event is null) also getting the path from the recorder object is null
2 - Path access violation error

Sometimes it works but most of the time i get one of the above errors. (I will post some in depth error messaging later today) The issue seems to be coming from the upgrade of mscorlib 2.0.50 to 4.0.0.0

Does anyone have this issue and know what to do about it?

Build fails due to missing resources

Just trying to tinker with your app, as both an example to see how to bootstrap an app with Xamarin Forms on both android and iOS with a shared library, as well as a base for a recording app i want to make.

OSX 10.13.5
Visual Studio Community 2017
Cloned repo, opened solution file in root directory.

Package errors:

Restoring NuGet package NuGet.Build.Packaging.0.2.5-dev.1.
  GET https://api.nuget.org/v3-flatcontainer/nuget.build.packaging/0.2.5-dev.1/nuget.build.packaging.0.2.5-dev.1.nupkg
  NotFound https://api.nuget.org/v3-flatcontainer/nuget.build.packaging/0.2.5-dev.1/nuget.build.packaging.0.2.5-dev.1.nupkg 2494ms
Unable to find version '0.2.5-dev.1' of package 'NuGet.Build.Packaging'.
  https://api.nuget.org/v3/index.json: Package 'NuGet.Build.Packaging.0.2.5-dev.1' is not found on source 'https://api.nuget.org/v3/index.json'.

Package restore failed for project Plugin.AudioRecorder.iOS: Unable to find version '0.2.5-dev.1' of package 'NuGet.Build.Packaging'.
  https://api.nuget.org/v3/index.json: Package 'NuGet.Build.Packaging.0.2.5-dev.1' is not found on source 'https://api.nuget.org/v3/index.json'.

Package restore failed for project Plugin.AudioRecorder.Android: Unable to find version '0.2.5-dev.1' of package 'NuGet.Build.Packaging'.
  https://api.nuget.org/v3/index.json: Package 'NuGet.Build.Packaging.0.2.5-dev.1' is not found on source 'https://api.nuget.org/v3/index.json'.

Package restore failed.

When I try to build AudioRecord.Forms.Android, there's lots of missing resource errors
/Users/cd/src/rekt/Samples/Forms/AudioRecord.Forms.Android/Resources/values/styles.xml(0,0): Error APT0000: Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light.DarkActionBar'. (APT0000) (AudioRecord.Forms.Android)

Was able to build and run ..Forms.iOS in simulator!

Recording with background music doesn't work when headset is connected

Hi.

I am currently using your plugin in the scenario when I am running a MediaPlayer with some background music and also starting the voice recording with the help of your code.

But if I connect a headset and try to do the same - I receive only the recorded voice and no music.

Do you know how to correct that?

Thanks in advance.

Not implemented exception

When I try and run the example code it just throws an exception that says its not implemented.

using System;
using System.Threading.Tasks;
using Plugin.AudioRecorder;

namespace csharp_mic_thingy
{
    class Program
    {
        static async Task Main()
        {
            var recorder = new AudioRecorderService
            {
                StopRecordingOnSilence = true, //will stop recording after 2 seconds (default)
                StopRecordingAfterTimeout = true,  //stop recording after a max timeout (defined below)
                TotalAudioTimeout = TimeSpan.FromMinutes(1), //audio will stop recording after 1 minute
                AudioSilenceTimeout = TimeSpan.FromSeconds(1),
                SilenceThreshold = 0.2f
            };

            recorder.AudioInputReceived += Recorder_AudioInputReceived;

            Console.WriteLine("Enter \"go\" into the console when you are ready (no qoutes).\nDont forget to press enter!");
            string go = Console.ReadLine();
            if (go != "go") return;

            await RecordAudio(recorder);
        }

        static void Recorder_AudioInputReceived(object sender, string e)
        {
            Console.WriteLine("YO... received some data");
        }

        static async Task RecordAudio(AudioRecorderService recorder)
        {
            try
            {
                if (!recorder.IsRecording)
                {
                    await recorder.StartRecording();
                }
                else
                {
                    await recorder.StopRecording();
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Exception occured:\n\n" + ex);
	    }
        }
    }
}

Here is the console output:

System.NotImplementedException: The method or operation is not implemented.
   at Plugin.AudioRecorder.AudioStream.get_ChannelCount()
   at Plugin.AudioRecorder.WaveRecorder.StopRecorder()
   at Plugin.AudioRecorder.WaveRecorder.StartRecorder(IAudioStream stream, String filePath)
   at Plugin.AudioRecorder.AudioRecorderService.StartRecording()
   at csharp_mic_thingy.Program.RecordAudio(AudioRecorderService recorder) in C:\Users\Max\Documents\csharp_mic_thingy\Program.cs:line 40

play() not working on Xiaomi devices

I have tested these functions on several devices that are Redmi Note 7, Redmi Y1, Vivo V5 and iPhone6.
I found that audio recording feature works fine. The recorded audio file is being stored as well. But player function is not working on Redmi note 7 and Redmi Y1. On other devices, it works well.
The code is same as stated in the sample application.

Thank you.

Playing of recorded audio wav file is not working in android phones

I am using the plugin as Nuget package in a xamarin forms project. I am facing issue with playing the recorded audio file in android devices only(specifically on OnePlus and Redmi phones). It works fine in iOS.

I see that .wav file is not present in the Android file managers cache folder. Please help me with resolving the issue.

can this run on raspbian?

i want to run this on raspbian.
My microphone is a usb device.
I test it ok via arecord and aplay

Cross Platform library throws NullReference exception

Audio Recorder service in Xamarin forms is yet to be implemented. One way to implement it in Android and use inside Xamarin forms is to inject the dependency from Android project and get that into Xamarin forms code behind.

Audio Recorder no working Android 6.0

Audio Recorder not working Android 6.0 but working fine in Android 8.1. I added everything which is mentioned in Readme.MD. Always returning filepath as null.
Device Log:
01-23 02:30:24.057 22826-22826/com.mobilelivetranslation D/AudioRecord: set(): inputSource 1, sampleRate 48000, format 0x1, channelMask 0x10, frameCount 1024, notificationFrames 0, sessionId 0, transferType 0, flags 0, opPackageName com.mobilelivetranslation uid -1, pid -1
01-23 02:30:24.069 22826-22826/com.mobilelivetranslation D/AudioRecord: set: Create AudioRecordThread
01-23 02:30:24.070 22826-22826/com.mobilelivetranslation D/AudioRecord: openRecord_l
01-23 02:30:24.078 22826-23344/com.mobilelivetranslation D/AudioSystem: getIoDescriptor: ioHandle = 1987, index = -2, mIoDescriptors = 0x7fa347e950
01-23 02:30:24.081 22826-22826/com.mobilelivetranslation D/AudioRecord: start, sync event 0 trigger session 0
01-23 02:30:24.115 22826-23315/com.mobilelivetranslation D/AudioSystem: getIoDescriptor: ioHandle = 1987, index = 1, mIoDescriptors = 0x7fa347e950
01-23 02:30:24.118 22826-22826/com.mobilelivetranslation D/AudioRecord: return status 0
01-23 02:30:25.277 22826-22878/com.mobilelivetranslation D/ConnectivityManager.CallbackHandler: CM callback handler got msg 524294
01-23 02:30:26.669 22826-23273/com.mobilelivetranslation D/AudioRecord: stop
01-23 02:30:26.669 22826-23273/com.mobilelivetranslation D/AudioTrackShared: front(98304), mIsOut 0, interrupt() FUTEX_WAKE
01-23 02:30:26.795 22826-23273/com.mobilelivetranslation D/AudioRecord: -stop
01-23 02:30:26.795 22826-23273/com.mobilelivetranslation D/AudioRecord: stop
01-23 02:30:26.795 22826-23273/com.mobilelivetranslation D/AudioRecord: stop
01-23 02:30:26.795 22826-23273/com.mobilelivetranslation D/AudioRecord: stop
01-23 02:30:26.795 22826-23273/com.mobilelivetranslation D/AudioTrackShared: front(99328), mIsOut 0, interrupt() FUTEX_WAKE
01-23 02:30:26.798 22826-23344/com.mobilelivetranslation D/AudioSystem: getIoDescriptor: ioHandle = 1987, index = 1, mIoDescriptors = 0x7fa347e950
01-23 02:30:31.400 22826-22878/com.mobilelivetranslation D/ConnectivityManager.CallbackHandler: CM callback handler got msg 524294

Please check the log and let me know where is the issue.

Path as null

Hi there, in android whenever i stop recording its returning file path as null (in case of default path). What can be the chances for this? This is happening for sample project too
My device is Android 6.0, htc one x9

No audio on AudioPlayer when iOS mute switch is on

I have run into a problem where users expect the audio to still play back on iOS even when they have the mute hardware switch on. Most apps will play audio despite this, but the AudioPlayer does not. Can you implement this functionality? Or even have ignoring the mute switch as an option?

Getting error "The method or operation is not implemented" while making an object

@NateRickard
I copied the code from your sample project and when I run it, it gives me an exception "The method or operation is not implemented" on

   **recorder = new AudioRecorderService
            {
                StopRecordingAfterTimeout = true,
                TotalAudioTimeout = TimeSpan.FromSeconds(15),
                AudioSilenceTimeout = TimeSpan.FromSeconds(2)
            };**

I have installed your latest version V1.0.1. I am using it in Xamarin Forms and I have given all the required permissions in Android Manifest.

Concurrent streaming while recording not working as expected

We are trying to implement an SDK in Xamarin to support IoS / Android / UWP consumers , where in we wanted to stream the audio while recording from microphone to CRIS to get the speech to text transalation while talking and return the response to the consumer so that he can display it on the screen progresively. We read the documentation of the Audio Recorder plugin for Xamarin and found that it supports concurrent streaming as per the documentation (It's also possible to get a stream to the recording audio data as it's being recorded). We also referred to the Bing Speech implementation provided in the documentation.

However, we are not able to achieve this functionality. Our observation was that when StartRecording is invoked, a wav file is being written to the GetAudioFilePath () - audiofilepath (ARS_recording.wav) and it always 0 bytes while being on a recording mode (via microphone). Only when StopRecording is invoked the stream writer internally flushes the bytes to the Wav file. Hence the below code recorder.GetAudioFileStream() does not streams any data during recording due to the fact that file ARS_recording.wav is always 0 bytes while recording.

// start recording audio
var audioRecordTask = await recorder.StartRecording ();

using (var stream = recorder.GetAudioFileStream ())
{
// this will begin sending the recording audio data as it continues to record
var simpleResult = await bingSpeechClient.SpeechToTextSimple (stream, recorder.AudioStreamDetails.SampleRate, audioRecordTask);
}

Please let us know if we are in the right path and the plugin will help us in solving the above mentioned usecase.

Thanks,
Lakshmi Narasimhan V

Hello NateRickard

Hello
I am using Plugin.AudioRecoder in visual studio 2017 xamarin project
My Xamarin project is portable
So when I install your plugin with NewGet, your plugin were installed for android and ios
But your plugin isn't installed for Portable Forms
So I got follow issue

Error Could not install package 'Plugin.AudioRecorder 0.8.0'. You are trying to install this package into a project that targets '.NETPortable,Version=v4.5,Profile=Profile259', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author. 0

How can i use your plugin in my project
Please help me
Best Regards

Conflict with Xamarin MediaManager?

I'm building a Forms app that needs to record audio, but also playback audio/video. Your plugin is a great fit for the recording, but I've noticed that if I have the Xamarin MediaManager (https://github.com/martijn00/XamarinMediaManager) plugin active at all in a given instance of the app, audio recording will fail. Is there any known conflict with these libraries?

I get the following error when calling StartRecording():
audioQueue.Start() returned non-OK status: GeneralParamError

I have reproduced this by loading up the media manager sample, adding Plugin.AudioRecorder, and this error is immediately produced upon trying to record. If I remove the auto load of the media manager playback, the error is triggered after the first time I playback and then try to record again. I've also gone the other way and added mediamanager to the AudioRecorder sample with the same result.

Any help is very much appreciated.

Audio Level Metering

I want to access the input volume level coming in through the microphone. For the end result, I want to display a live 'Volume Meter' for user feedback while recording.

Is there any possible way to access the microphone's input volume when recording audio using this plugin?

EDIT: I see this plugin implements recording via an InputAudioQueue, and not the AVAudioRecorder. But these AudioQueues have the CurrentLevelMeter property that could be used to do what I want. Is there a way that I can access the current AudioQueue from my DependencyService thats responsible for all this?

EDIT 2: I was able to fix this in my code, but I had to edit your source code, so I dont know if I should close this issue or not. To fix it, I simply cloned the project to create a local assembly and then made a Public Static Float volumeLevel variable in the AudioRecordingService.cs file and then updated the value of volumeLevel with the result of Calculate_Levels() every time its called in the AudioStream_OnBroadcast() event handler. Then from my personal app, I referenced the local DLL and was able to simply access the volumeLevel variable whenever I wanted to update the GUI to show the changing volume level. This was it still acts as a cross-platform solution and it doesnt add any more heavy lifting than you have already done in your code. Works great!

Problem accessing system microphone

Hy, the plugin will be exactly what i need, but i have the followinf problem:

When i run the App with this simple code

try
{
await _recorder.StartRecording();
}
catch(Exception ex)
{
await App.Current.MainPage.DisplayAlert("Error", ex.ToString(), "OK");
}

i get the following error message:
"System Exception: Unable to successfully initialize AudioRecord; reporting State.Uninitialized. If using an emulator make sure it has access to the system microphone."

I get this message independent whether i´m using the App in the VS emulator or directly on my phone.
I can´t find any options to activate mic access in the emulator.

So what could be the reason for that?

Pause recording

Is there any way to have the pause functionality implemented? or is it there?

Can't play the recorded audio

Hello, well as I explain in the title, I can not play the recorded audio, I checked the actual path of filePath in my device (physical) and nothing is in there.

I followed one of your samples.

  • isRecording event is triggered.
  • AudioInputReceived is triggered.
  • filePath is different than null.
  • player.play(filePath) executes with no error but the record isn't played.
  • player.FinishedPlaying is not triggered.

Sorry that I can not provide my code because I can't share it.

Thanks

Build failed with this error message about 'NuGet.Build.Packaging.0.2.5-dev.1'

Recent downloading of the github code and attempting to build with VS2017 15.8.2 has failed with this error message 'NuGet.Build.Packaging.0.2.5-dev.1' is not found on source.
I have excluded the unavailable Plugin.AudioRecorder.NuGet project and tried to find the update / remove without success.

Any suggestion are appreciated

Cheers

Play url file

You can play an audio from a URL?
method of play is not implemented?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.