Format exception when returning the result from RecognizeOnceAsync
See original GitHub issueDescribe the bug
I followed this quickstart to enroll my voice and check my voice afterward in another audio stream : https://docs.microsoft.com/en-us/azure/cognitive-services/speech-service/get-started-speaker-recognition?tabs=script&pivots=programming-language-csharp.
I used the text-independant examples. I just changed the locale for the CreateProfileAsync
method, I used fr-FR.
await client.CreateProfileAsync(VoiceProfileType.TextIndependentVerification, "fr-FR")
The enrollment seems to be ok, but when I try to recognize my voice with the RecognizeOnceAsync
method, I get an InvalidFormatException
when the result is fetched from the web service (see thr stack trace below for more info). The error occurs when the Convert.ToDouble()
is called.
To Reproduce Use the text-independant example from the link with fr-FR locale for the profil.
Expected behavior No exception thrown
Version of the Cognitive Services Speech SDK Microsoft.CognitiveServices.Speech: 1.14.0
Platform, Operating System, and Programming Language
- OS: Windows
- Hardware - x64
- Programming language: C#
- Azure : Azure Speech service in West US region
Additional context Here is the stack trace
Input string was not in a correct format.
at System.Number.ThrowOverflowOrFormatException(ParsingStatus status, TypeCode type)
at System.Convert.ToDouble(String value, IFormatProvider provider)
at Microsoft.CognitiveServices.Speech.SpeakerRecognitionResult..ctor(IntPtr resultHandlePtr)
at Microsoft.CognitiveServices.Speech.SpeakerRecognizer.<>c__DisplayClass5_0.<RecognizeOnceAsync>b__0(InteropSafeHandle h)
at Microsoft.CognitiveServices.Speech.SpeakerRecognizer.<>c__DisplayClass8_0.<RunAsync>b__0()
at System.Threading.Tasks.Task`1.InnerInvoke()
at System.Threading.Tasks.Task.<>c.<.cctor>b__274_0(Object obj)
at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at ConsoleApp1.Program.<SpeakerVerify>d__3.MoveNext() in D:\_Docs\Projets\ITCE\MultiLocuteur\ITCE.Multilocuteur.Console\ConsoleApp1\Program.cs:line 98
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
at ConsoleApp1.Program.<VerificationEnroll>d__2.MoveNext() in D:\_Docs\Projets\ITCE\MultiLocuteur\ITCE.Multilocuteur.Console\ConsoleApp1\Program.cs:line 81
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
at ConsoleApp1.Program.<Main>d__0.MoveNext() in D:\_Docs\Projets\ITCE\MultiLocuteur\ITCE.Multilocuteur.Console\ConsoleApp1\Program.cs:line 16
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (4 by maintainers)
Top GitHub Comments
Hi all,
I resolved the issue in the end. The problem was due to the difference in culture formats between the speech configuration (or cognitive services) and the local machine (mine). As I use a machine which formats strings in the “fr-fr” format, doubles in strings are probably used with “,” and not “.” as in “en-us”. The below line of code resolved the issue (changing the system format to the right one):
System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.GetCultureInfo("en-us");
Thanks for your will to help @glecaros!
Great, please reopen if you need further help.