maui icon indicating copy to clipboard operation
maui copied to clipboard

.NET Maui application throws System.DllNotFoundException for libMicrosoft.CognitiveServices.Speech.core.so

Open shuheydev opened this issue 2 years ago • 25 comments

Description

.NET Maui application throws System.DllNotFoundException for libMicrosoft.CognitiveServices.Speech.core.so when execute SpeechSDK's methods.

image

Environment:

  • Windows 10 Enterprise 21H2 19044.1466
  • Microsoft Visual Studio Enterprise 2022 (64-bit) - Preview Version 17.3.0 Preview 1.1
  • .NET MAUI 1.0
  • Microsoft.CognitiveServices.Speech v1.22

Steps to Reproduce

  1. Create a MAUI project
  2. Install Microsoft.CognitiveServices.Speech with nuget
  3. Add a code which call a SpeechSDK's method.
  4. Change the build target for Android image
  5. Run the app.

Version with bug

6.0 (current)

Last version that worked well

Unknown/Other

Affected platforms

Android

Affected platform versions

Android12.1

Did you find any workaround?

No response

Relevant log output

No response

shuheydev avatar Jun 06 '22 15:06 shuheydev

repro with vs main build 32609.239, here is part of output:

[monodroid-assembly] Shared library 'libMicrosoft.CognitiveServices.Speech.core.so' not loaded, p/invoke 'speech_translation_config_from_subscription' may fail
[monodroid-assembly] Shared library 'libMicrosoft.CognitiveServices.Speech.core.so' not loaded, p/invoke 'speech_translation_config_from_subscription' may fail
[ame.mauiapp770] * Assertion: should not be reached at /__w/1/s/src/mono/mono/mini/mini-exceptions.c:456
[libc] Fatal signal 6 (SIGABRT), code -1 (SI_QUEUE) in tid 1745 (Debugger agent), pid 1711 (ame.mauiapp7700)
The connection with the debugger has been lost. The target application may have exited.
Mono.Debugger.Soft.VMDisconnectedException: Exception of type 'Mono.Debugger.Soft.VMDisconnectedException' was thrown.
   at Mono.Debugger.Soft.ThreadMirror.GetFrames() in D:\a\_work\1\s\External\debugger-libs\Mono.Debugger.Soft\Mono.Debugger.Soft\ThreadMirror.cs:line 28
   at Mono.Debugging.Soft.SoftDebuggerBacktrace..ctor(SoftDebuggerSession session, ThreadMirror thread) in D:\a\_work\1\s\External\debugger-libs\Mono.Debugging.Soft\SoftDebuggerBacktrace.cs:line 64
   at Mono.Debugging.Soft.SoftDebuggerSession.HandleBreakEventSet(Event[] es, Boolean dequeuing) in D:\a\_work\1\s\External\debugger-libs\Mono.Debugging.Soft\SoftDebuggerSession.cs:line 2172
   at Mono.Debugging.Soft.SoftDebuggerSession.EventHandler() in D:\a\_work\1\s\External\debugger-libs\Mono.Debugging.Soft\SoftDebuggerSession.cs:line 1791

VincentBu avatar Jun 10 '22 06:06 VincentBu

I've got exactly the same issue. Are there any workarounds I can use to get this working? I'm currently completely blocked on a project I'm working on until I can find a solution.

RTroywest avatar Jul 25 '22 11:07 RTroywest

I can get this to work on an Android emulator if I create an x86 emulator instead of an x86_64 device. I am unable to deploy a working version to my Pixel 6 pro for testing though.

RTroywest avatar Aug 03 '22 12:08 RTroywest

@RTroywest did you find a workaround? I am also having this issue.

magols avatar Aug 29 '22 08:08 magols

I guess I'm here to say... me too

BobbyCannon avatar Sep 04 '22 20:09 BobbyCannon

Same problem here, but not only the problem is for android, other platforms have the same problem.

felique avatar Sep 04 '22 22:09 felique

@felique Windows platform works for me, it's only Android that doesn't work.

BobbyCannon avatar Sep 04 '22 22:09 BobbyCannon

@felique Windows platform works for me, it's only Android that doesn't work.

Yes, sorry I was having another problem. I can reproduce the error.. Same situation with Android, please help!

felique avatar Sep 04 '22 23:09 felique

