Deepspeech: .NET Can not import DeepSpeech NuGet package

Created on 24 Apr 2020  路  38Comments  路  Source: mozilla/DeepSpeech

Hey there!

I want to use DeepSpeech in a .NET project and fortunately you already have a NuGet package available! But when I add DeepSpeech to my references by installing it in Visual Studio with the NuGet Manager, it is listed in my References but I can not import it with using.

C# using DeepSpeechClient.Interfaces; // The type or namespace name 'DeepSpeechClient' could not be found.

The .NET example project somehow works, but where is the difference?

Steps to reproduce:

  • Create basic .NET CLI project in Visual Studio
  • Add DeepSpeech with NuGet manager
  • try import with using DeepSpeechClient.Interfaces;

Do you have any ideas? Am I missing something (I am new to windows stuff)?

bug

Most helpful comment

Do you think you can have enough time for 0.8 for that ?

Yes.

All 38 comments

What version are you using ? Have you had a look at the .Net code under native_client/dotnet/ ?

I am using the latest v0.6.1. The code in native_client/dotnet README only states how to build the native client for windows, but I guess I don't have to do that because the NuGet package with a prebuild library exists.

I am using the latest v0.6.1. The code in native_client/dotnet README only states how to build the native client for windows, but I guess I don't have to do that because the NuGet package with a prebuild library exists.

Unfortunately, according to the docs, 0.6..1 uses the same interface, and it's working well on CI.

Have you verified against ? https://github.com/mozilla/DeepSpeech-examples/tree/r0.6/net_framework/DeepSpeechWPF

I know nothing about .Net in itself, so you'd need to wait for @carlfm01 :/

I fixed it!
I was looking into this commit of the example project and saw these lines were added in the .csproj file:

<Reference Include="DeepSpeechClient, Version=1.0.0.0, Culture=neutral, processorArchitecture=AMD64">
  <HintPath>packages\DeepSpeech.0.6.0\lib\net46\DeepSpeechClient.dll</HintPath>
</Reference> 

I looked up the lines in my file and it is:

<PackageReference Include="DeepSpeech">
  <Version>0.6.1</Version>
</PackageReference>

So my uneducated guess would be to run nuget install DeepSpeech and just reference the resulting folder via Reference and HintPath instead of using PackageReference.

But this seems a bit odd, shouldn't the NuGet package when referred with PackageReference work, too?

nuget install DeepSpeech

Does that installs you 0.6.1 ?

But this seems a bit odd, shouldn't the NuGet package when referred with PackageReference work, too?

Again, 0 knowledge in .Net, I don't even understand what you are talking abotu.

Does that installs you 0.6.1 ?

Yes it does.

Sorry @lissyx :D Although it's not perfect, I found my workaround. So thank you for checking in! Maybe later @carlfm01 will clarify some things.

I'm pretty sure you should be able to use it with just the NuGet reference...

Hello @erksch

I was looking into this commit of the example project and saw these lines were added in the .csproj file:

This should be automatically added by Visual Studio, which Visual studio version are you using?

I'm pretty sure you should be able to use it with just the NuGet reference...

You are right.

Anmerkung 2020-04-24 180104

Does it work for you when creating a new project?

Does it work for you when creating a new project?

Yes, I just created a new project and imported it without a problem.

Go to Help/About Visual Studio and click the copy button

Microsoft Visual Studio Community 2019
Version 16.5.4
VisualStudio.16.Release/16.5.4+30011.22
Microsoft .NET Framework
Version 4.8.03761

Installed Version: Community

Visual C++ 2019 00435-60000-00000-AA985
Microsoft Visual C++ 2019

ASP.NET and Web Tools 2019 16.5.236.49856
ASP.NET and Web Tools 2019

ASP.NET Web Frameworks and Tools 2019 16.5.236.49856
For additional information, visit https://www.asp.net/

Azure App Service Tools v3.0.0 16.5.236.49856
Azure App Service Tools v3.0.0

Azure Functions and Web Jobs Tools 16.5.236.49856
Azure Functions and Web Jobs Tools

C# Tools 3.5.0-beta4-20153-05+20b9af913f1b8ce0a62f72bea9e75e4aa3cf6b0e
C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Common Azure Tools 1.10
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

IntelliCode Extension 1.0
IntelliCode Visual Studio Extension Detailed Info

Microsoft Azure Tools 2.9
Microsoft Azure Tools for Microsoft Visual Studio 2019 - v2.9.30207.1

Microsoft Continuous Delivery Tools for Visual Studio 0.4
Simplifying the configuration of Azure DevOps pipelines from within the Visual Studio IDE.

Microsoft JVM Debugger 1.0
Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines

Microsoft Library Manager 2.1.25+gdacdb9b7a1
Install client-side libraries easily to any web project

Microsoft MI-Based Debugger 1.0
Provides support for connecting Visual Studio to MI compatible debuggers

Microsoft Visual C++ Wizards 1.0
Microsoft Visual C++ Wizards

