From afa1ebdba8cb0f068a2ebe039a70fcbef47d9629 Mon Sep 17 00:00:00 2001 From: Julien Date: Thu, 11 Mar 2021 18:49:08 +0100 Subject: [PATCH] Support for netcore and net5. Upgrade obsolete SizeOf call. Add a test netcore console app (into a seperate folder to workaround nuget/msbuild mixing dependencies). --- native_client/dotnet/DeepSpeech.sln | 6 +++++ .../DeepSpeechClient/DeepSpeechClient.csproj | 2 +- .../Extensions/NativeExtensions.cs | 4 ++-- .../DeepSpeechConsoleNetCore.csproj | 24 +++++++++++++++++++ 4 files changed, 33 insertions(+), 3 deletions(-) create mode 100644 native_client/dotnet/DeepSpeechConsoleNetCore/DeepSpeechConsoleNetCore.csproj diff --git a/native_client/dotnet/DeepSpeech.sln b/native_client/dotnet/DeepSpeech.sln index 78afe7db06..0be0ad4dde 100644 --- a/native_client/dotnet/DeepSpeech.sln +++ b/native_client/dotnet/DeepSpeech.sln @@ -6,6 +6,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DeepSpeechClient", "DeepSpe EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DeepSpeechConsole", "DeepSpeechConsole\DeepSpeechConsole.csproj", "{312965E5-C4F6-4D95-BA64-79906B8BC7AC}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DeepSpeechConsoleNetCore", "DeepSpeechConsoleNetCore\DeepSpeechConsoleNetCore.csproj", "{913D0781-3DCD-43F1-988D-F26622FA0D2B}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|x64 = Debug|x64 @@ -20,6 +22,10 @@ Global {312965E5-C4F6-4D95-BA64-79906B8BC7AC}.Debug|x64.Build.0 = Debug|x64 {312965E5-C4F6-4D95-BA64-79906B8BC7AC}.Release|x64.ActiveCfg = Release|x64 {312965E5-C4F6-4D95-BA64-79906B8BC7AC}.Release|x64.Build.0 = Release|x64 + {913D0781-3DCD-43F1-988D-F26622FA0D2B}.Debug|x64.ActiveCfg = Debug|Any CPU + {913D0781-3DCD-43F1-988D-F26622FA0D2B}.Debug|x64.Build.0 = Debug|Any CPU + {913D0781-3DCD-43F1-988D-F26622FA0D2B}.Release|x64.ActiveCfg = Release|Any CPU + {913D0781-3DCD-43F1-988D-F26622FA0D2B}.Release|x64.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/native_client/dotnet/DeepSpeechClient/DeepSpeechClient.csproj b/native_client/dotnet/DeepSpeechClient/DeepSpeechClient.csproj index 33a94115d9..a6eb275f9d 100644 --- a/native_client/dotnet/DeepSpeechClient/DeepSpeechClient.csproj +++ b/native_client/dotnet/DeepSpeechClient/DeepSpeechClient.csproj @@ -1,7 +1,7 @@  Library - net452;net46;net47;uap10.0 + net452;net46;net47;uap10.0;netstandard1.3 x64 diff --git a/native_client/dotnet/DeepSpeechClient/Extensions/NativeExtensions.cs b/native_client/dotnet/DeepSpeechClient/Extensions/NativeExtensions.cs index 9325f4b82a..62439e2796 100644 --- a/native_client/dotnet/DeepSpeechClient/Extensions/NativeExtensions.cs +++ b/native_client/dotnet/DeepSpeechClient/Extensions/NativeExtensions.cs @@ -56,7 +56,7 @@ private static Models.CandidateTranscript PtrToCandidateTranscript(this IntPtr i managedTranscript.Confidence = transcript.confidence; //we need to manually read each item from the native ptr using its size - var sizeOfTokenMetadata = Marshal.SizeOf(typeof(TokenMetadata)); + var sizeOfTokenMetadata = Marshal.SizeOf(); for (int i = 0; i < transcript.num_tokens; i++) { managedTranscript.Tokens[i] = transcript.tokens.PtrToTokenMetadata(); @@ -79,7 +79,7 @@ internal static Models.Metadata PtrToMetadata(this IntPtr intPtr) managedMetadata.Transcripts = new Models.CandidateTranscript[metadata.num_transcripts]; //we need to manually read each item from the native ptr using its size - var sizeOfCandidateTranscript = Marshal.SizeOf(typeof(CandidateTranscript)); + var sizeOfCandidateTranscript = Marshal.SizeOf(); for (int i = 0; i < metadata.num_transcripts; i++) { managedMetadata.Transcripts[i] = metadata.transcripts.PtrToCandidateTranscript(); diff --git a/native_client/dotnet/DeepSpeechConsoleNetCore/DeepSpeechConsoleNetCore.csproj b/native_client/dotnet/DeepSpeechConsoleNetCore/DeepSpeechConsoleNetCore.csproj new file mode 100644 index 0000000000..b4387e5c14 --- /dev/null +++ b/native_client/dotnet/DeepSpeechConsoleNetCore/DeepSpeechConsoleNetCore.csproj @@ -0,0 +1,24 @@ + + + + Exe + netcoreapp3.1 + x64 + + + + + + + + + + + + + + PreserveNewest + + + +