I am really surprised that this is outstanding this long. It takes the wind out of my sails for my excitement for Maui. And I'm very disappointed.

BobbyCannon avatar Sep 04 '22 23:09 BobbyCannon

I have managed to get this building by manually linking the dependencies instead of using Nuget. I found the location of the required files in nuget and then added them into the project file:

	<ItemGroup>
		<AndroidNativeLibrary Include="SpeechLibs\arm64-v8a\libMicrosoft.CognitiveServices.Speech.core.so">
			<Abi>arm64-v8a</Abi>
		</AndroidNativeLibrary>
		<AndroidNativeLibrary Include="SpeechLibs\arm64-v8a\libMicrosoft.CognitiveServices.Speech.extension.audio.sys.so">
			<Abi>arm64-v8a</Abi>
		</AndroidNativeLibrary>
		<AndroidNativeLibrary Include="SpeechLibs\arm64-v8a\libMicrosoft.CognitiveServices.Speech.extension.kws.so">
			<Abi>arm64-v8a</Abi>
		</AndroidNativeLibrary>
		<AndroidNativeLibrary Include="SpeechLibs\arm64-v8a\libMicrosoft.CognitiveServices.Speech.extension.lu.so">
			<Abi>arm64-v8a</Abi>
		</AndroidNativeLibrary>
	</ItemGroup>

RTroywest avatar Sep 05 '22 08:09 RTroywest

I have managed to get this building by manually linking the dependencies instead of using Nuget. I found the location of the required files in nuget and then added them into the project file:

	<ItemGroup>
		<AndroidNativeLibrary Include="SpeechLibs\arm64-v8a\libMicrosoft.CognitiveServices.Speech.core.so">
			<Abi>arm64-v8a</Abi>
		</AndroidNativeLibrary>
		<AndroidNativeLibrary Include="SpeechLibs\arm64-v8a\libMicrosoft.CognitiveServices.Speech.extension.audio.sys.so">
			<Abi>arm64-v8a</Abi>
		</AndroidNativeLibrary>
		<AndroidNativeLibrary Include="SpeechLibs\arm64-v8a\libMicrosoft.CognitiveServices.Speech.extension.kws.so">
			<Abi>arm64-v8a</Abi>
		</AndroidNativeLibrary>
		<AndroidNativeLibrary Include="SpeechLibs\arm64-v8a\libMicrosoft.CognitiveServices.Speech.extension.lu.so">
			<Abi>arm64-v8a</Abi>
		</AndroidNativeLibrary>
	</ItemGroup>

Building or running? I can build with no problems using just the nuget. The problem is it will exception at runtime.

BobbyCannon avatar Sep 05 '22 16:09 BobbyCannon

I have managed to get this building by manually linking the dependencies instead of using Nuget. I found the location of the required files in nuget and then added them into the project file:

	<ItemGroup>
		<AndroidNativeLibrary Include="SpeechLibs\arm64-v8a\libMicrosoft.CognitiveServices.Speech.core.so">
			<Abi>arm64-v8a</Abi>
		</AndroidNativeLibrary>
		<AndroidNativeLibrary Include="SpeechLibs\arm64-v8a\libMicrosoft.CognitiveServices.Speech.extension.audio.sys.so">
			<Abi>arm64-v8a</Abi>
		</AndroidNativeLibrary>
		<AndroidNativeLibrary Include="SpeechLibs\arm64-v8a\libMicrosoft.CognitiveServices.Speech.extension.kws.so">
			<Abi>arm64-v8a</Abi>
		</AndroidNativeLibrary>
		<AndroidNativeLibrary Include="SpeechLibs\arm64-v8a\libMicrosoft.CognitiveServices.Speech.extension.lu.so">
			<Abi>arm64-v8a</Abi>
		</AndroidNativeLibrary>
	</ItemGroup>

Building or running? I can build with no problems using just the nuget. The problem is it will exception at runtime.

Building and running. Everything works fine on all the android devices I've tested with once linked manually.

RTroywest avatar Sep 05 '22 16:09 RTroywest

At runtime I get the following output in the "Output Window".

Thread started: <Thread Pool> #8
[monodroid-assembly] Shared library 'libMicrosoft.CognitiveServices.Speech.core.so' not loaded, p/invoke 'speech_config_from_subscription' may fail
[monodroid-assembly] Shared library 'libMicrosoft.CognitiveServices.Speech.core.so' not loaded, p/invoke 'speech_config_from_subscription' may fail
[TrafficStats] tagSocket(78) with statsTag=0xffffffff, statsUid=-1
**System.DllNotFoundException:** 'libMicrosoft.CognitiveServices.Speech.core.so'

