mozilla / DeepSpeech

DeepSpeech is an open source embedded (offline, on-device) speech-to-text engine which can run in real time on devices ranging from a Raspberry Pi 4 to high power GPU servers.
Mozilla Public License 2.0
25.38k stars 3.97k forks source link

.NET Can not import DeepSpeech NuGet package #2937

Closed erksch closed 4 years ago

erksch commented 4 years ago

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.

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:

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

lissyx commented 4 years ago

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

erksch commented 4 years ago

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.

lissyx commented 4 years ago

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 :/

erksch commented 4 years ago

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.

erksch commented 4 years ago

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

lissyx commented 4 years ago

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.

erksch commented 4 years ago

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.

reuben commented 4 years ago

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

carlfm01 commented 4 years ago

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.

erksch commented 4 years ago

Anmerkung 2020-04-24 180104

Does it work for you when creating a new project?

carlfm01 commented 4 years ago

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

erksch commented 4 years ago

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
erksch commented 4 years ago

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.

carlfm01 commented 4 years ago

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.

lissyx commented 4 years ago

@erksch Have you been able to figure this out?

lissyx commented 4 years ago

@erksch Gentle ping?

erksch commented 4 years ago

@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?

lissyx commented 4 years ago

Well i know nothing about the .Net framework 😢

carlfm01 commented 4 years ago

Well i know nothing about the .Net framework

Today I can look into this.

carlfm01 commented 4 years ago

@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.

carlfm01 commented 4 years ago

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 :/

lissyx commented 4 years ago

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 :-)

erksch commented 4 years ago

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.

carlfm01 commented 4 years ago

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 :)

lissyx commented 4 years ago

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?

carlfm01 commented 4 years ago

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

Yes.

kdavis-mozilla commented 4 years ago

@carlfm01 How is this progressing?

carlfm01 commented 4 years ago

@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)

carlfm01 commented 4 years ago

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.

erksch commented 4 years ago

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

erksch commented 4 years ago

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

kdavis-mozilla commented 4 years ago

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

carlfm01 commented 4 years ago

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

@erksch Thanks.

lissyx commented 4 years ago

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

carlfm01 commented 4 years ago

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.

FurkanGozukara commented 4 years ago

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

lissyx commented 4 years ago

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.

problemSolvingProgramming commented 4 years ago

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

ADD-eNavarro commented 3 years ago

Hello @reuben, @lissyx and @carlfm01 I see this issue is closed for a few months now, but I'm experiencing the very same problem here: I create a new .NET Core 3.1 console project in Visual Studio (details further on), copy Program.cs from the examples and get a compiler error CS0246 (missing reference).

I am far from being an expert using VS, maybe I am doing something wrong.

Installed Version: Enterprise

Architecture Diagrams and Analysis Tools 00433-90050-55344-AA737 Microsoft Architecture Diagrams and Analysis Tools

Visual C++ 2019 00433-90050-55344-AA737 Microsoft Visual C++ 2019

.NET Core Debugging with WSL 2 1.0 .NET Core Debugging with WSL 2

ADL Tools Service Provider 1.0 This package contains services used by Data Lake tools

ASA Service Provider 1.0

ASP.NET and Web Tools 2019 16.9.688.6828 ASP.NET and Web Tools 2019

ASP.NET Core Razor Language Services 16.1.0.2112521+5741df381174d72f08e3632bb99f52e8635b6a1a Provides languages services for ASP.NET Core Razor.

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

Azure App Service Tools v3.0.0 16.9.688.6828 Azure App Service Tools v3.0.0

Azure Data Lake Node 1.0 This package contains the Data Lake integration nodes for Server Explorer.

Azure Data Lake Tools for Visual Studio 2.6.1000.0 Microsoft Azure Data Lake Tools for Visual Studio

Azure Functions and Web Jobs Tools 16.9.688.6828 Azure Functions and Web Jobs Tools

Azure Stream Analytics Tools for Visual Studio 2.6.1000.0 Microsoft Azure Stream Analytics Tools for Visual Studio

C# Tools 3.9.0-6.21160.10+59eedc33d35754759994155ea2f4e1012a9951e3 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.

Cookiecutter 16.9.21026.1 Provides tools for finding, instantiating and customizing templates in cookiecutter format.

Extensibility Message Bus 1.2.6 (master@34d6af2) Provides common messaging-based MEF services for loosely coupled Visual Studio extension components communication and integration.

