question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Format exception when returning the result from RecognizeOnceAsync

See original GitHub issue

Describe 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:closed
  • Created 3 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
lnstreitcommented, Apr 27, 2021

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!

0reactions
glecaroscommented, Apr 27, 2021

Great, please reopen if you need further help.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Azure speech to text model runs but returns wrong output
It runs with no errors, but the output returned is "Hello World!". The narration.wav file does not include the words hello world. Since...
Read more >
Speech Cognitive services Authentication error (401) even ...
Hi I meet a problem for building a speech to text with Azure. I followed this tutorial …
Read more >
speech
The task returns the recognition text as result. Note: Since RecognizeOnceAsync() returns only a single utterance, it is suitable only for single shot ......
Read more >
Recognize and Synthesize Speech
If the SpeechRecognizer encounters an error, it produces a result of “Cancelled”. The code in the application will then display the error message....
Read more >
The Sa11ytaire Experiment Part 2: Putting the AI in ...
RecognizeOnceAsync (), which would return after an utterance had been made. The approach I'd taken meant that the player had to take action...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found