Thread started: <Thread Pool> #9
[libc] Requested dump for pid 28768 (nnonfarm.client)

Notice the "Shared library 'libMicrosoft.CognitiveServices.Speech.core.so' not loaded" part. Why is it not loading?

BobbyCannon avatar Sep 05 '22 16:09 BobbyCannon

@RTroywest hum, I must still be doing something wrong then. I am invoking code in another assembly that does reference the nuget... I wonder if I should move (or rather copy) the code temporarily and see if that will work instead.

BobbyCannon avatar Sep 05 '22 16:09 BobbyCannon

@BobbyCannon - I had to completely remove the nuget package and reference it manually as the nuget package just wasn't worrking. I copied all the required files to a 'SpeechLibs' directory in my project and then referenced them all in the csproj file. You will need to register all of the abis you need - I've got them all registered:


	<ItemGroup>
		<AndroidNativeLibrary Include="SpeechLibs\arm64-v8a\libMicrosoft.CognitiveServices.Speech.core.so">
			<Abi>arm64-v8a</Abi>
		</AndroidNativeLibrary>
		<AndroidNativeLibrary Include="SpeechLibs\arm64-v8a\libMicrosoft.CognitiveServices.Speech.extension.audio.sys.so">
			<Abi>arm64-v8a</Abi>
		</AndroidNativeLibrary>
		<AndroidNativeLibrary Include="SpeechLibs\arm64-v8a\libMicrosoft.CognitiveServices.Speech.extension.kws.so">
			<Abi>arm64-v8a</Abi>
		</AndroidNativeLibrary>
		<AndroidNativeLibrary Include="SpeechLibs\arm64-v8a\libMicrosoft.CognitiveServices.Speech.extension.lu.so">
			<Abi>arm64-v8a</Abi>
		</AndroidNativeLibrary>
	</ItemGroup>

	<ItemGroup>
		<AndroidNativeLibrary Include="SpeechLibs\armeabi-v7a\libMicrosoft.CognitiveServices.Speech.core.so">
			<Abi>armeabi-v7a</Abi>
		</AndroidNativeLibrary>
		<AndroidNativeLibrary Include="SpeechLibs\armeabi-v7a\libMicrosoft.CognitiveServices.Speech.extension.audio.sys.so">
			<Abi>armeabi-v7a</Abi>
		</AndroidNativeLibrary>
		<AndroidNativeLibrary Include="SpeechLibs\armeabi-v7a\libMicrosoft.CognitiveServices.Speech.extension.kws.so">
			<Abi>armeabi-v7a</Abi>
		</AndroidNativeLibrary>
		<AndroidNativeLibrary Include="SpeechLibs\armeabi-v7a\libMicrosoft.CognitiveServices.Speech.extension.lu.so">
			<Abi>armeabi-v7a</Abi>
		</AndroidNativeLibrary>
	</ItemGroup>

	<ItemGroup>
		<AndroidNativeLibrary Include="SpeechLibs\x86\libMicrosoft.CognitiveServices.Speech.core.so">
			<Abi>x86</Abi>
		</AndroidNativeLibrary>
		<AndroidNativeLibrary Include="SpeechLibs\x86\libMicrosoft.CognitiveServices.Speech.extension.audio.sys.so">
			<Abi>x86</Abi>
		</AndroidNativeLibrary>
		<AndroidNativeLibrary Include="SpeechLibs\x86\libMicrosoft.CognitiveServices.Speech.extension.kws.so">
			<Abi>x86</Abi>
		</AndroidNativeLibrary>
		<AndroidNativeLibrary Include="SpeechLibs\x86\libMicrosoft.CognitiveServices.Speech.extension.lu.so">
			<Abi>x86</Abi>
		</AndroidNativeLibrary>
	</ItemGroup>

	<ItemGroup>
		<AndroidNativeLibrary Include="SpeechLibs\x86_64\libMicrosoft.CognitiveServices.Speech.core.so">
			<Abi>x86_64</Abi>
		</AndroidNativeLibrary>
		<AndroidNativeLibrary Include="SpeechLibs\x86_64\libMicrosoft.CognitiveServices.Speech.extension.audio.sys.so">
			<Abi>x86_64</Abi>
		</AndroidNativeLibrary>
		<AndroidNativeLibrary Include="SpeechLibs\x86_64\libMicrosoft.CognitiveServices.Speech.extension.kws.so">
			<Abi>x86_64</Abi>
		</AndroidNativeLibrary>
		<AndroidNativeLibrary Include="SpeechLibs\x86_64\libMicrosoft.CognitiveServices.Speech.extension.lu.so">
			<Abi>x86_64</Abi>
		</AndroidNativeLibrary>
	</ItemGroup>

