Fry Posted August 27, 2020 Share Posted August 27, 2020 I'm not sure if this belongs here or in the troubleshooting forum. I've been working on a voice recognition plug-in for some time and it seems the 11.3 upgrade has broken the speech recognition functionality. I'm getting the following exception when my code references System.Speech. This is the exception: Could not load file or assembly 'System.Speech, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified. Here's the code, it was working in 11.2 so I think the change to .net core has caused this. There's nothing special about the code here and it fails as soon as the method is invoked, before log message on the first line. private bool CreateRecognizer() { try { Helpers.Log("Creating recognizer"); List<string> titleElements = new List<string>(GameTitlePhrases.Keys); // add the distinct phrases to the list of choices Choices choices = new Choices(); choices.Add(titleElements.ToArray()); GrammarBuilder grammarBuilder = new GrammarBuilder(); grammarBuilder.Append(choices); Grammar grammar = new Grammar(grammarBuilder) { Name = "Game title elements" }; // setup the recognizer Recognizer = new SpeechRecognitionEngine(); Recognizer.InitialSilenceTimeout = TimeSpan.FromSeconds(5.0); Recognizer.RecognizeCompleted += new EventHandler<RecognizeCompletedEventArgs>(RecognizeCompleted); Recognizer.LoadGrammarAsync(grammar); Recognizer.SpeechHypothesized += new EventHandler<SpeechHypothesizedEventArgs>(SpeechHypothesized); Recognizer.SetInputToDefaultAudioDevice(); Recognizer.RecognizeAsyncCancel(); } catch(Exception ex) { Helpers.LogException(ex, "CreateRecognizer"); } return (true); } I tried copying System.Speech.dll into the plugins folder alongside my DLL but then I get another error when I load big box: An error occurred while attempting to load the plugin "C:\Users\...\Documents\LaunchBox\Plugins\System.Speech.dll" Could not load the assembly 'System.Speech, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31f3856ad364e35, processorArchitecture=MSIL'. Reference assemblies should not be loaded for execution. They can only be loaded in the Reflection-only loader context. (0x80131058) It appears maybe it's trying to load System.Speech as a plugin? I tried moving the DLL from the plugins folder over to the LaunchBox\Core folder but I was back to the original exception. I'm wondering if anyone has any suggestion. Under .net framework and 11.2, I could reference System.Speech and it just worked. Is there a place where .net framework references should go? Any suggestion is greatly appreciated! Quote Link to comment Share on other sites More sharing options...
Fry Posted August 27, 2020 Author Share Posted August 27, 2020 I did a quick sample WPF application to ensure it's not an environment issue. I'm able to create a standalone WPF application to perform voice recognition functions using system.speech without a problem. Quote Link to comment Share on other sites More sharing options...
Jason Carr Posted August 27, 2020 Share Posted August 27, 2020 Apparently .NET Core has some issues still with System.Speech. I didn't see that one coming. Here's a couple of links that may help: https://github.com/dotnet/runtime/issues/30991 https://www.c-sharpcorner.com/blogs/using-systemspeech-with-net-core-30 The first link has a port of System.Speech on Github that supposedly works. 1 Quote Link to comment Share on other sites More sharing options...
Fry Posted August 27, 2020 Author Share Posted August 27, 2020 Thanks Jason! Is the BigBox plug-in API supporting plugins created in both .net framework and in .net core? I am considering porting my plug-in to .net core but wasn't sure if it's supported. I think it wasn't supported prior to 11.3. Quote Link to comment Share on other sites More sharing options...
Jason Carr Posted August 27, 2020 Share Posted August 27, 2020 1 minute ago, Fry said: Thanks Jason! Is the BigBox plug-in API supporting plugins created in both .net framework and in .net core? I am considering porting my plug-in to .net core but wasn't sure if it's supported. I think it wasn't supported prior to 11.3. Yes, you should be able to use either the .NET Framework or .NET Core. 1 Quote Link to comment Share on other sites More sharing options...
Fry Posted August 27, 2020 Author Share Posted August 27, 2020 Great, thank you! I will try porting to .net core, I think they have a system.speech alternative over there 1 Quote Link to comment Share on other sites More sharing options...
Fry Posted August 27, 2020 Author Share Posted August 27, 2020 (edited) Took me a bit to figure out how to add WPF user controls in a .net core class library project. In case anyone is trying to do the same thing, you'll want to do this. I think just the WindowsDesktop and <UseWPF> part. Targeting netcoreapp3.1 is working fine https://stackoverflow.com/questions/58836149/how-can-i-add-wpf-items-into-a-c-sharp-class-library-project-in-vs2019 Right-click on the class library project, choose "Edit project file" and copy the following contents into the .csproj file: <Project Sdk="Microsoft.NET.Sdk.WindowsDesktop"> <PropertyGroup> <TargetFramework>netcoreapp3.0</TargetFramework> <UseWPF>true</UseWPF> </PropertyGroup> </Project> This should give you the ability to add WPF specific items to the project using the menus. Edited August 27, 2020 by Fry 2 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.