DeepSpeech icon indicating copy to clipboard operation
DeepSpeech copied to clipboard

.Net Standard lib in the nuget package

Open verloka opened this issue 5 years ago • 24 comments
trafficstars

Will you add the .Net Standard library into nuget package?

verloka avatar Aug 27 '20 11:08 verloka

@carlfm01 is the one expert on .Net, I have no ide what ".Net Standard Library" is, so I'll let him answer :)

lissyx avatar Aug 28 '20 12:08 lissyx

Hi @verloka, thanks for the interest. As this not on my immediate work path I can't work on this right now, but would be nice to start making it easier to support other frameworks such as .NET Core with a common API, I can review if anyone wants to jump into it.

carlfm01 avatar Aug 28 '20 20:08 carlfm01

Would be very helpful to have a NetCore compatible version. Any idea of when this would be started?

dev-bre avatar Sep 28 '20 08:09 dev-bre

@dev-bre As you can see, @carlfm01 is mostly alone on that, so any help here is welcome.

lissyx avatar Sep 28 '20 08:09 lissyx

@dev-bre, @carlfm01 - The problem is that DLLImport does not see the deepspeech.so lib in the .Net Standard. DLLImport only correct works on Windows and this is a problem with the .Net Standard.

verloka avatar Sep 28 '20 08:09 verloka

he problem is that DLLImport does not see the deepspeech.so lib in the .Net Standard.

Could you please elaborate ? Again I insist, @carlfm01 could use some help from other people that are .Net knowledgeable.

lissyx avatar Sep 28 '20 11:09 lissyx

@lissyx dllimport is a built-in Windows feature, so it only works fine on Windows. Other platforms like linux or macos don't. I've ask the .net development team and they said they are working on a new modern feature to import native libraries. The problem is that the app doesn't provide enough information. Just throws FileNotFound exception.

verloka avatar Sep 28 '20 11:09 verloka

@lissyx dllimport is a built-in Windows feature, so it only works fine on Windows. Other platforms like linux or macos don't. I've ask the .net development team and they said they are working on a new modern feature to import native libraries. The problem is that the app doesn't provide enough information. Just throws FileNotFound exception.

This is still very much unclear here, no context What app are you talking about ? How does DLLImport relates to everything ? Have you traced the system calls ? DLL search path might be wrong ? DLLImport might be lurred because we name the lib libdeepspeech.so and not libdeepspeech.dll ?

lissyx avatar Sep 28 '20 11:09 lissyx

Just to clarify and avoid adding more confusion to this thread:

DllImport attribute IS supported by NetCore and would work in Linux: https://docs.microsoft.com/en-us/dotnet/api/system.runtime.interopservices.dllimportattribute?view=netcore-3.1

Not sure why has been stated otherwise, but even the .so extension is not an issue, since the .so imports would work in Linux , the .dll imports would work in Windows. You don't need to specify the extension,you just need to specify the class name.

The not found exception might be that the lib path has not been added to env variable: LD_LIBRARY_PATH

dev-bre avatar Sep 28 '20 16:09 dev-bre

The not found exception might be that the lib path has not been added to env variable: LD_LIBRARY_PATH

That is only valid on linux, i think the previous comment about that refers to Windows ?

You don't need to specify the extension,you just need to specify the class name

And so what happens on Windows if you name .so ?

lissyx avatar Sep 28 '20 16:09 lissyx

And so what happens on Windows if you name .so ?

the name does not matter, i've experimented with different names: .dll, .so, without extension for Windows it works for Linux no

verloka avatar Sep 28 '20 16:09 verloka

You don't need to name the extension. Windows will use the .dll , Linux the .so

[​DllImport​(​"​libdeepspeech"​)]

In Linux you need to set the LD_ var. In Windows you need the lib available in bin folder.

dev-bre avatar Sep 28 '20 16:09 dev-bre

You don't need to name the extension. Windows will use the .dll , Linux the .so

[​DllImport​(​"​libdeepspeech"​)]

In Linux you need to set the LD_ var. In Windows you need the lib available in bin folder.

Does this work for you?

verloka avatar Sep 28 '20 16:09 verloka

Not tried this for this library, but I used it in other situations My point is that if there is a problem with NetCore, it is not in the DllImport directive.

dev-bre avatar Sep 28 '20 17:09 dev-bre

You don't need to name the extension. Windows will use the .dll , Linux the .so

Exactly my point: we currently ship it named libdeepspeech.so on Windows, if the DllImport() code tries to be clever and only loads libdeepspeech.dll that might explain why it cannot find it ...

lissyx avatar Sep 28 '20 17:09 lissyx

Specifying the extension it should load the required file. Very strange it doesn't.

The extension should be automatically added only if not specified.

Doing something like: [​DllImport​(​"​libdeepspeech.so"​)]

Should find the lib if available in the bin folder (in Windows).

dev-bre avatar Sep 28 '20 17:09 dev-bre

Is there any update on .NetCore side? Are you guys going to look into this?

dev-bre avatar Oct 02 '20 06:10 dev-bre

Is there any update on .NetCore side? Are you guys going to look into this?

As I already stated, .Net is maintained by only @carlfm01 and he could use some help.

lissyx avatar Oct 02 '20 06:10 lissyx

I would like to help but i'm not sure how to ... I create an unofficial package and used in a demo project: https://github.com/Davilink/MyRecorder/tree/deepspeech-integration (if you want to make it work on window you need to install https://openal.org/) hoping that could help @carlfm01.

Davilink avatar Oct 15 '20 05:10 Davilink

@Davilink, Have you tested on Linux?

verloka avatar Oct 15 '20 06:10 verloka

@verloka Yeah, i tested linux and windows, i don't have a mac so cannot promise that it work on mac (it should... but not tested)

Davilink avatar Oct 15 '20 06:10 Davilink

@Davilink this is great news! Thanks for this. I will spend some time in this and report back.

Would be good to have your changes merged in the main project once proved fully working.

dev-bre avatar Oct 17 '20 17:10 dev-bre

https://github.com/mozilla/DeepSpeech/pull/3373

Davilink avatar Oct 22 '20 09:10 Davilink

Just a word to mention that there's a PR in flight and we just started using GitHub Actions, so now might be a good fit for people who would like to work on the new CI to address and land this.

lissyx avatar Mar 25 '21 15:03 lissyx