RTroywest avatar Sep 05 '22 17:09 RTroywest

@RTroywest I have tried and tried, I cannot get the Android version to build unless I directly reference the nuget... I have to be doing something wrong. I'll have to try again this evening.

BobbyCannon avatar Sep 06 '22 11:09 BobbyCannon

@RTroywest Could you share a small project that builds? If not, no worries. I'm just curious is all.

BobbyCannon avatar Sep 06 '22 12:09 BobbyCannon

OK, I have it building and executing. Here is what I had to do. I'm only testing Windows and Android

I was able to include the nuget for everything but Android. I was able to use the code above but only for Android. I had to do one extra ItemGroup to reference the dll (Android Only).

so if you just remove the PackageReference to Microsoft.CognitiveServices.Speech then copy and page the config below into your Maui project file, you should also have a working solution.

	<ItemGroup Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) != 'android'">
		<PackageReference Include="Microsoft.CognitiveServices.Speech" Version="1.23.0" />
	</ItemGroup>

	<ItemGroup Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">
		<AndroidNativeLibrary Include="libs\arm64-v8a\libMicrosoft.CognitiveServices.Speech.core.so">
			<Abi>arm64-v8a</Abi>
		</AndroidNativeLibrary>
		<AndroidNativeLibrary Include="libs\arm64-v8a\libMicrosoft.CognitiveServices.Speech.extension.audio.sys.so">
			<Abi>arm64-v8a</Abi>
		</AndroidNativeLibrary>
		<AndroidNativeLibrary Include="libs\arm64-v8a\libMicrosoft.CognitiveServices.Speech.extension.kws.so">
			<Abi>arm64-v8a</Abi>
		</AndroidNativeLibrary>
		<AndroidNativeLibrary Include="libs\arm64-v8a\libMicrosoft.CognitiveServices.Speech.extension.lu.so">
			<Abi>arm64-v8a</Abi>
		</AndroidNativeLibrary>
	</ItemGroup>

	<ItemGroup Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">
		<AndroidNativeLibrary Include="libs\armeabi-v7a\libMicrosoft.CognitiveServices.Speech.core.so">
			<Abi>armeabi-v7a</Abi>
		</AndroidNativeLibrary>
		<AndroidNativeLibrary Include="libs\armeabi-v7a\libMicrosoft.CognitiveServices.Speech.extension.audio.sys.so">
			<Abi>armeabi-v7a</Abi>
		</AndroidNativeLibrary>
		<AndroidNativeLibrary Include="libs\armeabi-v7a\libMicrosoft.CognitiveServices.Speech.extension.kws.so">
			<Abi>armeabi-v7a</Abi>
		</AndroidNativeLibrary>
		<AndroidNativeLibrary Include="libs\armeabi-v7a\libMicrosoft.CognitiveServices.Speech.extension.lu.so">
			<Abi>armeabi-v7a</Abi>
		</AndroidNativeLibrary>
	</ItemGroup>

	<ItemGroup Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">
		<AndroidNativeLibrary Include="libs\x86\libMicrosoft.CognitiveServices.Speech.core.so">
			<Abi>x86</Abi>
		</AndroidNativeLibrary>
		<AndroidNativeLibrary Include="libs\x86\libMicrosoft.CognitiveServices.Speech.extension.audio.sys.so">
			<Abi>x86</Abi>
		</AndroidNativeLibrary>
		<AndroidNativeLibrary Include="libs\x86\libMicrosoft.CognitiveServices.Speech.extension.kws.so">
			<Abi>x86</Abi>
		</AndroidNativeLibrary>
		<AndroidNativeLibrary Include="libs\x86\libMicrosoft.CognitiveServices.Speech.extension.lu.so">
			<Abi>x86</Abi>
		</AndroidNativeLibrary>
	</ItemGroup>

	<ItemGroup Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">
		<AndroidNativeLibrary Include="libs\x86_64\libMicrosoft.CognitiveServices.Speech.core.so">
			<Abi>x86_64</Abi>
		</AndroidNativeLibrary>
		<AndroidNativeLibrary Include="libs\x86_64\libMicrosoft.CognitiveServices.Speech.extension.audio.sys.so">
			<Abi>x86_64</Abi>
		</AndroidNativeLibrary>
		<AndroidNativeLibrary Include="libs\x86_64\libMicrosoft.CognitiveServices.Speech.extension.kws.so">
			<Abi>x86_64</Abi>
		</AndroidNativeLibrary>
		<AndroidNativeLibrary Include="libs\x86_64\libMicrosoft.CognitiveServices.Speech.extension.lu.so">
			<Abi>x86_64</Abi>
		</AndroidNativeLibrary>
	</ItemGroup>

	<ItemGroup Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">
		<Reference Include="Microsoft.CognitiveServices.Speech.csharp">
			<HintPath>libs\Microsoft.CognitiveServices.Speech.csharp.dll</HintPath>
		</Reference>
	</ItemGroup>