Fabric.DiagnosticEvents 1.0 Fabric Diagnostic Events

GitHub.VisualStudio 2.11.102.28613 A Visual Studio Extension that brings the GitHub Flow into Visual Studio.

IntelliCode Extension 1.0 IntelliCode Visual Studio Extension Detailed Info

Linux Core Dump Debugging 1.0.9.31112 Enables debugging of Linux core dumps.

Microsoft Azure HDInsight Azure Node 2.6.1000.0 HDInsight Node under Azure Node

Microsoft Azure Hive Query Language Service 2.6.1000.0 Language service for Hive query

Microsoft Azure Service Fabric Tools for Visual Studio 16.0 Microsoft Azure Service Fabric Tools for Visual Studio

Microsoft Azure Stream Analytics Language Service 2.6.1000.0 Language service for Azure Stream Analytics

Microsoft Azure Stream Analytics Node 1.0 Azure Stream Analytics Node under Azure Node

Microsoft Azure Tools 2.9 Microsoft Azure Tools for Microsoft Visual Studio 2019 - v2.9.40218.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.113+g422d40002e.RR 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

Mono Debugging for Visual Studio 16.9.7 (df23ba6) Support for debugging Mono processes with Visual Studio.

NuGet Package Manager 5.9.0 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

Python 16.9.21026.1 Provides IntelliSense, projects, templates, debugging, interactive windows, and other support for Python developers.

Python - Conda support 16.9.21026.1 Conda support for Python projects.

Python - Django support 16.9.21026.1 Provides templates and integration for the Django web framework.

Python - IronPython support 16.9.21026.1 Provides templates and integration for IronPython-based projects.

Python - Profiling support 16.9.21026.1 Profiling support for Python projects.

Snapshot Debugging Extension 1.0 Snapshot Debugging Visual Studio Extension Detailed Info

SQL Server Data Tools 16.0.62103.10080 Microsoft SQL Server Data Tools

Syntax Visualizer 1.0 An extension for visualizing Roslyn SyntaxTrees.

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.

ToolWindowHostedEditor 1.0 Hosting json editor into a tool window

TypeScript Tools 16.0.30201.2001 TypeScript Tools for Microsoft Visual Studio

Visual Basic Tools 3.9.0-6.21160.10+59eedc33d35754759994155ea2f4e1012a9951e3 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 Cross Platform Mobile Development (Android) 16.0.31025.194 Visual C++ for Cross Platform Mobile Development (Android)

Visual C++ for Cross Platform Mobile Development (iOS) 16.0.31004.209 Visual C++ for Cross Platform Mobile Development (iOS)

Visual C++ for Linux Development 1.0.9.31112 Visual C++ for Linux Development

Visual F# Tools 16.9.0-beta.21102.9+7ce7132f1459095e635194d09d6f73265352029a Microsoft Visual F# Tools

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 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

Visual Studio Tools for Kubernetes 1.0 Visual Studio Tools for Kubernetes

VisualStudio.DeviceLog 1.0 Information about my package

VisualStudio.Foo 1.0 Information about my package

VisualStudio.Mac 1.0 Mac Extension for Visual Studio

Xamarin 16.9.000.273 (d16-9@1bba9e0) Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin Designer 16.9.0.316 (remotes/origin/d16-9@fdbf64026) Visual Studio extension to enable Xamarin Designer tools in Visual Studio.

Xamarin Templates 16.9.68 (8e9b569) Templates for building iOS, Android, and Windows apps with Xamarin and Xamarin.Forms.

Xamarin.Android SDK 11.2.2.1 (d16-9/877f572) Xamarin.Android Reference Assemblies and MSBuild support. Mono: 5e9cb6d Java.Interop: xamarin/java.interop/d16-9@54f8c24 ProGuard: Guardsquare/proguard/v7.0.1@912d149 SQLite: xamarin/sqlite/3.34.1@daff8f4 Xamarin.Android Tools: xamarin/xamarin-android-tools/d16-9@d210f11

Xamarin.iOS and Xamarin.Mac SDK 14.14.2.5 (3836759d4) Xamarin.iOS and Xamarin.Mac Reference Assemblies and MSBuild support.

giovinazzo-kevin commented 1 year ago

+1. I just tried importing the package on a .NET 7 WPF app and the same issue mentioned above happens.

I will try the suggested workaround and edit this comment.