Giter Club home page Giter Club logo

plugin.audiorecorder's Introduction

🎉

plugin.audiorecorder's People

Contributors

mbmleone avatar 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

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.

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?

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.

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

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

Pause recording

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

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?

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.

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.

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.

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?

Play url file

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

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.

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.

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

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?

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!

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.

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!

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

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.

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

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.

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?

Set the filepath

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

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.

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.

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

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.

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?

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.

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.

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

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?

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

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.