BobbyCannon avatar Sep 06 '22 19:09 BobbyCannon

@BobbyCannon @RTroywest Hi, thanks for your help I was trying to do the test without success. I am a Maui beginner and I think that I missing this step "you will need to register all of the abis you need " No idea...How to register an Abis of the DLLS?

The steps that I am doing:

  • download the plugin

  • Go to the plugin folder and copy the monoandroid\libs in a new folder named "libs"

  • Reference in the PinERP.csproj removing this:

  • <ItemGroup> <PackageReference Include="Microsoft.CognitiveServices.Speech" Version="1.23.0" /> </ItemGroup>

  • add the references that you write in the post.

felique avatar Sep 07 '22 04:09 felique

@BobbyCannon @RTroywest Hi, thanks for your help I was trying to do the test without success. I am a Maui beginner and I think that I missing this step "you will need to register all of the abis you need " No idea...How to register an Abis of the DLLS?

The steps that I am doing:

  • download the plugin
  • Go to the plugin folder and copy the monoandroid\libs in a new folder named "libs"
  • Reference in the PinERP.csproj removing this:
  • <ItemGroup> <PackageReference Include="Microsoft.CognitiveServices.Speech" Version="1.23.0" /> </ItemGroup>
  • add the references that you write in the post.

Here is what I eventually did. I didn't want to copy the actually nugets files to my project. Later if the nuget revs, I can just find and replace the version and boom I'm upgraded.