Microsoft Visual Studio Tools for Containers 1.1
Develop, run, validate your ASP.NET Core applications in the target environment. F5 your application directly into a container with debugging, or CTRL + F5 to edit & refresh your app without having to rebuild the container.

Microsoft Visual Studio VC Package 1.0
Microsoft Visual Studio VC Package

NuGet Package Manager 5.5.0
NuGet Package Manager in Visual Studio. For more information about NuGet, visit https://docs.nuget.org/

NVIDIA CUDA 10.2 Wizards 10.2
Wizards to create new NVIDIA CUDA projects and source files.

ProjectServicesPackage Extension 1.0
ProjectServicesPackage Visual Studio Extension Detailed Info

SQL Server Data Tools 16.0.62003.05170
Microsoft SQL Server Data Tools

StylerPackage Extension 1.0
StylerPackage Visual Stuido Extension Detailed Info

SyncfusionMenu Extension 1.0
SyncfusionMenu Visual Studio Extension Detailed Info

Test Adapter for Boost.Test 1.0
Enables Visual Studio's testing tools with unit tests written for Boost.Test. The use terms and Third Party Notices are available in the extension installation directory.

Test Adapter for Google Test 1.0
Enables Visual Studio's testing tools with unit tests written for Google Test. The use terms and Third Party Notices are available in the extension installation directory.

TypeScript Tools 16.0.20225.2001
TypeScript Tools for Microsoft Visual Studio

Visual Basic Tools 3.5.0-beta4-20153-05+20b9af913f1b8ce0a62f72bea9e75e4aa3cf6b0e
Visual Basic components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Visual C++ for Linux Development 1.0.9.29814
Visual C++ for Linux Development

Visual F# Tools 10.8.0.0 for F# 4.7 16.5.0-beta.20181.6+85af456066acd4e76d2bc7821b44a325e46f2fca
Microsoft Visual F# Tools 10.8.0.0 for F# 4.7

Visual Studio Code Debug Adapter Host Package 1.0
Interop layer for hosting Visual Studio Code debug adapters in Visual Studio

Visual Studio Container Tools Extensions (Preview) 1.0
View, manage, and diagnose containers within Visual Studio.

Visual Studio Tools for CMake 1.0
Visual Studio Tools for CMake

Visual Studio Tools for Containers 1.0
Visual Studio Tools for Containers

Here's the info:

Microsoft Visual Studio Community 2019 (2)
Version 16.3.10
VisualStudio.16.Release/16.3.10+29519.87
Microsoft .NET Framework
Version 4.8.03752

Installed Version: Community

Visual C++ 2019   00435-60000-00000-AA461
Microsoft Visual C++ 2019

Application Insights Tools for Visual Studio Package   9.1.00913.1
Application Insights Tools for Visual Studio

ASP.NET and Web Tools 2019   16.3.286.43615
ASP.NET and Web Tools 2019

Azure App Service Tools v3.0.0   16.3.286.43615
Azure App Service Tools v3.0.0

C# Tools   3.3.1-beta3-19461-02+2fd12c210e22f7d6245805c60340f6a34af6875b
C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Common Azure Tools   1.10
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

IntelliCode Extension   1.0
IntelliCode Visual Studio Extension Detailed Info

Microsoft JVM Debugger   1.0
Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines

Microsoft MI-Based Debugger   1.0
Provides support for connecting Visual Studio to MI compatible debuggers

Microsoft Visual C++ Wizards   1.0
Microsoft Visual C++ Wizards

Microsoft Visual Studio VC Package   1.0
Microsoft Visual Studio VC Package

NuGet Package Manager   5.3.1
NuGet Package Manager in Visual Studio. For more information about NuGet, visit https://docs.nuget.org/

ProjectServicesPackage Extension   1.0
ProjectServicesPackage Visual Studio Extension Detailed Info

Test Adapter for Boost.Test   1.0
Enables Visual Studio's testing tools with unit tests written for Boost.Test.  The use terms and Third Party Notices are available in the extension installation directory.

Test Adapter for Google Test   1.0
Enables Visual Studio's testing tools with unit tests written for Google Test.  The use terms and Third Party Notices are available in the extension installation directory.

TypeScript Tools   16.0.10821.2002
TypeScript Tools for Microsoft Visual Studio

Visual Basic Tools   3.3.1-beta3-19461-02+2fd12c210e22f7d6245805c60340f6a34af6875b
Visual Basic components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Visual Studio Code Debug Adapter Host Package   1.0
Interop layer for hosting Visual Studio Code debug adapters in Visual Studio

Visual Studio Tools for CMake   1.0
Visual Studio Tools for CMake

Visual Studio Tools for CMake   1.0
Visual Studio Tools for CMake

Update:
When creating a fresh WPF App, adding the package and using it works as expected.
However when making a CLI or UWP project it does not.

Hello @erksch, thanks for the update.

The CLI project type works as usual on my side, can't test UWP due to an external issue that suggests reinstalling vs, I can't do that right now.

