NateRickard / Xamarin.Cognitive.Speech

A client library that makes it easy to work with the Microsoft Cognitive Services Speech Services Speech to Text API on Xamarin.iOS, Xamarin.Android, UWP, and Xamarin.Forms/.NET Standard libraries used by those platforms
MIT License
59 stars 18 forks source link

Getting Exception in Plugin.AudioRecorder #12

Closed ajaysbsic closed 6 years ago

ajaysbsic commented 6 years ago

Hi, your libraries are very helpful. I am working on speech to text in Xamarin forms I have used this nuget to convert voice to text for searching purpose, it is working fine with IOS but in case of Android I am getting below exception when trying to call recorder.StartRecording() . Please help me out how can I resolve this.

at Plugin.AudioRecorder.AudioStream.get_ChannelCount () [0x00000] in C:\Repos\libs\Plugin.AudioRecorder\Plugin.AudioRecorder\AudioStream.cs:11 at Plugin.AudioRecorder.WaveRecorder.StopRecorder () [0x000ba] in C:\Repos\libs\Plugin.AudioRecorder\Plugin.AudioRecorder.Shared\WaveRecorder.cs:132 at Plugin.AudioRecorder.WaveRecorder+<StartRecorder>d__6.MoveNext () [0x00192] in C:\Repos\libs\Plugin.AudioRecorder\Plugin.AudioRecorder.Shared\WaveRecorder.cs:58 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 at System.Runtime.CompilerServices.TaskAwaiter.GetResult () [0x00000] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 at Plugin.AudioRecorder.AudioRecorderService+<StartRecording>d__50.MoveNext () [0x000bc] in C:\Repos\libs\Plugin.AudioRecorder\Plugin.AudioRecorder.Shared\AudioRecorderService.cs:112 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 at System.Runtime.CompilerServices.TaskAwaiter1[TResult].GetResult () [0x00000] in :0 at KAPSARC.Forms.Pages.PhoneDirectory.PhoneBookPage+d__23.MoveNext () [0x00088] in E:\Imran\Mobile\KAPSARC.Forms\Pages\PhoneDirectory\PhoneBookPage.xaml.cs:152 `

I have tried in both case installing this package in Forms and in Android and also only with Forms. As I can see that before calling the StartRecording() method I am getting IsRecording= false , but after then it is showing "System.NotImplementedException: The method or operation is not implemented." Any help will be really appreciated, Thanks in Advance.

NateRickard commented 6 years ago

Make sure you're targeting Android 8.1. The NuGet package only contains a binary for monoandroid81.

ajaysbsic commented 6 years ago

Yes , I am targeting Android 8.1, that was package issue, I have updated all the packages related to android and its working now, but still sometime I am getting this below exception : {System.Exception: SendRequest: Non-success status received :: Status Code: ServiceUnavailable; Reason: Service Unavailable; Content: <!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'><html xmlns='http://www.w3.org/1999/xhtml'><head><meta content='text/html; charset=utf-8' http-equiv='content-type'/><style type='text/css'>body { font-family:Arial; margin-left:40px; }img { border:0 none; }#content { margin-left: auto; margin-right: auto }#logo { margin-top: 30px; width=120px; height=34px }#message h2 { font-size: 20px; font-weight: normal; color: #000000; margin: 34px 0px 0px 0px }#message p { font-size: 13px; color: #000000; margin: 7px 0px 0px 0px }#errorref { font-size: 11px; color: #737373; margin-top: 41px }</style><title>Bing</title></head><body><div id='content'><div id='logo'><img alt='Bing' src='data:image/gif;base64,R0lGODlheAAiAMQAAL/a9ECR3n+16e/2/BB11jCI28/j95/I7mCj5K/R8d/t+XCt5iB+2f+mFI++7FCa4f/u0/+sI/+xMZvF7v/YmP/04v/dpwBs0////wAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAAAAAAALAAAAAB4ACIAAAX/ICCMAmaeaKqekNQ0kbXOdG3feI4JV3/ptMhrCAEaj8gcz5dECYeNYnNKNS571dYrQql6v7XrT6UAmAG5itQ2OAMUScPZkFI4HoEeYBIIOBwTXmInCQgFPogMDw5wSHZ5iD4BAnQ2BguHkRcFCwmQiGgCAAUFaFViAwIEmqwXCJUom3mmJwCfrZIHM7a4vRdoBwYjsFNiqz4ECA5nBwsMkQsDsT60Aw+RDMpmzZmSjScIkQWiAAkC3ay0YDusDLq7twXSJqAmA+gB6ii8yLDh3itGIUKwboWYHgjm1TiASB49aiY+EUhwA8CxTSbEEKzxrwfFgigObsTB0MeDh3ow/xioh2OljwQDLha4MeBZDwYgQyYysgARnHpXZur4hAAAonc2HCAiVlAM0hwKEJWo1zEAkCt+WNowCjEnOx/fdHSzWu+TVR1YuXrEobRrTlRHxmIoK+mqpAGITt6weYGAVxNqL3zUgdfHgrkQzdrtYbWnj6crOl4o8RfDxbM62qaky3jxBav3EEVbYa1h5YxHdRi4jPIXBsVo62IIjWzBGwwKCl288EBhZXSQZ6zu1xoNbCWyM+7GRSD4X9o9HoRNkQoRAVicP3vGbM8Bula9T6MonfcArdwIdhcglp37Daw0ypFI4Mk609P8fN0Mnn0kDvhAHHARAb6Jp5IzzCEwWIAKffRBxwINOkfDAQ0eZkQCAxlIGgAHkLDMdBoiIVmBIZYIUkkpmagiSBi6teKLVTjWA4gwwsgXgZawVuOOhDRE4gkGoHMfjy+i2JcABaaym4RErpjAcgEsIIAh2OjT5I5K+sIAkld2aU8CEPLFwCQA/OglkQMMoIABbCqQpokhAAA7'/></div><div id='message'><h2>Bing services aren't available right now</h2><p>We're working to restore all services as soon as possible.<br/>We know you want to get back to searching. Please check back soon.</p></div><div id='errorref'><span>Ref A: B83687BC7BA94CDD8C7233071F42840E Ref B: BOM02EDGE0319 Ref C: 2018-09-24T09:24:38Z</span></div></div></body></html> at Xamarin.Cognitive.BingSpeech.BingSpeechApiClient+<SendRequest>d__42.MoveNext () [0x00352] in C:\Repos\libs\Xamarin.Cognitive.BingSpeech\Xamarin.Cognitive.BingSpeech\BingSpeechApiClient.cs:216 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 at System.Runtime.CompilerServices.TaskAwaiter1[TResult].GetResult () [0x00000] in :0 at Xamarin.Cognitive.BingSpeech.BingSpeechApiClient+d46.MoveNext () [0x0015a] in C:\Repos\libs\Xamarin.Cognitive.BingSpeech\Xamarin.Cognitive.BingSpeech\BingSpeechApiClient.cs:406 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in :0 at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in :0 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in :0 at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in :0 at System.Runtime.CompilerServices.TaskAwaiter`1[TResult].GetResult () [0x00000] in :0 at Sample.Forms.Pages.PhoneDirectory.PhoneBookPage+d25.MoveNext () [0x0005d] in E:\xxx\Mobile\Sample.Forms\Pages\PhoneDirectory\PhoneBookPage.xaml.cs:209 }`

Thanks for the help.

ajaysbsic commented 6 years ago

Also , I am not able to search exactly keyword always , sometime i am getting approx values but some time not. Can give any suggestions. You can close this issue now.

nexxuno commented 6 years ago

I'm getting exactly the same error (see #11 )

ajaysbsic commented 6 years ago

@nexxuno make sure to Target 8.1 and all the packages should be updated mainly 'Plugin.CurrentActivity' (if you are using this). Also make sure you are asking user for Runtime permission. Further this is not the perfect solution but 7 times out of 10 it is working at my end , still looking for a perfect solution.

@NateRickard .. Any suggestion??

NateRickard commented 6 years ago

Change your Android project to use the Android HttpClient/Handler. This now seems to be required to successfully make calls to the speech api and I need to update the readme to reflect that.

I've not seen the error in iOS so if you do let me know.