Here is a step by step process to get it working.

  1. Start a Maui project.
  2. Open the "csproj" of the Maui project.
  3. Paste the code below.
  4. Do a find replace for "C:\Users\bobby.nuget" > "C:\Users[Your User Name].nuget"
  5. Build and test
	<ItemGroup Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) != 'android'">
		<PackageReference Include="Microsoft.CognitiveServices.Speech" Version="1.23.0" />
	</ItemGroup>

	<ItemGroup Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">
		<AndroidNativeLibrary Include="C:\Users\bobby\.nuget\packages\microsoft.cognitiveservices.speech\1.23.0\build\monoandroid\libs\arm64-v8a\libMicrosoft.CognitiveServices.Speech.core.so">
			<Abi>arm64-v8a</Abi>
		</AndroidNativeLibrary>
		<AndroidNativeLibrary Include="C:\Users\bobby\.nuget\packages\microsoft.cognitiveservices.speech\1.23.0\build\monoandroid\libs\arm64-v8a\libMicrosoft.CognitiveServices.Speech.extension.audio.sys.so">
			<Abi>arm64-v8a</Abi>
		</AndroidNativeLibrary>
		<AndroidNativeLibrary Include="C:\Users\bobby\.nuget\packages\microsoft.cognitiveservices.speech\1.23.0\build\monoandroid\libs\arm64-v8a\libMicrosoft.CognitiveServices.Speech.extension.kws.so">
			<Abi>arm64-v8a</Abi>
		</AndroidNativeLibrary>
		<AndroidNativeLibrary Include="C:\Users\bobby\.nuget\packages\microsoft.cognitiveservices.speech\1.23.0\build\monoandroid\libs\arm64-v8a\libMicrosoft.CognitiveServices.Speech.extension.lu.so">
			<Abi>arm64-v8a</Abi>
		</AndroidNativeLibrary>
	</ItemGroup>

	<ItemGroup Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">
		<AndroidNativeLibrary Include="C:\Users\bobby\.nuget\packages\microsoft.cognitiveservices.speech\1.23.0\build\monoandroid\libs\armeabi-v7a\libMicrosoft.CognitiveServices.Speech.core.so">
			<Abi>armeabi-v7a</Abi>
		</AndroidNativeLibrary>
		<AndroidNativeLibrary Include="C:\Users\bobby\.nuget\packages\microsoft.cognitiveservices.speech\1.23.0\build\monoandroid\libs\armeabi-v7a\libMicrosoft.CognitiveServices.Speech.extension.audio.sys.so">
			<Abi>armeabi-v7a</Abi>
		</AndroidNativeLibrary>
		<AndroidNativeLibrary Include="C:\Users\bobby\.nuget\packages\microsoft.cognitiveservices.speech\1.23.0\build\monoandroid\libs\armeabi-v7a\libMicrosoft.CognitiveServices.Speech.extension.kws.so">
			<Abi>armeabi-v7a</Abi>
		</AndroidNativeLibrary>
		<AndroidNativeLibrary Include="C:\Users\bobby\.nuget\packages\microsoft.cognitiveservices.speech\1.23.0\build\monoandroid\libs\armeabi-v7a\libMicrosoft.CognitiveServices.Speech.extension.lu.so">
			<Abi>armeabi-v7a</Abi>
		</AndroidNativeLibrary>
	</ItemGroup>

	<ItemGroup Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">
		<AndroidNativeLibrary Include="C:\Users\bobby\.nuget\packages\microsoft.cognitiveservices.speech\1.23.0\build\monoandroid\libs\x86\libMicrosoft.CognitiveServices.Speech.core.so">
			<Abi>x86</Abi>
		</AndroidNativeLibrary>
		<AndroidNativeLibrary Include="C:\Users\bobby\.nuget\packages\microsoft.cognitiveservices.speech\1.23.0\build\monoandroid\libs\x86\libMicrosoft.CognitiveServices.Speech.extension.audio.sys.so">
			<Abi>x86</Abi>
		</AndroidNativeLibrary>
		<AndroidNativeLibrary Include="C:\Users\bobby\.nuget\packages\microsoft.cognitiveservices.speech\1.23.0\build\monoandroid\libs\x86\libMicrosoft.CognitiveServices.Speech.extension.kws.so">
			<Abi>x86</Abi>
		</AndroidNativeLibrary>
		<AndroidNativeLibrary Include="C:\Users\bobby\.nuget\packages\microsoft.cognitiveservices.speech\1.23.0\build\monoandroid\libs\x86\libMicrosoft.CognitiveServices.Speech.extension.lu.so">
			<Abi>x86</Abi>
		</AndroidNativeLibrary>
	</ItemGroup>

	<ItemGroup Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">
		<AndroidNativeLibrary Include="C:\Users\bobby\.nuget\packages\microsoft.cognitiveservices.speech\1.23.0\build\monoandroid\libs\x86_64\libMicrosoft.CognitiveServices.Speech.core.so">
			<Abi>x86_64</Abi>
		</AndroidNativeLibrary>
		<AndroidNativeLibrary Include="C:\Users\bobby\.nuget\packages\microsoft.cognitiveservices.speech\1.23.0\build\monoandroid\libs\x86_64\libMicrosoft.CognitiveServices.Speech.extension.audio.sys.so">
			<Abi>x86_64</Abi>
		</AndroidNativeLibrary>
		<AndroidNativeLibrary Include="C:\Users\bobby\.nuget\packages\microsoft.cognitiveservices.speech\1.23.0\build\monoandroid\libs\x86_64\libMicrosoft.CognitiveServices.Speech.extension.kws.so">
			<Abi>x86_64</Abi>
		</AndroidNativeLibrary>
		<AndroidNativeLibrary Include="C:\Users\bobby\.nuget\packages\microsoft.cognitiveservices.speech\1.23.0\build\monoandroid\libs\x86_64\libMicrosoft.CognitiveServices.Speech.extension.lu.so">
			<Abi>x86_64</Abi>
		</AndroidNativeLibrary>
	</ItemGroup>

	<ItemGroup Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">
		<Reference Include="Microsoft.CognitiveServices.Speech.csharp">
			<HintPath>C:\Users\bobby\.nuget\packages\microsoft.cognitiveservices.speech\1.23.0\lib\monoandroid\Microsoft.CognitiveServices.Speech.csharp.dll</HintPath>
		</Reference>
	</ItemGroup>


