naterickard / plugin.audiorecorder Goto Github PK
View Code? Open in Web Editor NEWAudio Recorder plugin for Xamarin and Windows
License: MIT License
Audio Recorder plugin for Xamarin and Windows
License: MIT License
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.
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?
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.
This plugin is pretty awesome but it really needs more formats compatibility or a converter to mp3/ogg. The task of sending the recorded file is awful since file is always large.
It can record audio, but when we play the recorded audio , nothing has happened, no voice, no audio from the speaker.
But if we record audio following this tutorial, it can record & play the audio on Asus Zenfone Max M1
https://github.com/xamarin/recipes/tree/master/Recipes/android/media/audio/record_audio.
29-Nov-2018:
I found out that If we use MediaRecorder to record audio, it worked well
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
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
When I play audio the sound just comes out of the ear speaker for IOS. Can I do something to change this to come out of all the speakers or switch to the main speaker? Thanks in advance for your help.
Jim
Is there any way to have the pause functionality implemented? or is it there?
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?
Hello,
I would like to know if you see a way to create a spectogram related to the audio record?
Regards,
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.
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.
It is not possible to configure the number of channels thus the result is always mono.
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.
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?
You can play an audio from a URL?
method of play is not implemented?
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.
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.
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
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?
Hi
I am using Plugin.AudioRecorder in Xamarin Forms solution, target version Android 8.1(API Level -27), I have implemented as you have shown in the sample. The record functionality is working on phone with Android 6.0 but not on the latest Android version. Can you please help me with this one.
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!
Hi,
Any plan to support Xamarin.Forms for MacOS?
Thanks.
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.
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!
i want to run this on raspbian.
My microphone is a usb device.
I test it ok via arecord and aplay
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.
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.
Sorry that I can not provide my code because I can't share it.
Thanks
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.
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?
It would be really helpful if there will be an option to change the filepath from the default one.
I want to use MemoryStream with "WriteWavHeader".
but Stream is closed inside "WriteWavHeader".
using (var writer = new BinaryWriter (stream, Encoding.UTF8))
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.
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.
System.NotImplementedException: The method or operation is not implemented occured in my xamarin.forms app when "new AudioRecorderService{......} operation"
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
Is there a way to ignore the lack of sound or voice ( as best ) ?!
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.
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?
Hi,
With iOS 12.2, audio is no longer captured. Same code but the AudioInputReceived event is not called.
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:
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.
@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.
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
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?
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
Enhancement: I would like to be able to see all available audio sources (ie mic, audio interface, etc) and select one. Is this possible?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.