Fix .NET build/package, resolve package conflict in Java app

This commit is contained in:
Reuben Morais 2020-08-05 12:43:06 +02:00
parent 4d726e820d
commit 8c840bed23
13 changed files with 30 additions and 29 deletions

View File

@ -193,9 +193,9 @@ Please refer to TensorFlow documentation on how to setup the environment to buil
Using the library from Android project Using the library from Android project
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
We provide uptodate and tested ``libdeepspeech`` usable as an ``AAR`` package, We provide up-to-date and tested STT usable as an ``AAR`` package,
for Android versions starting with 7.0 to 11.0. The package is published on for Android versions starting with 7.0 to 11.0. The package is published on
`JCenter <https://bintray.com/alissy/org.mozilla.deepspeech/libdeepspeech>`_, `JCenter <https://bintray.com/alissy/org.mozilla.voice/stt>`_,
and the ``JCenter`` repository should be available by default in any Android and the ``JCenter`` repository should be available by default in any Android
project. Please make sure your project is setup to pull from this repository. project. Please make sure your project is setup to pull from this repository.
You can then include the library by just adding this line to your You can then include the library by just adding this line to your
@ -203,7 +203,7 @@ You can then include the library by just adding this line to your
.. code-block:: .. code-block::
implementation 'deepspeech.mozilla.org:libdeepspeech:VERSION@aar' implementation 'voice.mozilla.org:stt:VERSION@aar'
Building ``libmozilla_voice_stt.so`` Building ``libmozilla_voice_stt.so``
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -220,17 +220,17 @@ Or (ARM64):
bazel build --workspace_status_command="bash native_client/bazel_workspace_status_cmd.sh" --config=monolithic --config=android --config=android_arm64 --define=runtime=tflite --action_env ANDROID_NDK_API_LEVEL=21 --cxxopt=-std=c++14 --copt=-D_GLIBCXX_USE_C99 //native_client:libmozilla_voice_stt.so bazel build --workspace_status_command="bash native_client/bazel_workspace_status_cmd.sh" --config=monolithic --config=android --config=android_arm64 --define=runtime=tflite --action_env ANDROID_NDK_API_LEVEL=21 --cxxopt=-std=c++14 --copt=-D_GLIBCXX_USE_C99 //native_client:libmozilla_voice_stt.so
Building ``libdeepspeech.aar`` Building ``libmozillavoicestt.aar``
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
In the unlikely event you have to rebuild the JNI bindings, source code is In the unlikely event you have to rebuild the JNI bindings, source code is
available under the ``libdeepspeech`` subdirectory. Building depends on shared available under the ``libmozillavoicestt`` subdirectory. Building depends on shared
object: please ensure to place ``libmozilla_voice_stt.so`` into the object: please ensure to place ``libmozilla_voice_stt.so`` into the
``libdeepspeech/libs/{arm64-v8a,armeabi-v7a,x86_64}/`` matching subdirectories. ``libmozillavoicestt/libs/{arm64-v8a,armeabi-v7a,x86_64}/`` matching subdirectories.
Building the bindings is managed by ``gradle`` and should be limited to issuing Building the bindings is managed by ``gradle`` and should be limited to issuing
``./gradlew libdeepspeech:build``, producing an ``AAR`` package in ``./gradlew libmozillavoicestt:build``, producing an ``AAR`` package in
``./libdeepspeech/build/outputs/aar/``. ``./libmozillavoicestt/build/outputs/aar/``.
Please note that you might have to copy the file to a local Maven repository Please note that you might have to copy the file to a local Maven repository
and adapt file naming (when missing, the error message should states what and adapt file naming (when missing, the error message should states what

View File

@ -3,8 +3,8 @@ using MozillaVoiceSttClient.Extensions;
using System; using System;
using System.IO; using System.IO;
using MozillaVoiceStt.Enums; using MozillaVoiceSttClient.Enums;
using MozillaVoiceStt.Models; using MozillaVoiceSttClient.Models;
namespace MozillaVoiceSttClient namespace MozillaVoiceSttClient
{ {

View File

@ -1,6 +1,6 @@
using CommonServiceLocator; using CommonServiceLocator;
using MozillaVoiceStt.WPF.ViewModels; using MozillaVoiceStt.WPF.ViewModels;
using MozillaVoiceStt.Interfaces; using MozillaVoiceSttClient.Interfaces;
using GalaSoft.MvvmLight.Ioc; using GalaSoft.MvvmLight.Ioc;
using System.Windows; using System.Windows;
@ -19,8 +19,8 @@ namespace MozillaVoiceSttWPF
try try
{ {
//Register instance of Mozilla Voice STT //Register instance of Mozilla Voice STT
MozillaVoiceSttClient.Model client = MozillaVoiceSttClient.MozillaVoiceSttModel client =
new MozillaVoiceSttClient.Model("deepspeech-0.8.0-models.pbmm"); new MozillaVoiceSttClient.MozillaVoiceSttModel("deepspeech-0.8.0-models.pbmm");
SimpleIoc.Default.Register<IMozillaVoiceSttModel>(() => client); SimpleIoc.Default.Register<IMozillaVoiceSttModel>(() => client);
SimpleIoc.Default.Register<MainWindowViewModel>(); SimpleIoc.Default.Register<MainWindowViewModel>();

View File

@ -4,7 +4,7 @@ android {
compileSdkVersion 27 compileSdkVersion 27
defaultConfig { defaultConfig {
applicationId "org.mozilla.voice.stt" applicationId "org.mozilla.voice.sttapp"
minSdkVersion 21 minSdkVersion 21
targetSdkVersion 27 targetSdkVersion 27
versionName androidGitVersion.name() versionName androidGitVersion.name()

View File

@ -1,4 +1,4 @@
package org.mozilla.voice.stt; package org.mozilla.voice.sttapp;
import android.content.Context; import android.content.Context;
import android.support.test.InstrumentationRegistry; import android.support.test.InstrumentationRegistry;
@ -21,6 +21,6 @@ public class ExampleInstrumentedTest {
// Context of the app under test. // Context of the app under test.
Context appContext = InstrumentationRegistry.getTargetContext(); Context appContext = InstrumentationRegistry.getTargetContext();
assertEquals("org.mozilla.voice.stt", appContext.getPackageName()); assertEquals("org.mozilla.voice.sttapp", appContext.getPackageName());
} }
} }

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.mozilla.voice.stt"> package="org.mozilla.voice.sttapp">
<application <application
android:allowBackup="true" android:allowBackup="true"

View File

@ -1,4 +1,4 @@
package org.mozilla.voice.stt; package org.mozilla.voice.sttapp;
import android.support.v7.app.AppCompatActivity; import android.support.v7.app.AppCompatActivity;
import android.os.Bundle; import android.os.Bundle;

View File

@ -1,4 +1,4 @@
package org.mozilla.voice.stt; package org.mozilla.voice.sttapp;
import org.junit.Test; import org.junit.Test;

View File

@ -11,5 +11,5 @@ mkdir -p ${TASKCLUSTER_ARTIFACTS} || true
cp ${DS_ROOT_TASK}/DeepSpeech/ds/tensorflow/bazel*.log ${TASKCLUSTER_ARTIFACTS}/ cp ${DS_ROOT_TASK}/DeepSpeech/ds/tensorflow/bazel*.log ${TASKCLUSTER_ARTIFACTS}/
cp ${DS_ROOT_TASK}/DeepSpeech/ds/native_client/java/app/build/outputs/apk/release/app*.apk ${TASKCLUSTER_ARTIFACTS}/ cp ${DS_ROOT_TASK}/DeepSpeech/ds/native_client/java/app/build/outputs/apk/release/app*.apk ${TASKCLUSTER_ARTIFACTS}/
cp ${DS_ROOT_TASK}/DeepSpeech/ds/native_client/java/libdeepspeech/build/outputs/aar/libdeepspeech*.aar ${TASKCLUSTER_ARTIFACTS}/ cp ${DS_ROOT_TASK}/DeepSpeech/ds/native_client/java/libmozillavoicestt/build/outputs/aar/libmozillavoicestt*.aar ${TASKCLUSTER_ARTIFACTS}/
cp ${DS_ROOT_TASK}/DeepSpeech/ds/native_client/java/libdeepspeech/build/libdeepspeech-*.maven.zip ${TASKCLUSTER_ARTIFACTS}/ cp ${DS_ROOT_TASK}/DeepSpeech/ds/native_client/java/libmozillavoicestt/build/libmozillavoicestt-*.maven.zip ${TASKCLUSTER_ARTIFACTS}/

View File

@ -322,22 +322,22 @@ run_tflite_basic_inference_tests()
run_netframework_inference_tests() run_netframework_inference_tests()
{ {
set +e set +e
phrase_pbmodel_nolm=$(DeepSpeechConsole.exe --model ${TASKCLUSTER_TMP_DIR}/${model_name} --audio ${TASKCLUSTER_TMP_DIR}/${ldc93s1_sample_filename} 2>${TASKCLUSTER_TMP_DIR}/stderr) phrase_pbmodel_nolm=$(MozillaVoiceSttConsole.exe --model ${TASKCLUSTER_TMP_DIR}/${model_name} --audio ${TASKCLUSTER_TMP_DIR}/${ldc93s1_sample_filename} 2>${TASKCLUSTER_TMP_DIR}/stderr)
set -e set -e
assert_working_ldc93s1 "${phrase_pbmodel_nolm}" "$?" assert_working_ldc93s1 "${phrase_pbmodel_nolm}" "$?"
set +e set +e
phrase_pbmodel_nolm=$(DeepSpeechConsole.exe --model ${TASKCLUSTER_TMP_DIR}/${model_name} --audio ${TASKCLUSTER_TMP_DIR}/${ldc93s1_sample_filename} --extended yes 2>${TASKCLUSTER_TMP_DIR}/stderr) phrase_pbmodel_nolm=$(MozillaVoiceSttConsole.exe --model ${TASKCLUSTER_TMP_DIR}/${model_name} --audio ${TASKCLUSTER_TMP_DIR}/${ldc93s1_sample_filename} --extended yes 2>${TASKCLUSTER_TMP_DIR}/stderr)
set -e set -e
assert_working_ldc93s1 "${phrase_pbmodel_nolm}" "$?" assert_working_ldc93s1 "${phrase_pbmodel_nolm}" "$?"
set +e set +e
phrase_pbmodel_nolm=$(DeepSpeechConsole.exe --model ${TASKCLUSTER_TMP_DIR}/${model_name_mmap} --audio ${TASKCLUSTER_TMP_DIR}/${ldc93s1_sample_filename} 2>${TASKCLUSTER_TMP_DIR}/stderr) phrase_pbmodel_nolm=$(MozillaVoiceSttConsole.exe --model ${TASKCLUSTER_TMP_DIR}/${model_name_mmap} --audio ${TASKCLUSTER_TMP_DIR}/${ldc93s1_sample_filename} 2>${TASKCLUSTER_TMP_DIR}/stderr)
set -e set -e
assert_working_ldc93s1 "${phrase_pbmodel_nolm}" "$?" assert_working_ldc93s1 "${phrase_pbmodel_nolm}" "$?"
set +e set +e
phrase_pbmodel_withlm=$(DeepSpeechConsole.exe --model ${TASKCLUSTER_TMP_DIR}/${model_name_mmap} --scorer ${TASKCLUSTER_TMP_DIR}/kenlm.scorer --audio ${TASKCLUSTER_TMP_DIR}/${ldc93s1_sample_filename} 2>${TASKCLUSTER_TMP_DIR}/stderr) phrase_pbmodel_withlm=$(MozillaVoiceSttConsole.exe --model ${TASKCLUSTER_TMP_DIR}/${model_name_mmap} --scorer ${TASKCLUSTER_TMP_DIR}/kenlm.scorer --audio ${TASKCLUSTER_TMP_DIR}/${ldc93s1_sample_filename} 2>${TASKCLUSTER_TMP_DIR}/stderr)
set -e set -e
assert_working_ldc93s1_lm "${phrase_pbmodel_withlm}" "$?" assert_working_ldc93s1_lm "${phrase_pbmodel_withlm}" "$?"
} }

View File

@ -341,5 +341,6 @@ do_deepspeech_ios_framework_build()
xcodeArch="arm64" xcodeArch="arm64"
;; ;;
esac esac
xcodebuild -workspace mozilla_voice_stt.xcworkspace -list
xcodebuild -workspace mozilla_voice_stt.xcworkspace -scheme mozilla_voice_stt_test -configuration Release -arch "${xcodeArch}" -sdk "${iosSDK}" -derivedDataPath DerivedData CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO CODE_SIGNING_ALLOWED=NO xcodebuild -workspace mozilla_voice_stt.xcworkspace -scheme mozilla_voice_stt_test -configuration Release -arch "${xcodeArch}" -sdk "${iosSDK}" -derivedDataPath DerivedData CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO CODE_SIGNING_ALLOWED=NO
} }

View File

@ -18,10 +18,10 @@ install_nuget()
mkdir -p "${TASKCLUSTER_TMP_DIR}/ds/" mkdir -p "${TASKCLUSTER_TMP_DIR}/ds/"
nuget_pkg_url=$(get_dep_nuget_pkg_url "${nuget}") nuget_pkg_url=$(get_dep_nuget_pkg_url "${nuget}")
console_pkg_url=$(get_dep_nuget_pkg_url "DeepSpeechConsole.exe") console_pkg_url=$(get_dep_nuget_pkg_url "MozillaVoiceSttConsole.exe")
${WGET} -O - "${nuget_pkg_url}" | gunzip > "${TASKCLUSTER_TMP_DIR}/${PROJECT_NAME}.${DS_VERSION}.nupkg" ${WGET} -O - "${nuget_pkg_url}" | gunzip > "${TASKCLUSTER_TMP_DIR}/${PROJECT_NAME}.${DS_VERSION}.nupkg"
${WGET} -O - "${console_pkg_url}" | gunzip > "${TASKCLUSTER_TMP_DIR}/ds/DeepSpeechConsole.exe" ${WGET} -O - "${console_pkg_url}" | gunzip > "${TASKCLUSTER_TMP_DIR}/ds/MozillaVoiceSttConsole.exe"
nuget sources add -Name repo -Source $(cygpath -w "${TASKCLUSTER_TMP_DIR}/repo/") nuget sources add -Name repo -Source $(cygpath -w "${TASKCLUSTER_TMP_DIR}/repo/")
@ -37,7 +37,7 @@ install_nuget()
nuget install NAudio nuget install NAudio
cp NAudio*/lib/net35/NAudio.dll ${TASKCLUSTER_TMP_DIR}/ds/ cp NAudio*/lib/net35/NAudio.dll ${TASKCLUSTER_TMP_DIR}/ds/
cp ${PROJECT_NAME}.${DS_VERSION}/build/libmozilla_voice_stt.so ${TASKCLUSTER_TMP_DIR}/ds/ cp ${PROJECT_NAME}.${DS_VERSION}/build/libmozilla_voice_stt.so ${TASKCLUSTER_TMP_DIR}/ds/
cp ${PROJECT_NAME}.${DS_VERSION}/lib/net46/DeepSpeechClient.dll ${TASKCLUSTER_TMP_DIR}/ds/ cp ${PROJECT_NAME}.${DS_VERSION}/lib/net46/MozillaVoiceSttClient.dll ${TASKCLUSTER_TMP_DIR}/ds/
ls -hal ${TASKCLUSTER_TMP_DIR}/ds/ ls -hal ${TASKCLUSTER_TMP_DIR}/ds/

View File

@ -14,7 +14,7 @@ package_libdeepspeech_as_zip "libmozilla_voice_stt.zip"
cp ${DS_ROOT_TASK}/DeepSpeech/ds/native_client/dotnet/*.nupkg ${TASKCLUSTER_ARTIFACTS}/ cp ${DS_ROOT_TASK}/DeepSpeech/ds/native_client/dotnet/*.nupkg ${TASKCLUSTER_ARTIFACTS}/
cp ${DS_ROOT_TASK}/DeepSpeech/ds/native_client/dotnet/DeepSpeechConsole/bin/x64/Release/DeepSpeechConsole.exe ${TASKCLUSTER_ARTIFACTS}/ cp ${DS_ROOT_TASK}/DeepSpeech/ds/native_client/dotnet/MozillaVoiceSttConsole/bin/x64/Release/MozillaVoiceSttConsole.exe ${TASKCLUSTER_ARTIFACTS}/
if [ -d ${DS_ROOT_TASK}/DeepSpeech/ds/wheels ]; then if [ -d ${DS_ROOT_TASK}/DeepSpeech/ds/wheels ]; then
cp ${DS_ROOT_TASK}/DeepSpeech/ds/wheels/* ${TASKCLUSTER_ARTIFACTS}/ cp ${DS_ROOT_TASK}/DeepSpeech/ds/wheels/* ${TASKCLUSTER_ARTIFACTS}/