BobbyCannon avatar Sep 07 '22 11:09 BobbyCannon

@BobbyCannon, thanks very much for your guide; the android project compiles well. But I have a problem when I begin the voice Recognition.

The code:

var config = SpeechConfig.FromSubscription(Constants.CognitiveServicesApiKey, Constants.CognitiveServicesRegion); recognizer = new SpeechRecognizer(config) await recognizer.StartContinuousRecognitionAsync();

When the last line recognizer.StartContinuousRecognitionAsync() is executed I get the follow error: Error:

{System.ApplicationException: Exception with an error code: 0x15 at Microsoft.CognitiveServices.Speech.Internal.SpxExceptionThrower.ThrowIfFail(IntPtr hr) at Microsoft.CognitiveServices.Speech.Recognizer.StartContinuousRecognition() at Microsoft.CognitiveServices.Speech.Recognizer.DoAsyncRecognitionAction(Action recoImplAction) at Microsoft.CognitiveServices.Speech.SpeechRecognizer.<StartContinuousRecognitionAsync>b__52_0() at System.Threading.Tasks.Task.InnerInvoke() at System.Threading.Tasks.Task.<>c.<.cctor>b__272_0(Object obj) at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state) --- End of stack trace from previous location --- at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread) --- End of stack trace from previous location --- at PinERP.MainPage.OnTranscribeClicked(Object sender, EventArgs e) in D:\desarrollo\TFG\PinERP\PinERP\MainPage.xaml.cs:line 113}

I don't know if I have to add something new in Maui because my code is based on Xamarin. The windows project works well, but the android project doesn't.

Thanks again for your help.

@RTroywest, if your android project is working fine, please send me how you run the Speech service.

felique avatar Sep 08 '22 03:09 felique

@felique If you'll search the error, you'll see that 0x15 is a SPXERR_MIC_ERROR. Meaning you might have permission issues and / or microphone issues?

BobbyCannon avatar Sep 09 '22 17:09 BobbyCannon

We (Speech SDK team) are working on to update the NuGet to support .NET MAUI for Android (and also other targets). We target to provide update in the next Speech SDK release in October 2022.

jhakulin avatar Sep 30 '22 21:09 jhakulin

Hi @jhakulin ,

Is there any update about the fix? Thanks

jonmikeli avatar Oct 11 '22 12:10 jonmikeli

Hi all,

It seems that the Microsoft.CognitiveServices.Speech (1.24.0) solves the issue on Android (not tested yet on iOS).

jonmikeli avatar Oct 15 '22 08:10 jonmikeli

@jonmikeli Thank you for the information! I tried it too, and it worked fine after updating Microsoft.CognitiveServices.Speech to 1.24.0.

device : Pixel 5a

clipboard_20221016161637

shuheydev avatar Oct 16 '22 07:10 shuheydev

Apparently, it works on Android but still having issues on iOS. Do you experience the same?

jonmikeli avatar Oct 17 '22 14:10 jonmikeli

Unfortunately I don't have an ios device so I can't check that. I would appreciate it if someone could check that😊

shuheydev avatar Oct 26 '22 06:10 shuheydev

Support for iOS and Maccatalyst has been added to 1.25.0 version of Azure Speech SDK Nuget https://www.nuget.org/packages/Microsoft.CognitiveServices.Speech

jhakulin avatar Feb 03 '23 16:02 jhakulin

Hi @shuheydev. We have added the "s/try-latest-version" label to this issue, which indicates that we'd like you to try and reproduce this issue on the latest available public version. This can happen because we think that this issue was fixed in a version that has just been released, or the information provided by you indicates that you might be working with an older version.

You can install the latest version by installing the latest Visual Studio (Preview) with the .NET MAUI workload installed. If the issue still persists, please let us know with any additional details and ideally a reproduction project provided through a GitHub repository.

This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

ghost avatar Feb 06 '23 18:02 ghost