This looks like VS cache/config/version issue, now please verify under Tools/Options/Nuget package manager this config:
Captura de pantalla (1041)

Also, clear the NuGet cache and try again. If this doesn't work please update visual studio.

@erksch Have you been able to figure this out?

@erksch Gentle ping?

@lissyx Sorry for getting back so late, we shifted priority away from the windows recently.
I have the same NuGet configuration as @carlfm01 suggested.
I just created a fresh UWP app, added DeepSpeech (0.7.4) as a reference, and tried to include the DeepSpeechClient class and it is not found. So as usual.
I still have to use the workaround as mentioned in my comment from above.

Also what is weird: When adding a reference to the UWP app, no Packages folder or Packages.config is created. Maybe UWP is just handling NuGet references differently (only in csproj file) and that doesn't work for the way the DeepSpeech package is published.

Other (uneducated) idea: I remember the NuGet package having libraries for target frameworks net46 net45 and so on. Maybe there is missing an export for target framework uap10.0 which the UWP NuGet manager can pick up?

Well i know nothing about the .Net framework 馃槩

Well i know nothing about the .Net framework

Today I can look into this.

@erksch Thanks for the update and you are correct :

Maybe there is missing an export for target framework uap10.0 which the UWP NuGet manager can pick up?

I'm testing with NuGet locally to send a patch.

Ugh this will require more effort for UWP support, best case I only add the target (Which seems not to work), and the worst case I'll need to change project type completely and change cluster packing logic :/

the worst case I'll need to change project type completely and change cluster packing logic :/

While unfortunate, I think it would be a good move if it helps making the library being usable to UWP. Is it complicated? Maybe @erksch could help here if you are overloaded :-)

I mean the library is totally usable on UWP. It just requires some manual steps to get it done. If fixing that is out of scope maybe a small workaround guide would be enough.

I think it would be a good move if it helps making the library being usable to UWP.

+1 Here, it also makes easier to introduce Net core support :)

Maybe @erksch could help here if you are overloaded :-)

I can take, maybe later for testing. I wanted to touch .Net Core and I think this is the door.

I mean the library is totally usable on UWP.

Just luck, digging docs we should not pack net framework build as UWP, there are even min/max win sdk versions missing on the NuGet packing. I feel it can explode any time if we pack net framework version.

I will upgrade project type aiming for UWP and Net Core support :)

I will upgrade project type aiming for UWP and Net Core support :)

Do you think you can have enough time for 0.8 for that ?

I mean the library is totally usable on UWP. It just requires some manual steps to get it done. If fixing that is out of scope maybe a small workaround guide would be enough.

If not, can we at least document this workaround more or less officially?

Do you think you can have enough time for 0.8 for that ?

Yes.

@carlfm01 How is this progressing?

@kdavis-mozilla Hello, I need to confirm that this command : --add Microsoft.VisualStudio.ComponentGroup.UWP.BuildTools;includeRecommended --add Microsoft.NetCore.Component.SDK;includeRecommended --add Microsoft.VisualStudio.Component.Windows10SDK.18362;includeRecommended
fixes the issue, the thing is that I need to uninstall VS to confirm and can't do it on my daylight, I plan to finish this within the next two days
(with vs installed is not working)

Ok, now installing the generated NuGet by https://github.com/mozilla/DeepSpeech/pull/3100 from https://community-tc.services.mozilla.com/api/queue/v1/task/U9AVNs4CTqCR6GwmvXjhhQ/runs/0/artifacts/public/DeepSpeech.0.9.0-alpha.2.nupkg automatically adds the client, @erksch can you test in your side?

You will need to change the default target to x64(of your example), I'll do it in a PR.

Awesome I'll give it a try today or tomorrow.

@carlfm01 It works! Awesome! thank you for your hard work!

@carlfm01 Is the remaining task now landing the PR "Add UWP Nuget packing support"?

Hello @kdavis-mozilla, just rebased, I'll send test with a different PR.

@erksch Thanks.

Hello @kdavis-mozilla, just rebased, I'll send test with a different PR.

@erksch Thanks.

So if it's green we can merge this one? Looking forward to it and the tests :D

So if it's green we can merge this one?

Yes, already got the uwp console project working with a file link to reuse the .Net Framework console, the surprise was we can't run uwp .exe apps from command line out of the box :D, still on it.

Hello. Can anyone point a tutorial to use DeepSpeech with C#? I just need where to download latest database and how to convert an MP3 audio file to text

@carlfm01

Hello. Can anyone point a tutorial to use DeepSpeech with C#? I just need where to download latest database and how to convert an MP3 audio file to text

@carlfm01

Are you going to spam all the issues ? This is my last warning.

@reuben @lissyx @erksch Hello . How can I translate audio very accurately through a microphone using C #? Do I have to make very specific settings?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lissyx picture lissyx  路  33Comments

nealmcb picture nealmcb  路  30Comments

yoann1995 picture yoann1995  路  49Comments

khu834 picture khu834  路  48Comments

MaxPowerWasTaken picture MaxPowerWasTaken  路  40Comments