From 2020f1b15a4d1da1263b98f8f408c5e43a6685b9 Mon Sep 17 00:00:00 2001 From: Reuben Morais Date: Wed, 28 Jul 2021 14:24:11 +0200 Subject: [PATCH 1/4] Undo accidental auth removal in check_artifact_exists action --- .../check_artifact_exists/dist/index.js | Bin 1052781 -> 1053200 bytes .github/actions/check_artifact_exists/main.js | 7 +++++++ 2 files changed, 7 insertions(+) diff --git a/.github/actions/check_artifact_exists/dist/index.js b/.github/actions/check_artifact_exists/dist/index.js index 9f900b5367a2a2a73bcce5f43348590f7d4e41da..ebfdd28fd0eeaa209533919314e329871179140c 100644 GIT binary patch delta 324 zcmaF6z+u7?hYkN&l}qxoQ}YyT6_WFdQuWePOFZ)mN=r19(lbjkN|WNjvXd3r#2BqN zzh_;?$dg!Fl3}F)7S`E3f&Cxjv`b9v)8BJ*h)({%&N6ud3$KW4MMh$2aY<^5f{{W| zYDrOMYO&JfKu&2DuocCrC2onCIjJccN;njXPcD!U+B~0Alo4bk#9;_s3GSIC9;HbN zL9W3e3XTDu3X=o4Y#22s_i-w0KFrm?3euyfqmt)nK|d zq1jNN-B5rLh?#(x8Hibcm=%cGfS4VKIe?fGh`E568;E&;m=}oofS7-}p@4u509L4I AH~;_u delta 119 zcmbQR#Nq7%hYkN&H@maVXWaas{UhV#g6)En6?phJui#>1+^oRU&kE!TOn)E7%RPOK z3I}mdKF((jn0Wmia^8hg~5c2^s|8yQ90Tuw+ CqaJzy diff --git a/.github/actions/check_artifact_exists/main.js b/.github/actions/check_artifact_exists/main.js index be1559dd..abb9d440 100644 --- a/.github/actions/check_artifact_exists/main.js +++ b/.github/actions/check_artifact_exists/main.js @@ -37,6 +37,7 @@ async function getGoodArtifacts(client, owner, repo, releaseId, name) { async function main() { try { + const token = core.getInput("github_token", { required: true }); const [owner, repo] = core.getInput("repo", { required: true }).split("/"); const path = core.getInput("path", { required: true }); const name = core.getInput("name"); @@ -44,6 +45,7 @@ async function main() { const releaseTag = core.getInput("release-tag"); const OctokitWithThrottling = GitHub.plugin(throttling); const client = new OctokitWithThrottling({ + auth: token, throttle: { onRateLimit: (retryAfter, options) => { console.log( @@ -54,6 +56,9 @@ async function main() { if (options.request.retryCount <= 2) { console.log(`Retrying after ${retryAfter} seconds!`); return true; + } else { + console.log("Exhausted 2 retries"); + core.setFailed("Exhausted 2 retries"); } }, onAbuseLimit: (retryAfter, options) => { @@ -61,6 +66,7 @@ async function main() { console.log( `Abuse detected for request ${options.method} ${options.url}` ); + core.setFailed(`GitHub REST API Abuse detected for request ${options.method} ${options.url}`) }, }, }); @@ -101,6 +107,7 @@ async function main() { await Download(artifact.url, dir, { headers: { "Accept": "application/octet-stream", + "Authorization": `token ${token}`, }, }); } From 42ebbf91200f3ff450f44f1b94824996930505a0 Mon Sep 17 00:00:00 2001 From: Reuben Morais Date: Tue, 27 Jul 2021 21:27:40 +0200 Subject: [PATCH 2/4] Remove full TF backend --- .github/actions/host-build/action.yml | 5 +- .github/actions/python-build/action.yml | 6 - .github/actions/run-tests/action.yml | 8 +- .github/workflows/build-and-test.yml | 474 ++++++++---------------- ci_scripts/all-utils.sh | 17 - ci_scripts/build-utils.sh | 18 +- ci_scripts/cpp-tests-prod.sh | 26 -- ci_scripts/cpp-tests.sh | 24 -- ci_scripts/cppwin-tests.sh | 20 - ci_scripts/electronjs-tests-prod.sh | 48 --- ci_scripts/electronjs-tests.sh | 41 -- ci_scripts/host-build.sh | 7 +- ci_scripts/node-tests-prod.sh | 30 -- ci_scripts/node-tests.sh | 25 -- ci_scripts/package-utils.sh | 10 +- ci_scripts/python-tests-prod.sh | 29 -- ci_scripts/python-tests.sh | 21 -- ci_scripts/tf-build.sh | 11 +- ci_scripts/tf-package.sh | 19 +- ci_scripts/tf-setup.sh | 34 -- ci_scripts/tf-vars.sh | 32 +- native_client/BUILD | 136 +++---- native_client/definitions.mk | 8 +- native_client/javascript/binding.gyp | 2 + native_client/stt.cc | 14 +- native_client/tfmodelstate.cc | 263 ------------- native_client/tfmodelstate.h | 35 -- 27 files changed, 247 insertions(+), 1116 deletions(-) delete mode 100755 ci_scripts/cpp-tests-prod.sh delete mode 100755 ci_scripts/cpp-tests.sh delete mode 100755 ci_scripts/cppwin-tests.sh delete mode 100755 ci_scripts/electronjs-tests-prod.sh delete mode 100755 ci_scripts/electronjs-tests.sh delete mode 100755 ci_scripts/node-tests-prod.sh delete mode 100755 ci_scripts/node-tests.sh delete mode 100755 ci_scripts/python-tests-prod.sh delete mode 100755 ci_scripts/python-tests.sh delete mode 100644 native_client/tfmodelstate.cc delete mode 100644 native_client/tfmodelstate.h diff --git a/.github/actions/host-build/action.yml b/.github/actions/host-build/action.yml index 8f2a5039..34522ca2 100644 --- a/.github/actions/host-build/action.yml +++ b/.github/actions/host-build/action.yml @@ -5,11 +5,8 @@ inputs: description: "Target arch for loading script (host/armv7/aarch64)" required: false default: "host" - flavor: - description: "Build flavor" - required: true runs: using: "composite" steps: - - run: ./ci_scripts/${{ inputs.arch }}-build.sh ${{ inputs.flavor }} + - run: ./ci_scripts/${{ inputs.arch }}-build.sh shell: bash diff --git a/.github/actions/python-build/action.yml b/.github/actions/python-build/action.yml index 44e11134..a30df7b8 100644 --- a/.github/actions/python-build/action.yml +++ b/.github/actions/python-build/action.yml @@ -1,9 +1,6 @@ name: "Python binding" description: "Binding a python binding" inputs: - build_flavor: - description: "Python package name" - required: true numpy_build: description: "NumPy build dependecy" required: true @@ -46,9 +43,6 @@ runs: set -xe PROJECT_NAME="stt" - if [ "${{ inputs.build_flavor }}" = "tflite" ]; then - PROJECT_NAME="stt-tflite" - fi OS=$(uname) if [ "${OS}" = "Linux" ]; then diff --git a/.github/actions/run-tests/action.yml b/.github/actions/run-tests/action.yml index 142009ba..0cd2007f 100644 --- a/.github/actions/run-tests/action.yml +++ b/.github/actions/run-tests/action.yml @@ -4,9 +4,6 @@ inputs: runtime: description: "Runtime to use for running test" required: true - build-flavor: - description: "Running against TF or TFLite" - required: true model-kind: description: "Running against CI baked or production model" required: true @@ -22,10 +19,7 @@ runs: - run: | set -xe - build="" - if [ "${{ inputs.build-flavor }}" = "tflite" ]; then - build="_tflite" - fi + build="_tflite" model_kind="" if [ "${{ inputs.model-kind }}" = "prod" ]; then diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 16de407c..68fc5b7f 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -210,10 +210,6 @@ jobs: cp /tmp/train*/output_graph.* /tmp/checkpoint.tar.xz ${{ github.workspace }}/tmp/ - run: | ls -hal /tmp/ ${{ github.workspace }}/tmp/ - - uses: actions/upload-artifact@v2 - with: - name: "test-model.tf-${{ matrix.bitrate }}.zip" - path: ${{ github.workspace }}/tmp/output_graph.pb* - uses: actions/upload-artifact@v2 with: name: "test-model.tflite-${{ matrix.bitrate }}.zip" @@ -235,7 +231,7 @@ jobs: - id: get_cache_key uses: ./.github/actions/get_cache_key with: - extras: "2" + extras: "3" - id: check_artifact_exists uses: ./.github/actions/check_artifact_exists with: @@ -272,9 +268,6 @@ jobs: name: "Lin|Build libstt+client" runs-on: ubuntu-20.04 needs: [ build-tensorflow-Linux, tensorflow_opt-Linux ] - strategy: - matrix: - build-flavor: ["tf", "tflite"] steps: - uses: actions/checkout@v2 with: @@ -285,23 +278,21 @@ jobs: path: ${{ github.workspace }}/ download: true - run: | - tar --skip-old-files -xf ${{ needs.tensorflow_opt-Linux.outputs.cache_key }}.tar.xz + tar --skip-old-files -xf ${{ needs.tensorflow_opt-linux.outputs.cache_key }}.tar.xz rm ${{ needs.tensorflow_opt-Linux.outputs.cache_key }}.tar.xz - run: | sudo apt-get install -y --no-install-recommends make build-essential gfortran git libblas-dev liblapack-dev libsox-dev libmagic-dev libgsm1-dev libltdl-dev libpng-dev python python-dev zlib1g-dev - run: | git status - uses: ./.github/actions/host-build - with: - flavor: ${{ matrix.build-flavor }} - uses: ./.github/actions/package - uses: actions/upload-artifact@v2 with: - name: "native_client.${{ matrix.build-flavor }}.Linux.tar.xz" + name: "native_client.tflite.Linux.tar.xz" path: ${{ github.workspace }}/artifacts/native_client.tar.xz - uses: actions/upload-artifact@v2 with: - name: "libstt.${{ matrix.build-flavor }}.zip" + name: "libstt.tflite.zip" path: ${{ github.workspace }}/artifacts/libstt.zip build-python-Linux: name: "Lin|Build Python bindings" @@ -309,7 +300,6 @@ jobs: needs: [ build-lib_Linux, swig_Linux ] strategy: matrix: - build-flavor: ["tf", "tflite"] python-version: [3.6, 3.7, 3.8, 3.9] steps: - uses: actions/checkout@v2 @@ -317,12 +307,14 @@ jobs: fetch-depth: 1 - uses: actions/download-artifact@v2 with: - name: "native_client.${{ matrix.build-flavor }}.Linux.tar.xz" + name: "native_client.tflite.Linux.tar.xz" path: ${{ github.workspace }}/tensorflow/bazel-bin/native_client/ - run: | cd ${{ github.workspace }}/tensorflow/bazel-bin/native_client/ tar xf native_client.tar.xz - ls -hal + mkdir -p ../tensorflow/lite + mv libtensorflowlite.so ../tensorflow/lite/ + ls -hal . ../tensorflow/lite cd ${{ github.workspace }}/ - uses: actions/download-artifact@v2 with: @@ -342,32 +334,30 @@ jobs: pyver: ${{ matrix.python-version }} - uses: ./.github/actions/python-build with: - build_flavor: ${{ matrix.build-flavor }} numpy_build: "${{ steps.get_numpy.outputs.build_version }}" numpy_dep: "${{ steps.get_numpy.outputs.dep_version }}" - uses: actions/upload-artifact@v2 with: - name: "stt-${{ matrix.build-flavor }}-${{ matrix.python-version }}-Linux.whl" + name: "stt-tflite-${{ matrix.python-version }}-Linux.whl" path: ${{ github.workspace }}/wheels/*.whl build-nodejs-Linux: name: "Lin|Build NodeJS and ElectronJS" runs-on: ubuntu-20.04 needs: [ build-lib_Linux, swig_Linux ] - strategy: - matrix: - build-flavor: ["tf", "tflite"] steps: - uses: actions/checkout@v2 with: fetch-depth: 1 - uses: actions/download-artifact@v2 with: - name: "native_client.${{ matrix.build-flavor }}.Linux.tar.xz" + name: "native_client.tflite.Linux.tar.xz" path: ${{ github.workspace }}/tensorflow/bazel-bin/native_client/ - run: | cd ${{ github.workspace }}/tensorflow/bazel-bin/native_client/ tar xf native_client.tar.xz - ls -hal + mkdir -p ../tensorflow/lite + mv libtensorflowlite.so ../tensorflow/lite/ + ls -hal . ../tensorflow/lite cd ${{ github.workspace }}/ - uses: actions/download-artifact@v2 with: @@ -397,11 +387,11 @@ jobs: electronjs_versions: "5.0.13 6.0.12 6.1.7 7.0.1 7.1.8 8.0.1 9.0.1 9.1.0 9.2.0 10.0.0 10.1.0 11.0.0 12.0.0" - uses: actions/upload-artifact@v2 with: - name: "nodewrapper-${{ matrix.build-flavor }}-Linux_amd64.tar.gz" + name: "nodewrapper-tflite-Linux_amd64.tar.gz" path: ${{ github.workspace }}/native_client/javascript/wrapper.tar.gz - uses: actions/upload-artifact@v2 with: - name: "stt_intermediate-${{ matrix.build-flavor }}-Linux.tgz" + name: "stt_intermediate-tflite-Linux.tgz" path: ${{ github.workspace }}/native_client/javascript/stt-*.tgz test-cpp-Linux: name: "Lin|Test C++ binary" @@ -410,7 +400,6 @@ jobs: if: ${{ github.event_name == 'pull_request' }} strategy: matrix: - build-flavor: ["tf", "tflite"] models: ["test", "prod"] bitrate: ["8k", "16k"] env: @@ -425,14 +414,14 @@ jobs: fetch-depth: 1 - uses: actions/download-artifact@v2 with: - name: "native_client.${{ matrix.build-flavor }}.Linux.tar.xz" + name: "native_client.tflite.Linux.tar.xz" path: ${{ env.CI_TMP_DIR }} - run: | cd ${{ env.CI_TMP_DIR }} mkdir ds && cd ds && tar xf ../native_client.tar.xz - uses: actions/download-artifact@v2 with: - name: "test-model.${{ matrix.build-flavor }}-${{ matrix.bitrate }}.zip" + name: "test-model.tflite-${{ matrix.bitrate }}.zip" path: ${{ env.CI_TMP_DIR }} if: matrix.models == 'test' - run: | @@ -441,7 +430,6 @@ jobs: - uses: ./.github/actions/run-tests with: runtime: "cpp" - build-flavor: ${{ matrix.build-flavor }} bitrate: ${{ matrix.bitrate }} model-kind: ${{ matrix.models }} test-py-Linux: @@ -452,7 +440,6 @@ jobs: strategy: matrix: python-version: [3.6, 3.7, 3.8, 3.9] - build-flavor: ["tf", "tflite"] models: ["test", "prod"] bitrate: ["8k", "16k"] env: @@ -472,11 +459,11 @@ jobs: sudo apt-get install -y --no-install-recommends sox - uses: actions/download-artifact@v2 with: - name: "stt-${{ matrix.build-flavor }}-${{ matrix.python-version }}-Linux.whl" + name: "stt-tflite-${{ matrix.python-version }}-Linux.whl" path: ${{ env.CI_TMP_DIR }} - uses: actions/download-artifact@v2 with: - name: "test-model.${{ matrix.build-flavor }}-${{ matrix.bitrate }}.zip" + name: "test-model.tflite-${{ matrix.bitrate }}.zip" path: ${{ env.CI_TMP_DIR }} if: matrix.models == 'test' - run: | @@ -488,7 +475,6 @@ jobs: - uses: ./.github/actions/run-tests with: runtime: "python" - build-flavor: ${{ matrix.build-flavor }} bitrate: ${{ matrix.bitrate }} model-kind: ${{ matrix.models }} test-nodejs-Linux: @@ -500,7 +486,6 @@ jobs: matrix: # https://nodejs.org/en/about/releases/ nodejs-version: [10, 12, 14, 16] - build-flavor: ["tf", "tflite"] models: ["test"] bitrate: ["16k"] env: @@ -520,11 +505,11 @@ jobs: sudo apt-get install -y --no-install-recommends sox - uses: actions/download-artifact@v2 with: - name: "stt_intermediate-${{ matrix.build-flavor }}-Linux.tgz" + name: "stt_intermediate-tflite-Linux.tgz" path: ${{ env.CI_TMP_DIR }} - uses: actions/download-artifact@v2 with: - name: "test-model.${{ matrix.build-flavor }}-${{ matrix.bitrate }}.zip" + name: "test-model.tflite-${{ matrix.bitrate }}.zip" path: ${{ env.CI_TMP_DIR }} if: matrix.models == 'test' - run: | @@ -534,7 +519,7 @@ jobs: id: node-modules-cache with: path: ~/.npm/ - key: node-modules-${{ matrix.build-flavor }}-${{ runner.os }}-${{ env.CI_NODE_MODULES_NTH }} + key: node-modules-tflite-${{ runner.os }}-${{ env.CI_NODE_MODULES_NTH }} - name: Install STT package run: | ls -hal ${{ env.CI_TMP_DIR }}/ @@ -544,7 +529,6 @@ jobs: - uses: ./.github/actions/run-tests with: runtime: "node" - build-flavor: ${{ matrix.build-flavor }} bitrate: ${{ matrix.bitrate }} model-kind: ${{ matrix.models }} test-electronjs-Linux: @@ -555,7 +539,6 @@ jobs: strategy: matrix: electronjs-version: [5.0.13, 6.1.7, 7.1.8, 8.0.1, 9.2.0, 10.1.0, 11.0.0, 12.0.0] - build-flavor: ["tf", "tflite"] models: ["test"] bitrate: ["16k"] env: @@ -575,11 +558,11 @@ jobs: sudo apt-get install -y --no-install-recommends sox - uses: actions/download-artifact@v2 with: - name: "stt_intermediate-${{ matrix.build-flavor }}-Linux.tgz" + name: "stt_intermediate-tflite-Linux.tgz" path: ${{ env.CI_TMP_DIR }} - uses: actions/download-artifact@v2 with: - name: "test-model.${{ matrix.build-flavor }}-${{ matrix.bitrate }}.zip" + name: "test-model.tflite-${{ matrix.bitrate }}.zip" path: ${{ env.CI_TMP_DIR }} if: matrix.models == 'test' - run: | @@ -589,7 +572,7 @@ jobs: id: electron-modules-cache with: path: ~/.npm/ - key: electron-modules-${{ matrix.build-flavor }}-${{ runner.os }}-${{ env.CI_NODE_MODULES_NTH }} + key: electron-modules-tflite-${{ runner.os }}-${{ env.CI_NODE_MODULES_NTH }} - name: Install STT package run: | ls -hal ${{ env.CI_TMP_DIR }}/ @@ -599,7 +582,6 @@ jobs: - uses: ./.github/actions/run-tests with: runtime: "electronjs" - build-flavor: ${{ matrix.build-flavor }} bitrate: ${{ matrix.bitrate }} model-kind: ${{ matrix.models }} timeout-minutes: 5 @@ -700,64 +682,6 @@ jobs: runs-on: ubuntu-20.04 if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') needs: [build-python-Linux, build-python-macOS, build-python-Windows, build-python-LinuxArmv7, build-python-LinuxAarch64] - steps: - - uses: actions/setup-python@v2 - with: - python-version: 3.8 - - name: Update pip and install twine - run: | - python -m pip install -U pip - python -m pip install -U twine - - uses: actions/download-artifact@v2 - with: - name: stt-tf-3.6.8-macOS.whl - - uses: actions/download-artifact@v2 - with: - name: stt-tf-3.7.9-macOS.whl - - uses: actions/download-artifact@v2 - with: - name: stt-tf-3.8.9-macOS.whl - - uses: actions/download-artifact@v2 - with: - name: stt-tf-3.9.4-macOS.whl - - uses: actions/download-artifact@v2 - with: - name: stt-tf-3.6.8-Windows.whl - - uses: actions/download-artifact@v2 - with: - name: stt-tf-3.7.9-Windows.whl - - uses: actions/download-artifact@v2 - with: - name: stt-tf-3.8.8-Windows.whl - - uses: actions/download-artifact@v2 - with: - name: stt-tf-3.9.4-Windows.whl - - uses: actions/download-artifact@v2 - with: - name: stt-tf-3.6-Linux.whl - - uses: actions/download-artifact@v2 - with: - name: stt-tf-3.7-Linux.whl - - uses: actions/download-artifact@v2 - with: - name: stt-tf-3.8-Linux.whl - - uses: actions/download-artifact@v2 - with: - name: stt-tf-3.9-Linux.whl - - name: Setup PyPI config - run: | - cat << EOF > ~/.pypirc - [pypi] - username=__token__ - password=${{ secrets.PYPI_STT_TOKEN }} - EOF - - run: | - twine upload --repository pypi *.whl - twine-upload-tflite: - name: "Upload STT-tflite packages to PyPI" - runs-on: ubuntu-20.04 - if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') - needs: [build-python-Linux, build-python-macOS, build-python-Windows, build-python-LinuxArmv7, build-python-LinuxAarch64] steps: - uses: actions/setup-python@v2 with: @@ -815,7 +739,7 @@ jobs: cat << EOF > ~/.pypirc [pypi] username=__token__ - password=${{ secrets.PYPI_TFLITE_TOKEN }} + password=${{ secrets.PYPI_STT_TOKEN }} EOF - run: | twine upload --repository pypi *.whl @@ -1011,10 +935,6 @@ jobs: cp /tmp/train*/output_graph.* /tmp/checkpoint.tar.xz ${{ github.workspace }}/tmp/ - run: | ls -hal /tmp/ ${{ github.workspace }}/tmp/ - - uses: actions/upload-artifact@v2 - with: - name: "test-model.tf-${{ matrix.bitrate }}.zip" - path: ${{ github.workspace }}/tmp/output_graph.pb* - uses: actions/upload-artifact@v2 with: name: "test-model.tflite-${{ matrix.bitrate }}.zip" @@ -1036,7 +956,7 @@ jobs: - id: get_cache_key uses: ./.github/actions/get_cache_key with: - extras: "2" + extras: "3" - id: check_artifact_exists uses: ./.github/actions/check_artifact_exists with: @@ -1074,9 +994,6 @@ jobs: name: "Mac|Build libstt+client" runs-on: macos-10.15 needs: [ build-tensorflow-macOS, tensorflow_opt-macOS ] - strategy: - matrix: - build-flavor: ["tf", "tflite"] steps: - uses: actions/checkout@v2 with: @@ -1094,17 +1011,19 @@ jobs: - uses: ./.github/actions/select-xcode with: version: "12.1.1" + - run: | + # Taken from https://www.tensorflow.org/install/source + # Only future is needed for our builds, as we don't build the Python package + python -m pip install -U --user future==0.17.1 || true - uses: ./.github/actions/host-build - with: - flavor: ${{ matrix.build-flavor }} - uses: ./.github/actions/package - uses: actions/upload-artifact@v2 with: - name: "native_client.${{ matrix.build-flavor }}.macOS.tar.xz" + name: "native_client.tflite.macOS.tar.xz" path: ${{ github.workspace }}/artifacts/native_client.tar.xz - uses: actions/upload-artifact@v2 with: - name: "libstt.${{ matrix.build-flavor }}.zip" + name: "libstt.tflite.zip" path: ${{ github.workspace }}/artifacts/libstt.zip build-python-macOS: name: "Mac|Build Python bindings" @@ -1112,7 +1031,6 @@ jobs: needs: [ build-lib_macOS, swig_macOS ] strategy: matrix: - build-flavor: ["tf", "tflite"] python-version: [3.6.8, 3.7.9, 3.8.9, 3.9.4] steps: - uses: actions/checkout@v2 @@ -1120,12 +1038,14 @@ jobs: fetch-depth: 1 - uses: actions/download-artifact@v2 with: - name: "native_client.${{ matrix.build-flavor }}.macOS.tar.xz" + name: "native_client.tflite.macOS.tar.xz" path: ${{ github.workspace }}/tensorflow/bazel-bin/native_client/ - run: | cd ${{ github.workspace }}/tensorflow/bazel-bin/native_client/ tar xf native_client.tar.xz - ls -hal + mkdir -p ../tensorflow/lite + mv libtensorflowlite.so ../tensorflow/lite/ + ls -hal . ../tensorflow/lite cd ${{ github.workspace }}/ - uses: actions/download-artifact@v2 with: @@ -1149,32 +1069,30 @@ jobs: pyver: ${{ matrix.python-version }} - uses: ./.github/actions/python-build with: - build_flavor: ${{ matrix.build-flavor }} numpy_build: "${{ steps.get_numpy.outputs.build_version }}" numpy_dep: "${{ steps.get_numpy.outputs.dep_version }}" - uses: actions/upload-artifact@v2 with: - name: "stt-${{ matrix.build-flavor }}-${{ matrix.python-version }}-macOS.whl" + name: "stt-tflite-${{ matrix.python-version }}-macOS.whl" path: ${{ github.workspace }}/wheels/*.whl build-nodejs-macOS: name: "Mac|Build NodeJS and ElectronJS" runs-on: macos-10.15 needs: [ build-lib_macOS, swig_macOS ] - strategy: - matrix: - build-flavor: ["tf", "tflite"] steps: - uses: actions/checkout@v2 with: fetch-depth: 1 - uses: actions/download-artifact@v2 with: - name: "native_client.${{ matrix.build-flavor }}.macOS.tar.xz" + name: "native_client.tflite.macOS.tar.xz" path: ${{ github.workspace }}/tensorflow/bazel-bin/native_client/ - run: | cd ${{ github.workspace }}/tensorflow/bazel-bin/native_client/ tar xf native_client.tar.xz - ls -hal + mkdir -p ../tensorflow/lite + mv libtensorflowlite.so ../tensorflow/lite/ + ls -hal . ../tensorflow/lite cd ${{ github.workspace }}/ - uses: actions/download-artifact@v2 with: @@ -1204,11 +1122,11 @@ jobs: electronjs_versions: "5.0.13 6.0.12 6.1.7 7.0.1 7.1.8 8.0.1 9.0.1 9.1.0 9.2.0 10.0.0 10.1.0 11.0.0 12.0.0" - uses: actions/upload-artifact@v2 with: - name: "nodewrapper-${{ matrix.build-flavor }}-macOS_amd64.tar.gz" + name: "nodewrapper-tflite-macOS_amd64.tar.gz" path: ${{ github.workspace }}/native_client/javascript/wrapper.tar.gz - uses: actions/upload-artifact@v2 with: - name: "stt_intermediate-${{ matrix.build-flavor }}-macOS.tgz" + name: "stt_intermediate-tflite-macOS.tgz" path: ${{ github.workspace }}/native_client/javascript/stt-*.tgz test-cpp-macOS: name: "Mac|Test C++ binary" @@ -1217,7 +1135,6 @@ jobs: if: ${{ github.event_name == 'pull_request' }} strategy: matrix: - build-flavor: ["tf", "tflite"] models: ["test", "prod"] bitrate: ["8k", "16k"] env: @@ -1232,14 +1149,14 @@ jobs: fetch-depth: 1 - uses: actions/download-artifact@v2 with: - name: "native_client.${{ matrix.build-flavor }}.macOS.tar.xz" + name: "native_client.tflite.macOS.tar.xz" path: ${{ env.CI_TMP_DIR }} - run: | cd ${{ env.CI_TMP_DIR }} mkdir ds && cd ds && tar xf ../native_client.tar.xz - uses: actions/download-artifact@v2 with: - name: "test-model.${{ matrix.build-flavor }}-${{ matrix.bitrate }}.zip" + name: "test-model.tflite-${{ matrix.bitrate }}.zip" path: ${{ env.CI_TMP_DIR }} if: matrix.models == 'test' - run: | @@ -1248,7 +1165,6 @@ jobs: - uses: ./.github/actions/run-tests with: runtime: "cpp" - build-flavor: ${{ matrix.build-flavor }} bitrate: ${{ matrix.bitrate }} model-kind: ${{ matrix.models }} test-py-macOS: @@ -1259,7 +1175,6 @@ jobs: strategy: matrix: python-version: [3.6.8, 3.7.9, 3.8.9, 3.9.4] - build-flavor: ["tf", "tflite"] models: ["test", "prod"] bitrate: ["8k", "16k"] env: @@ -1277,11 +1192,11 @@ jobs: python-version: ${{ matrix.python-version }} - uses: actions/download-artifact@v2 with: - name: "stt-${{ matrix.build-flavor }}-${{ matrix.python-version }}-macOS.whl" + name: "stt-tflite-${{ matrix.python-version }}-macOS.whl" path: ${{ env.CI_TMP_DIR }} - uses: actions/download-artifact@v2 with: - name: "test-model.${{ matrix.build-flavor }}-${{ matrix.bitrate }}.zip" + name: "test-model.tflite-${{ matrix.bitrate }}.zip" path: ${{ env.CI_TMP_DIR }} if: matrix.models == 'test' - run: | @@ -1293,7 +1208,6 @@ jobs: - uses: ./.github/actions/run-tests with: runtime: "python" - build-flavor: ${{ matrix.build-flavor }} bitrate: ${{ matrix.bitrate }} model-kind: ${{ matrix.models }} test-nodejs-macOS: @@ -1305,7 +1219,6 @@ jobs: matrix: # https://nodejs.org/en/about/releases/ nodejs-version: [10, 12, 14, 16] - build-flavor: ["tf", "tflite"] models: ["test"] bitrate: ["16k"] env: @@ -1323,11 +1236,11 @@ jobs: node-version: ${{ matrix.nodejs-version }} - uses: actions/download-artifact@v2 with: - name: "stt_intermediate-${{ matrix.build-flavor }}-macOS.tgz" + name: "stt_intermediate-tflite-macOS.tgz" path: ${{ env.CI_TMP_DIR }} - uses: actions/download-artifact@v2 with: - name: "test-model.${{ matrix.build-flavor }}-${{ matrix.bitrate }}.zip" + name: "test-model.tflite-${{ matrix.bitrate }}.zip" path: ${{ env.CI_TMP_DIR }} if: matrix.models == 'test' - run: | @@ -1337,7 +1250,7 @@ jobs: id: node-modules-cache with: path: ~/.npm/ - key: node-modules-${{ matrix.build-flavor }}-${{ runner.os }}-${{ env.CI_NODE_MODULES_NTH }} + key: node-modules-tflite-${{ runner.os }}-${{ env.CI_NODE_MODULES_NTH }} - name: Install STT package run: | ls -hal ${{ env.CI_TMP_DIR }}/ @@ -1347,7 +1260,6 @@ jobs: - uses: ./.github/actions/run-tests with: runtime: "node" - build-flavor: ${{ matrix.build-flavor }} bitrate: ${{ matrix.bitrate }} model-kind: ${{ matrix.models }} test-electronjs-macOS: @@ -1358,7 +1270,6 @@ jobs: strategy: matrix: electronjs-version: [5.0.13, 6.1.7, 7.1.8, 8.0.1, 9.2.0, 10.1.0, 11.0.0, 12.0.0] - build-flavor: ["tf", "tflite"] models: ["test"] bitrate: ["16k"] env: @@ -1376,11 +1287,11 @@ jobs: node-version: 12 - uses: actions/download-artifact@v2 with: - name: "stt_intermediate-${{ matrix.build-flavor }}-macOS.tgz" + name: "stt_intermediate-tflite-macOS.tgz" path: ${{ env.CI_TMP_DIR }} - uses: actions/download-artifact@v2 with: - name: "test-model.${{ matrix.build-flavor }}-${{ matrix.bitrate }}.zip" + name: "test-model.tflite-${{ matrix.bitrate }}.zip" path: ${{ env.CI_TMP_DIR }} if: matrix.models == 'test' - run: | @@ -1390,7 +1301,7 @@ jobs: id: electron-modules-cache with: path: ~/.npm/ - key: electron-modules-${{ matrix.build-flavor }}-${{ runner.os }}-${{ env.CI_NODE_MODULES_NTH }} + key: electron-modules-tflite-${{ runner.os }}-${{ env.CI_NODE_MODULES_NTH }} - name: Install STT package run: | ls -hal ${{ env.CI_TMP_DIR }}/ @@ -1400,7 +1311,6 @@ jobs: - uses: ./.github/actions/run-tests with: runtime: "electronjs" - build-flavor: ${{ matrix.build-flavor }} bitrate: ${{ matrix.bitrate }} model-kind: ${{ matrix.models }} timeout-minutes: 5 @@ -1466,7 +1376,7 @@ jobs: - id: get_cache_key uses: ./.github/actions/get_cache_key with: - extras: "7" + extras: "8" - id: check_artifact_exists uses: ./.github/actions/check_artifact_exists with: @@ -1522,9 +1432,6 @@ jobs: name: "Win|Build libstt+client" runs-on: windows-2019 needs: [build-tensorflow-Windows, tensorflow_opt-Windows] - strategy: - matrix: - build-flavor: ["tf", "tflite"] steps: - uses: actions/checkout@v2 with: @@ -1554,15 +1461,15 @@ jobs: rm ${{ needs.tensorflow_opt-Windows.outputs.cache_key }}.tar.xz - run: | git status - - run: ./ci_scripts/host-build.sh ${{ matrix.build-flavor }} + - run: ./ci_scripts/host-build.sh - run: ./ci_scripts/package.sh - uses: actions/upload-artifact@v2 with: - name: "native_client.${{ matrix.build-flavor }}.Windows.tar.xz" + name: "native_client.tflite.Windows.tar.xz" path: ${{ github.workspace }}/artifacts/native_client.tar.xz - uses: actions/upload-artifact@v2 with: - name: "libstt.${{ matrix.build-flavor }}.zip" + name: "libstt.tflite.zip" path: ${{ github.workspace }}/artifacts/libstt.zip build-python-Windows: name: "Win|Build Python bindings" @@ -1570,7 +1477,6 @@ jobs: needs: [build-lib_Windows, swig_Windows_crosscompiled] strategy: matrix: - build-flavor: ["tf", "tflite"] # Try to keep Python versions in sync with cached versions to speed things up: # https://github.com/actions/virtual-environments/blob/main/images/win/Windows2019-Readme.md python-version: [3.6.8, 3.7.9, 3.8.8, 3.9.4] @@ -1590,12 +1496,14 @@ jobs: fetch-depth: 1 - uses: actions/download-artifact@v2 with: - name: "native_client.${{ matrix.build-flavor }}.Windows.tar.xz" + name: "native_client.tflite.Windows.tar.xz" path: ${{ github.workspace }}/tensorflow/bazel-bin/native_client/ - run: | pushd tensorflow/bazel-bin/native_client/ "C:/Program Files/7-Zip/7z.exe" x native_client.tar.xz -so | "C:/Program Files/7-Zip/7z.exe" x -aoa -si -ttar -o`pwd` - ls -hal + mkdir -p ../tensorflow/lite + mv libtensorflowlite.so* ../tensorflow/lite/ + ls -hal . ../tensorflow/lite popd - uses: actions/download-artifact@v2 with: @@ -1619,20 +1527,16 @@ jobs: pyver: ${{ matrix.python-version }} - uses: ./.github/actions/python-build with: - build_flavor: ${{ matrix.build-flavor }} numpy_build: "${{ steps.get_numpy.outputs.build_version }}" numpy_dep: "${{ steps.get_numpy.outputs.dep_version }}" - uses: actions/upload-artifact@v2 with: - name: "stt-${{ matrix.build-flavor }}-${{ matrix.python-version }}-Windows.whl" + name: "stt-tflite-${{ matrix.python-version }}-Windows.whl" path: ${{ github.workspace }}/wheels/*.whl build-nodejs-Windows: name: "Win|Build NodeJS/ElectronJS" runs-on: windows-2019 needs: [build-lib_Windows, swig_Windows_crosscompiled] - strategy: - matrix: - build-flavor: ["tf", "tflite"] steps: - name: Switch git-bash shell to MSYS2 shell by adding MSYS2 path to PATH front run: echo "$MSYS2_SHELL_PATH" >> $GITHUB_PATH @@ -1650,12 +1554,14 @@ jobs: fetch-depth: 1 - uses: actions/download-artifact@v2 with: - name: "native_client.${{ matrix.build-flavor }}.Windows.tar.xz" + name: "native_client.tflite.Windows.tar.xz" path: ${{ github.workspace }}/tensorflow/bazel-bin/native_client/ - run: | pushd tensorflow/bazel-bin/native_client/ "C:/Program Files/7-Zip/7z.exe" x native_client.tar.xz -so | "C:/Program Files/7-Zip/7z.exe" x -aoa -si -ttar -o`pwd` - ls -hal + mkdir -p ../tensorflow/lite + mv libtensorflowlite.so* ../tensorflow/lite/ + ls -hal . ../tensorflow/lite popd - uses: actions/download-artifact@v2 with: @@ -1686,20 +1592,17 @@ jobs: electronjs_versions: "5.0.13 6.0.12 6.1.7 7.0.1 7.1.8 8.0.1 9.0.1 9.1.0 9.2.0 10.0.0 10.1.0 11.0.0 12.0.0" - uses: actions/upload-artifact@v2 with: - name: "nodewrapper-${{ matrix.build-flavor }}-Windows_amd64.tar.gz" + name: "nodewrapper-tflite-Windows_amd64.tar.gz" path: ${{ github.workspace }}/native_client/javascript/wrapper.tar.gz - uses: actions/upload-artifact@v2 with: - name: "STT_intermediate-${{ matrix.build-flavor }}-Windows.tgz" + name: "STT_intermediate-tflite-Windows.tgz" path: ${{ github.workspace }}/native_client/javascript/stt-*.tgz test-cpp-Windows: name: "Win|Test C++ binary" runs-on: windows-2019 needs: [build-lib_Windows, train-test-model-Linux] if: ${{ github.event_name == 'pull_request' }} - strategy: - matrix: - build-flavor: ["tf", "tflite"] env: CI_TMP_DIR: tmp/ STT_TEST_MODEL: tmp/output_graph.pb @@ -1719,7 +1622,7 @@ jobs: - name: Download native_client.tar.xz uses: actions/download-artifact@v2 with: - name: "native_client.${{ matrix.build-flavor }}.Windows.tar.xz" + name: "native_client.tflite.Windows.tar.xz" path: ${{ env.CI_TMP_DIR }} - name: Extract native_client.tar.xz run: | @@ -1731,14 +1634,13 @@ jobs: - name: Download trained test model uses: actions/download-artifact@v2 with: - name: "test-model.${{ matrix.build-flavor }}-16k.zip" + name: "test-model.tflite-16k.zip" path: ${{ env.CI_TMP_DIR }} - run: | ls -hal ${{ env.CI_TMP_DIR }}/ - uses: ./.github/actions/run-tests with: runtime: "cppwin" - build-flavor: ${{ matrix.build-flavor }} bitrate: "16k" model-kind: "" test-py-Windows: @@ -1751,7 +1653,6 @@ jobs: # Try to keep Python versions in sync with cached versions to speed things up: # https://github.com/actions/virtual-environments/blob/main/images/win/Windows2019-Readme.md python-version: [3.6.8, 3.7.9, 3.8.8, 3.9.4] - build-flavor: ["tf", "tflite"] models: ["test", "prod"] bitrate: ["8k", "16k"] env: @@ -1779,11 +1680,11 @@ jobs: - uses: ./.github/actions/win-install-sox - uses: actions/download-artifact@v2 with: - name: "stt-${{ matrix.build-flavor }}-${{ matrix.python-version }}-Windows.whl" + name: "stt-tflite-${{ matrix.python-version }}-Windows.whl" path: ${{ env.CI_TMP_DIR }} - uses: actions/download-artifact@v2 with: - name: "test-model.${{ matrix.build-flavor }}-${{ matrix.bitrate }}.zip" + name: "test-model.tflite-${{ matrix.bitrate }}.zip" path: ${{ env.CI_TMP_DIR }} if: matrix.models == 'test' - run: | @@ -1795,7 +1696,6 @@ jobs: - uses: ./.github/actions/run-tests with: runtime: "python" - build-flavor: ${{ matrix.build-flavor }} bitrate: ${{ matrix.bitrate }} model-kind: ${{ matrix.models }} test-nodejs-Windows: @@ -1806,7 +1706,6 @@ jobs: strategy: matrix: nodejs-version: [10, 12, 14, 16] - build-flavor: ["tf", "tflite"] models: ["test"] bitrate: ["16k"] env: @@ -1834,11 +1733,11 @@ jobs: - uses: ./.github/actions/win-install-sox - uses: actions/download-artifact@v2 with: - name: "STT_intermediate-${{ matrix.build-flavor }}-Windows.tgz" + name: "STT_intermediate-tflite-Windows.tgz" path: ${{ env.CI_TMP_DIR }} - uses: actions/download-artifact@v2 with: - name: "test-model.${{ matrix.build-flavor }}-${{ matrix.bitrate }}.zip" + name: "test-model.tflite-${{ matrix.bitrate }}.zip" path: ${{ env.CI_TMP_DIR }} if: matrix.models == 'test' - name: Get npm cache directory @@ -1849,7 +1748,7 @@ jobs: id: node-modules-cache with: path: ${{ steps.npm-cache-dir.outputs.dir }} - key: node-modules-${{ matrix.build-flavor }}-${{ runner.os }}-${{ env.CI_NODE_MODULES_NTH }} + key: node-modules-tflite-${{ runner.os }}-${{ env.CI_NODE_MODULES_NTH }} - run: | ls -hal ${{ env.CI_TMP_DIR }}/ if: matrix.models == 'test' @@ -1860,7 +1759,6 @@ jobs: - uses: ./.github/actions/run-tests with: runtime: "node" - build-flavor: ${{ matrix.build-flavor }} bitrate: ${{ matrix.bitrate }} model-kind: ${{ matrix.models }} test-electronjs-Windows: @@ -1871,7 +1769,6 @@ jobs: strategy: matrix: electronjs-version: [5.0.13, 6.1.7, 7.1.8, 8.0.1, 9.2.0, 10.1.0, 11.0.0, 12.0.0] - build-flavor: ["tf", "tflite"] models: ["test"] bitrate: ["16k"] env: @@ -1899,11 +1796,11 @@ jobs: - uses: ./.github/actions/win-install-sox - uses: actions/download-artifact@v2 with: - name: "STT_intermediate-${{ matrix.build-flavor }}-Windows.tgz" + name: "STT_intermediate-tflite-Windows.tgz" path: ${{ env.CI_TMP_DIR }} - uses: actions/download-artifact@v2 with: - name: "test-model.${{ matrix.build-flavor }}-${{ matrix.bitrate }}.zip" + name: "test-model.tflite-${{ matrix.bitrate }}.zip" path: ${{ env.CI_TMP_DIR }} if: matrix.models == 'test' - run: | @@ -1917,7 +1814,7 @@ jobs: id: electron-modules-cache with: path: ${{ steps.npm-cache-dir.outputs.dir }} - key: electron-modules-${{ matrix.build-flavor }}-${{ runner.os }}-${{ env.CI_NODE_MODULES_NTH }} + key: electron-modules-tflite-${{ runner.os }}-${{ env.CI_NODE_MODULES_NTH }} - name: Install STT package run: | ls -hal ${{ env.CI_TMP_DIR }}/ @@ -1927,7 +1824,6 @@ jobs: - uses: ./.github/actions/run-tests with: runtime: "electronjs" - build-flavor: ${{ matrix.build-flavor }} bitrate: ${{ matrix.bitrate }} model-kind: ${{ matrix.models }} timeout-minutes: 5 @@ -1936,57 +1832,45 @@ jobs: name: "Repackage NodeJS / ElectronJS for multiplatforms" runs-on: ubuntu-20.04 needs: [build-nodejs-macOS, build-nodejs-Windows, build-nodejs-Linux, build-nodejs-LinuxArmv7, build-nodejs-LinuxAarch64] - strategy: - matrix: - build-flavor: ["tf", "tflite"] steps: - uses: actions/checkout@v2 with: fetch-depth: 1 - run: | - mkdir -p /tmp/nodewrapper-${{ matrix.build-flavor }}-macOS_amd64/ - mkdir -p /tmp/nodewrapper-${{ matrix.build-flavor }}-Windows_amd64/ + mkdir -p /tmp/nodewrapper-tflite-macOS_amd64/ + mkdir -p /tmp/nodewrapper-tflite-Windows_amd64/ - uses: actions/download-artifact@v2 with: - name: "nodewrapper-${{ matrix.build-flavor }}-macOS_amd64.tar.gz" + name: "nodewrapper-tflite-macOS_amd64.tar.gz" path: /tmp/nodewrapper-macOS_amd64/ - uses: actions/download-artifact@v2 with: - name: "nodewrapper-${{ matrix.build-flavor }}-Windows_amd64.tar.gz" + name: "nodewrapper-tflite-Windows_amd64.tar.gz" path: /tmp/nodewrapper-Windows_amd64/ - uses: actions/download-artifact@v2 with: - name: "nodewrapper-${{ matrix.build-flavor }}-Linux_amd64.tar.gz" + name: "nodewrapper-tflite-Linux_amd64.tar.gz" path: /tmp/nodewrapper-Linux_amd64/ - uses: actions/download-artifact@v2 with: - name: "nodewrapper-${{ matrix.build-flavor }}-Linux_armv7.tar.gz" + name: "nodewrapper-tflite-Linux_armv7.tar.gz" path: /tmp/nodewrapper-Linux_armv7/ - if: matrix.build-flavor == 'tflite' - uses: actions/download-artifact@v2 with: - name: "nodewrapper-${{ matrix.build-flavor }}-Linux_aarch64.tar.gz" + name: "nodewrapper-tflite-Linux_aarch64.tar.gz" path: /tmp/nodewrapper-Linux_aarch64/ - if: matrix.build-flavor == 'tflite' - name: Extract nodewrapper archives run: | tar -C ${{ github.workspace }}/native_client/javascript -xzvf /tmp/nodewrapper-macOS_amd64/wrapper.tar.gz tar -C ${{ github.workspace }}/native_client/javascript -xzvf /tmp/nodewrapper-Windows_amd64/wrapper.tar.gz tar -C ${{ github.workspace }}/native_client/javascript -xzvf /tmp/nodewrapper-Linux_amd64/wrapper.tar.gz - - name: Extract nodewrapper tflite-only archives - run: | tar -C ${{ github.workspace }}/native_client/javascript -xzvf /tmp/nodewrapper-Linux_armv7/wrapper.tar.gz tar -C ${{ github.workspace }}/native_client/javascript -xzvf /tmp/nodewrapper-Linux_aarch64/wrapper.tar.gz - if: matrix.build-flavor == 'tflite' - run: | - PROJECT_NAME="stt" - if [ "${{ matrix.build-flavor }}" = "tflite" ]; then - PROJECT_NAME="stt-tflite" - fi - make -C native_client/javascript clean npm-pack PROJECT_NAME=$PROJECT_NAME + make -C native_client/javascript clean npm-pack PROJECT_NAME=stt - uses: actions/upload-artifact@v2 with: - name: "stt-${{ matrix.build-flavor }}.tgz" + name: "stt-tflite.tgz" path: ${{ github.workspace }}/native_client/javascript/stt-*.tgz test-nodejs_all-Linux: name: "Lin|Test MultiArchPlatform NodeJS bindings" @@ -1997,7 +1881,6 @@ jobs: matrix: # https://nodejs.org/en/about/releases/ nodejs-version: [10, 16] - build-flavor: ["tf", "tflite"] models: ["test", "prod"] bitrate: ["8k", "16k"] env: @@ -2017,18 +1900,18 @@ jobs: sudo apt-get install -y --no-install-recommends sox - uses: actions/download-artifact@v2 with: - name: "stt-${{ matrix.build-flavor }}.tgz" + name: "stt-tflite.tgz" path: ${{ env.CI_TMP_DIR }} - uses: actions/download-artifact@v2 with: - name: "test-model.${{ matrix.build-flavor }}-${{ matrix.bitrate }}.zip" + name: "test-model.tflite-${{ matrix.bitrate }}.zip" path: ${{ env.CI_TMP_DIR }} if: matrix.models == 'test' - uses: actions/cache@v2 id: node-modules-cache with: path: ~/.npm/ - key: node-modules-${{ matrix.build-flavor }}-${{ runner.os }}-${{ env.CI_NODE_MODULES_NTH }} + key: node-modules-tflite-${{ runner.os }}-${{ env.CI_NODE_MODULES_NTH }} - run: | ls -hal ${{ env.CI_TMP_DIR }}/ if: matrix.models == 'test' @@ -2041,7 +1924,6 @@ jobs: - uses: ./.github/actions/run-tests with: runtime: "node" - build-flavor: ${{ matrix.build-flavor }} bitrate: ${{ matrix.bitrate }} model-kind: ${{ matrix.models }} test-electronjs_all-Linux: @@ -2052,7 +1934,6 @@ jobs: strategy: matrix: electronjs-version: [5.0.13, 12.0.0] - build-flavor: ["tf", "tflite"] models: ["test", "prod"] bitrate: ["8k", "16k"] env: @@ -2072,11 +1953,11 @@ jobs: sudo apt-get install -y --no-install-recommends sox - uses: actions/download-artifact@v2 with: - name: "stt-${{ matrix.build-flavor }}.tgz" + name: "stt-tflite.tgz" path: ${{ env.CI_TMP_DIR }} - uses: actions/download-artifact@v2 with: - name: "test-model.${{ matrix.build-flavor }}-${{ matrix.bitrate }}.zip" + name: "test-model.tflite-${{ matrix.bitrate }}.zip" path: ${{ env.CI_TMP_DIR }} if: matrix.models == 'test' - run: | @@ -2086,7 +1967,7 @@ jobs: id: electron-modules-cache with: path: ~/.npm/ - key: electron-modules-${{ matrix.build-flavor }}-${{ runner.os }}-${{ env.CI_NODE_MODULES_NTH }} + key: electron-modules-tflite-${{ runner.os }}-${{ env.CI_NODE_MODULES_NTH }} - name: Install STT package run: | ls -hal ${{ env.CI_TMP_DIR }}/ @@ -2096,7 +1977,6 @@ jobs: - uses: ./.github/actions/run-tests with: runtime: "electronjs" - build-flavor: ${{ matrix.build-flavor }} bitrate: ${{ matrix.bitrate }} model-kind: ${{ matrix.models }} timeout-minutes: 5 @@ -2109,7 +1989,6 @@ jobs: matrix: # https://nodejs.org/en/about/releases/ nodejs-version: [10, 16] - build-flavor: ["tf", "tflite"] models: ["test", "prod"] bitrate: ["8k", "16k"] env: @@ -2127,18 +2006,18 @@ jobs: node-version: ${{ matrix.nodejs-version }} - uses: actions/download-artifact@v2 with: - name: "stt-${{ matrix.build-flavor }}.tgz" + name: "stt-tflite.tgz" path: ${{ env.CI_TMP_DIR }} - uses: actions/download-artifact@v2 with: - name: "test-model.${{ matrix.build-flavor }}-${{ matrix.bitrate }}.zip" + name: "test-model.tflite-${{ matrix.bitrate }}.zip" path: ${{ env.CI_TMP_DIR }} if: matrix.models == 'test' - uses: actions/cache@v2 id: node-modules-cache with: path: ~/.npm/ - key: node-modules-${{ matrix.build-flavor }}-${{ runner.os }}-${{ env.CI_NODE_MODULES_NTH }} + key: node-modules-tflite-${{ runner.os }}-${{ env.CI_NODE_MODULES_NTH }} - run: | ls -hal ${{ env.CI_TMP_DIR }}/ if: matrix.models == 'test' @@ -2151,7 +2030,6 @@ jobs: - uses: ./.github/actions/run-tests with: runtime: "node" - build-flavor: ${{ matrix.build-flavor }} bitrate: ${{ matrix.bitrate }} model-kind: ${{ matrix.models }} test-electronjs_all-macOS: @@ -2162,7 +2040,6 @@ jobs: strategy: matrix: electronjs-version: [5.0.13, 12.0.0] - build-flavor: ["tf", "tflite"] models: ["test", "prod"] bitrate: ["8k", "16k"] env: @@ -2180,11 +2057,11 @@ jobs: node-version: 12 - uses: actions/download-artifact@v2 with: - name: "stt-${{ matrix.build-flavor }}.tgz" + name: "stt-tflite.tgz" path: ${{ env.CI_TMP_DIR }} - uses: actions/download-artifact@v2 with: - name: "test-model.${{ matrix.build-flavor }}-${{ matrix.bitrate }}.zip" + name: "test-model.tflite-${{ matrix.bitrate }}.zip" path: ${{ env.CI_TMP_DIR }} if: matrix.models == 'test' - run: | @@ -2194,7 +2071,7 @@ jobs: id: electron-modules-cache with: path: ~/.npm/ - key: electron-modules-${{ matrix.build-flavor }}-${{ runner.os }}-${{ env.CI_NODE_MODULES_NTH }} + key: electron-modules-tflite-${{ runner.os }}-${{ env.CI_NODE_MODULES_NTH }} - name: Install STT package run: | ls -hal ${{ env.CI_TMP_DIR }}/ @@ -2204,7 +2081,6 @@ jobs: - uses: ./.github/actions/run-tests with: runtime: "electronjs" - build-flavor: ${{ matrix.build-flavor }} bitrate: ${{ matrix.bitrate }} model-kind: ${{ matrix.models }} timeout-minutes: 5 @@ -2217,7 +2093,6 @@ jobs: matrix: # https://nodejs.org/en/about/releases/ nodejs-version: [10, 16] - build-flavor: ["tf", "tflite"] models: ["test", "prod"] bitrate: ["8k", "16k"] env: @@ -2245,11 +2120,11 @@ jobs: - uses: ./.github/actions/win-install-sox - uses: actions/download-artifact@v2 with: - name: "stt-${{ matrix.build-flavor }}.tgz" + name: "stt-tflite.tgz" path: ${{ env.CI_TMP_DIR }} - uses: actions/download-artifact@v2 with: - name: "test-model.${{ matrix.build-flavor }}-${{ matrix.bitrate }}.zip" + name: "test-model.tflite-${{ matrix.bitrate }}.zip" path: ${{ env.CI_TMP_DIR }} if: matrix.models == 'test' - name: Get npm cache directory @@ -2260,7 +2135,7 @@ jobs: id: node-modules-cache with: path: ${{ steps.npm-cache-dir.outputs.dir }} - key: node-modules-${{ matrix.build-flavor }}-${{ runner.os }}-${{ env.CI_NODE_MODULES_NTH }} + key: node-modules-tflite-${{ runner.os }}-${{ env.CI_NODE_MODULES_NTH }} - run: | ls -hal ${{ env.CI_TMP_DIR }}/ if: matrix.models == 'test' @@ -2271,7 +2146,6 @@ jobs: - uses: ./.github/actions/run-tests with: runtime: "node" - build-flavor: ${{ matrix.build-flavor }} bitrate: ${{ matrix.bitrate }} model-kind: ${{ matrix.models }} test-electronjs_all-Windows: @@ -2282,7 +2156,6 @@ jobs: strategy: matrix: electronjs-version: [5.0.13, 12.0.0] - build-flavor: ["tf", "tflite"] models: ["test", "prod"] bitrate: ["8k", "16k"] env: @@ -2310,11 +2183,11 @@ jobs: - uses: ./.github/actions/win-install-sox - uses: actions/download-artifact@v2 with: - name: "stt-${{ matrix.build-flavor }}.tgz" + name: "stt-tflite.tgz" path: ${{ env.CI_TMP_DIR }} - uses: actions/download-artifact@v2 with: - name: "test-model.${{ matrix.build-flavor }}-${{ matrix.bitrate }}.zip" + name: "test-model.tflite-${{ matrix.bitrate }}.zip" path: ${{ env.CI_TMP_DIR }} if: matrix.models == 'test' - run: | @@ -2328,7 +2201,7 @@ jobs: id: electron-modules-cache with: path: ${{ steps.npm-cache-dir.outputs.dir }} - key: electron-modules-${{ matrix.build-flavor }}-${{ runner.os }}-${{ env.CI_NODE_MODULES_NTH }} + key: electron-modules-tflite-${{ runner.os }}-${{ env.CI_NODE_MODULES_NTH }} - name: Install STT package run: | ls -hal ${{ env.CI_TMP_DIR }}/ @@ -2338,7 +2211,6 @@ jobs: - uses: ./.github/actions/run-tests with: runtime: "electronjs" - build-flavor: ${{ matrix.build-flavor }} bitrate: ${{ matrix.bitrate }} model-kind: ${{ matrix.models }} timeout-minutes: 5 @@ -2359,7 +2231,7 @@ jobs: - id: get_cache_key uses: ./.github/actions/get_cache_key with: - extras: "0" + extras: "1" - id: check_artifact_exists uses: ./.github/actions/check_artifact_exists with: @@ -2380,7 +2252,7 @@ jobs: - id: get_cache_key uses: ./.github/actions/get_cache_key with: - extras: "0" + extras: "1" - id: check_artifact_exists uses: ./.github/actions/check_artifact_exists with: @@ -2389,9 +2261,6 @@ jobs: name: "LinArmv7|Build TensorFlow (opt)" needs: tensorflow_opt-LinuxArmv7 runs-on: ubuntu-20.04 - strategy: - matrix: - arch: [ "armv7" ] steps: - run: true if: needs.tensorflow_opt-LinuxArmv7.outputs.status == 'found' @@ -2404,7 +2273,7 @@ jobs: if: needs.tensorflow_opt-LinuxArmv7.outputs.status == 'missing' - uses: ./.github/actions/build-tensorflow with: - flavor: "--linux-${{ matrix.arch }}" + flavor: "--linux-armv7" if: needs.tensorflow_opt-LinuxArmv7.outputs.status == 'missing' - uses: ./.github/actions/package-tensorflow if: needs.tensorflow_opt-LinuxArmv7.outputs.status == 'missing' @@ -2417,9 +2286,6 @@ jobs: name: "LinAarch64|Build TensorFlow (opt)" needs: tensorflow_opt-LinuxAarch64 runs-on: ubuntu-20.04 - strategy: - matrix: - arch: [ "aarch64" ] steps: - run: true if: needs.tensorflow_opt-LinuxAarch64.outputs.status == 'found' @@ -2432,7 +2298,7 @@ jobs: if: needs.tensorflow_opt-LinuxAarch64.outputs.status == 'missing' - uses: ./.github/actions/build-tensorflow with: - flavor: "--linux-${{ matrix.arch }}" + flavor: "--linux-aarch64" if: needs.tensorflow_opt-LinuxAarch64.outputs.status == 'missing' - uses: ./.github/actions/package-tensorflow if: needs.tensorflow_opt-LinuxAarch64.outputs.status == 'missing' @@ -2444,10 +2310,6 @@ jobs: build-lib_LinuxArmv7: name: "LinArmv7|Build libstt+client" runs-on: ubuntu-20.04 - strategy: - matrix: - build-flavor: ["tflite"] - arch: [ "armv7" ] needs: [ build-tensorflow-LinuxArmv7, tensorflow_opt-LinuxArmv7 ] env: SYSTEM_TARGET: rpi3 @@ -2462,34 +2324,29 @@ jobs: path: ${{ github.workspace }}/ download: true - run: | - tar -xf ${{ needs.tensorflow_opt-LinuxArmv7.outputs.cache_key }}.tar.xz --skip-old-files + tar --skip-old-files -xf ${{ needs.tensorflow_opt-linuxarmv7.outputs.cache_key }}.tar.xz rm ${{ needs.tensorflow_opt-LinuxArmv7.outputs.cache_key }}.tar.xz - run: | git status - name: "Install chroot" uses: ./.github/actions/multistrap with: - arch: ${{ matrix.arch }} + arch: armv7 - uses: ./.github/actions/host-build with: - arch: ${{ matrix.arch }} - flavor: ${{ matrix.build-flavor }} + arch: armv7 - uses: ./.github/actions/package - uses: actions/upload-artifact@v2 with: - name: "native_client.${{ matrix.build-flavor }}.linux.${{ matrix.arch }}.tar.xz" + name: "native_client.tflite.linux.armv7.tar.xz" path: ${{ github.workspace }}/artifacts/native_client.tar.xz - uses: actions/upload-artifact@v2 with: - name: "libstt.${{ matrix.build-flavor }}.linux.${{ matrix.arch }}.zip" + name: "libstt.tflite.linux.armv7.zip" path: ${{ github.workspace }}/artifacts/libstt.zip build-lib_LinuxAarch64: name: "LinAarch64|Build libstt+client" runs-on: ubuntu-20.04 - strategy: - matrix: - build-flavor: ["tflite"] - arch: [ "aarch64" ] needs: [ build-tensorflow-LinuxAarch64, tensorflow_opt-LinuxAarch64 ] env: SYSTEM_TARGET: rpi3-armv8 @@ -2504,26 +2361,25 @@ jobs: path: ${{ github.workspace }}/ download: true - run: | - tar -xf ${{ needs.tensorflow_opt-LinuxAarch64.outputs.cache_key }}.tar.xz --skip-old-files + tar --skip-old-files -xf ${{ needs.tensorflow_opt-linuxaarch64.outputs.cache_key }}.tar.xz rm ${{ needs.tensorflow_opt-LinuxAarch64.outputs.cache_key }}.tar.xz - run: | git status - name: "Install chroot" uses: ./.github/actions/multistrap with: - arch: ${{ matrix.arch }} + arch: aarch64 - uses: ./.github/actions/host-build with: - arch: ${{ matrix.arch }} - flavor: ${{ matrix.build-flavor }} + arch: aarch64 - uses: ./.github/actions/package - uses: actions/upload-artifact@v2 with: - name: "native_client.${{ matrix.build-flavor }}.linux.${{ matrix.arch }}.tar.xz" + name: "native_client.tflite.linux.aarch64.tar.xz" path: ${{ github.workspace }}/artifacts/native_client.tar.xz - uses: actions/upload-artifact@v2 with: - name: "libstt.${{ matrix.build-flavor }}.linux.${{ matrix.arch }}.zip" + name: "libstt.tflite.linux.aarch64.zip" path: ${{ github.workspace }}/artifacts/libstt.zip build-python-LinuxArmv7: name: "LinArmv7|Build python bindings" @@ -2531,9 +2387,7 @@ jobs: needs: [ build-lib_LinuxArmv7, swig_Linux, tensorflow_opt-LinuxArmv7 ] strategy: matrix: - build-flavor: ["tflite"] python-version: [3.7] - arch: [ "armv7" ] env: DEBIAN_FRONTEND: "noninteractive" SYSTEM_TARGET: rpi3 @@ -2544,12 +2398,14 @@ jobs: fetch-depth: 1 - uses: actions/download-artifact@v2 with: - name: "native_client.${{ matrix.build-flavor }}.linux.${{ matrix.arch }}.tar.xz" + name: "native_client.tflite.linux.armv7.tar.xz" path: ${{ github.workspace }}/tensorflow/bazel-bin/native_client/ - run: | cd ${{ github.workspace }}/tensorflow/bazel-bin/native_client/ tar xf native_client.tar.xz - ls -hal + mkdir -p ../tensorflow/lite + mv libtensorflowlite.so ../tensorflow/lite/ + ls -hal . ../tensorflow/lite cd ${{ github.workspace }}/ - uses: actions/download-artifact@v2 with: @@ -2566,7 +2422,7 @@ jobs: path: ${{ github.workspace }}/ download: true - run: | - tar -xf ${{ needs.tensorflow_opt-LinuxArmv7.outputs.cache_key }}.tar.xz --skip-old-files + tar --skip-old-files -xf ${{ needs.tensorflow_opt-linuxarmv7.outputs.cache_key }}.tar.xz rm ${{ needs.tensorflow_opt-LinuxArmv7.outputs.cache_key }}.tar.xz - uses: actions/setup-python@v2 with: @@ -2577,30 +2433,25 @@ jobs: - name: "Install chroot" uses: ./.github/actions/multistrap with: - arch: ${{ matrix.arch }} + arch: armv7 - id: get_numpy uses: ./.github/actions/numpy_vers with: pyver: ${{ matrix.python-version }} - uses: ./.github/actions/python-build with: - build_flavor: ${{ matrix.build-flavor }} numpy_build: "${{ steps.get_numpy.outputs.build_version }}" numpy_dep: "${{ steps.get_numpy.outputs.dep_version }}" target: ${{ env.SYSTEM_TARGET }} chroot: ${{ env.SYSTEM_RASPBIAN }} - uses: actions/upload-artifact@v2 with: - name: "stt-${{ matrix.build-flavor }}-${{ matrix.python-version }}-${{ matrix.arch }}.whl" + name: "stt-tflite-${{ matrix.python-version }}-armv7.whl" path: ${{ github.workspace }}/wheels/*.whl build-nodejs-LinuxArmv7: name: "LinArmv7|Build NodeJS and ElectronJS" runs-on: ubuntu-20.04 needs: [ build-lib_LinuxArmv7, swig_Linux, tensorflow_opt-LinuxArmv7 ] - strategy: - matrix: - build-flavor: ["tflite"] - arch: [ "armv7" ] env: SYSTEM_TARGET: rpi3 SYSTEM_RASPBIAN: ${{ github.workspace }}/multistrap-raspbian-buster @@ -2610,12 +2461,14 @@ jobs: fetch-depth: 1 - uses: actions/download-artifact@v2 with: - name: "native_client.${{ matrix.build-flavor }}.linux.${{ matrix.arch }}.tar.xz" + name: "native_client.tflite.linux.armv7.tar.xz" path: ${{ github.workspace }}/tensorflow/bazel-bin/native_client/ - run: | cd ${{ github.workspace }}/tensorflow/bazel-bin/native_client/ tar xf native_client.tar.xz - ls -hal + mkdir -p ../tensorflow/lite + mv libtensorflowlite.so ../tensorflow/lite/ + ls -hal . ../tensorflow/lite cd ${{ github.workspace }}/ - uses: actions/download-artifact@v2 with: @@ -2632,7 +2485,7 @@ jobs: path: ${{ github.workspace }}/ download: true - run: | - tar -xf ${{ needs.tensorflow_opt-LinuxArmv7.outputs.cache_key }}.tar.xz --skip-old-files + tar --skip-old-files -xf ${{ needs.tensorflow_opt-linuxarmv7.outputs.cache_key }}.tar.xz rm ${{ needs.tensorflow_opt-LinuxArmv7.outputs.cache_key }}.tar.xz - uses: ./.github/actions/install-xldd with: @@ -2640,7 +2493,7 @@ jobs: - name: "Install chroot" uses: ./.github/actions/multistrap with: - arch: ${{ matrix.arch }} + arch: armv7 - uses: actions/setup-node@v2 with: node-version: 12 @@ -2662,11 +2515,11 @@ jobs: chroot: ${{ env.SYSTEM_RASPBIAN }} - uses: actions/upload-artifact@v2 with: - name: "nodewrapper-${{ matrix.build-flavor }}-Linux_${{ matrix.arch }}.tar.gz" + name: "nodewrapper-tflite-Linux_armv7.tar.gz" path: ${{ github.workspace }}/native_client/javascript/wrapper.tar.gz - uses: actions/upload-artifact@v2 with: - name: "stt_intermediate-${{ matrix.build-flavor }}-${{ matrix.arch }}.tgz" + name: "stt_intermediate-tflite-armv7.tgz" path: ${{ github.workspace }}/native_client/javascript/stt-*.tgz build-python-LinuxAarch64: name: "LinAarch64|Build python bindings" @@ -2674,9 +2527,7 @@ jobs: needs: [ build-lib_LinuxAarch64, swig_Linux, tensorflow_opt-LinuxAarch64 ] strategy: matrix: - build-flavor: ["tflite"] python-version: [3.7] - arch: [ "aarch64" ] env: DEBIAN_FRONTEND: "noninteractive" SYSTEM_TARGET: rpi3-armv8 @@ -2689,12 +2540,14 @@ jobs: fetch-depth: 1 - uses: actions/download-artifact@v2 with: - name: "native_client.${{ matrix.build-flavor }}.linux.${{ matrix.arch }}.tar.xz" + name: "native_client.tflite.linux.aarch64.tar.xz" path: ${{ github.workspace }}/tensorflow/bazel-bin/native_client/ - run: | cd ${{ github.workspace }}/tensorflow/bazel-bin/native_client/ tar xf native_client.tar.xz - ls -hal + mkdir -p ../tensorflow/lite + mv libtensorflowlite.so ../tensorflow/lite/ + ls -hal . ../tensorflow/lite cd ${{ github.workspace }}/ - uses: actions/download-artifact@v2 with: @@ -2711,7 +2564,7 @@ jobs: path: ${{ github.workspace }}/ download: true - run: | - tar -xf ${{ needs.tensorflow_opt-LinuxAarch64.outputs.cache_key }}.tar.xz --skip-old-files + tar --skip-old-files -xf ${{ needs.tensorflow_opt-linuxaarch64.outputs.cache_key }}.tar.xz rm ${{ needs.tensorflow_opt-LinuxAarch64.outputs.cache_key }}.tar.xz - uses: actions/setup-python@v2 with: @@ -2722,30 +2575,25 @@ jobs: - name: "Install chroot" uses: ./.github/actions/multistrap with: - arch: ${{ matrix.arch }} + arch: aarch64 - id: get_numpy uses: ./.github/actions/numpy_vers with: pyver: ${{ matrix.python-version }} - uses: ./.github/actions/python-build with: - build_flavor: ${{ matrix.build-flavor }} numpy_build: "${{ steps.get_numpy.outputs.build_version }}" numpy_dep: "${{ steps.get_numpy.outputs.dep_version }}" target: ${{ env.SYSTEM_TARGET }} chroot: ${{ env.SYSTEM_RASPBIAN }} - uses: actions/upload-artifact@v2 with: - name: "stt-${{ matrix.build-flavor }}-${{ matrix.python-version }}-${{ matrix.arch }}.whl" + name: "stt-tflite-${{ matrix.python-version }}-aarch64.whl" path: ${{ github.workspace }}/wheels/*.whl build-nodejs-LinuxAarch64: name: "LinAarch64|Build NodeJS and ElectronJS" runs-on: ubuntu-20.04 needs: [ build-lib_LinuxAarch64, swig_Linux, tensorflow_opt-LinuxAarch64 ] - strategy: - matrix: - build-flavor: ["tflite"] - arch: [ "aarch64" ] env: SYSTEM_TARGET: rpi3-armv8 SYSTEM_RASPBIAN: ${{ github.workspace }}/multistrap-armbian64-buster @@ -2755,12 +2603,14 @@ jobs: fetch-depth: 1 - uses: actions/download-artifact@v2 with: - name: "native_client.${{ matrix.build-flavor }}.linux.${{ matrix.arch }}.tar.xz" + name: "native_client.tflite.linux.aarch64.tar.xz" path: ${{ github.workspace }}/tensorflow/bazel-bin/native_client/ - run: | cd ${{ github.workspace }}/tensorflow/bazel-bin/native_client/ tar xf native_client.tar.xz - ls -hal + mkdir -p ../tensorflow/lite + mv libtensorflowlite.so ../tensorflow/lite/ + ls -hal . ../tensorflow/lite cd ${{ github.workspace }}/ - uses: actions/download-artifact@v2 with: @@ -2777,7 +2627,7 @@ jobs: path: ${{ github.workspace }}/ download: true - run: | - tar -xf ${{ needs.tensorflow_opt-LinuxAarch64.outputs.cache_key }}.tar.xz --skip-old-files + tar --skip-old-files -xf ${{ needs.tensorflow_opt-linuxaarch64.outputs.cache_key }}.tar.xz rm ${{ needs.tensorflow_opt-LinuxAarch64.outputs.cache_key }}.tar.xz - uses: ./.github/actions/install-xldd with: @@ -2785,7 +2635,7 @@ jobs: - name: "Install chroot" uses: ./.github/actions/multistrap with: - arch: ${{ matrix.arch }} + arch: aarch64 - uses: actions/setup-node@v2 with: node-version: 12 @@ -2807,11 +2657,11 @@ jobs: chroot: ${{ env.SYSTEM_RASPBIAN }} - uses: actions/upload-artifact@v2 with: - name: "nodewrapper-${{ matrix.build-flavor }}-Linux_${{ matrix.arch }}.tar.gz" + name: "nodewrapper-tflite-Linux_aarch64.tar.gz" path: ${{ github.workspace }}/native_client/javascript/wrapper.tar.gz - uses: actions/upload-artifact@v2 with: - name: "stt_intermediate-${{ matrix.build-flavor }}-${{ matrix.arch }}.tgz" + name: "stt_intermediate-tflite-aarch64.tgz" path: ${{ github.workspace }}/native_client/javascript/stt-*.tgz build-test-chroot: name: "Lin|Build test chroot" @@ -2848,7 +2698,6 @@ jobs: strategy: matrix: arch: [ "armv7", "aarch64" ] - build-flavor: ["tflite"] models: ["test", "prod"] bitrate: ["8k", "16k"] env: @@ -2877,14 +2726,14 @@ jobs: rm ${{ env.CI_TMP_DIR }}/chroot.tar.xz - uses: actions/download-artifact@v2 with: - name: "native_client.${{ matrix.build-flavor }}.linux.${{ matrix.arch }}.tar.xz" + name: "native_client.tflite.linux.${{ matrix.arch }}.tar.xz" path: ${{ env.CI_TMP_DIR }}/ - run: | cd ${{ env.CI_TMP_DIR }}/ mkdir ds && cd ds && tar xf ../native_client.tar.xz - uses: actions/download-artifact@v2 with: - name: "test-model.${{ matrix.build-flavor }}-${{ matrix.bitrate }}.zip" + name: "test-model.tflite-${{ matrix.bitrate }}.zip" path: ${{ env.CI_TMP_DIR }}/ if: matrix.models == 'test' - run: | @@ -2900,7 +2749,6 @@ jobs: with: runtime: "cpp" chroot: "sudo --preserve-env chroot --userspec=runner:docker ${{ env.SYSTEM_RASPBIAN }}/ ${{ github.workspace }}" - build-flavor: ${{ matrix.build-flavor }} bitrate: ${{ matrix.bitrate }} model-kind: ${{ matrix.models }} test-py-LinuxArm: @@ -2912,7 +2760,6 @@ jobs: matrix: arch: [ "armv7", "aarch64" ] python-version: [3.7] - build-flavor: ["tflite"] models: ["test", "prod"] bitrate: ["8k", "16k"] env: @@ -2942,11 +2789,11 @@ jobs: rm ${{ env.CI_TMP_DIR }}/chroot.tar.xz - uses: actions/download-artifact@v2 with: - name: "stt-${{ matrix.build-flavor }}-${{ matrix.python-version }}-${{ matrix.arch }}.whl" + name: "stt-tflite-${{ matrix.python-version }}-${{ matrix.arch }}.whl" path: ${{ env.CI_TMP_DIR }}/ - uses: actions/download-artifact@v2 with: - name: "test-model.${{ matrix.build-flavor }}-${{ matrix.bitrate }}.zip" + name: "test-model.tflite-${{ matrix.bitrate }}.zip" path: ${{ env.CI_TMP_DIR }}/ if: matrix.models == 'test' - run: | @@ -2964,7 +2811,6 @@ jobs: with: runtime: "python" chroot: "sudo --preserve-env chroot --userspec=runner:docker ${{ env.SYSTEM_RASPBIAN }}/ ${{ github.workspace }}" - build-flavor: ${{ matrix.build-flavor }} bitrate: ${{ matrix.bitrate }} model-kind: ${{ matrix.models }} test-nodejs-LinuxArm: @@ -2977,7 +2823,6 @@ jobs: arch: [ "armv7", "aarch64" ] # https://nodejs.org/en/about/releases/ nodejs-version: [10, 12, 14, 16] - build-flavor: ["tflite"] models: ["test"] bitrate: ["16k"] env: @@ -3010,11 +2855,11 @@ jobs: node: ${{ matrix.nodejs-version }} - uses: actions/download-artifact@v2 with: - name: "stt_intermediate-${{ matrix.build-flavor }}-${{ matrix.arch }}.tgz" + name: "stt_intermediate-tflite-${{ matrix.arch }}.tgz" path: ${{ env.CI_TMP_DIR }}/ - uses: actions/download-artifact@v2 with: - name: "test-model.${{ matrix.build-flavor }}-${{ matrix.bitrate }}.zip" + name: "test-model.tflite-${{ matrix.bitrate }}.zip" path: ${{ env.CI_TMP_DIR }}/ if: matrix.models == 'test' - run: | @@ -3030,7 +2875,6 @@ jobs: with: runtime: "node" chroot: "sudo --preserve-env chroot --userspec=runner:docker ${{ env.SYSTEM_RASPBIAN }}/ ${{ github.workspace }}" - build-flavor: ${{ matrix.build-flavor }} bitrate: ${{ matrix.bitrate }} model-kind: ${{ matrix.models }} test-electronjs-LinuxArm: @@ -3043,7 +2887,6 @@ jobs: matrix: arch: [ "armv7", "aarch64" ] electronjs-version: [5.0.13, 6.1.7, 7.1.8, 8.0.1, 9.2.0, 10.1.0, 11.0.0, 12.0.0] - build-flavor: ["tflite"] models: ["test"] bitrate: ["16k"] env: @@ -3077,11 +2920,11 @@ jobs: node: 12 - uses: actions/download-artifact@v2 with: - name: "stt_intermediate-${{ matrix.build-flavor }}-${{ matrix.arch }}.tgz" + name: "stt_intermediate-tflite-${{ matrix.arch }}.tgz" path: ${{ env.CI_TMP_DIR }}/ - uses: actions/download-artifact@v2 with: - name: "test-model.${{ matrix.build-flavor }}-${{ matrix.bitrate }}.zip" + name: "test-model.tflite-${{ matrix.bitrate }}.zip" path: ${{ env.CI_TMP_DIR }}/ if: matrix.models == 'test' - run: | @@ -3109,7 +2952,6 @@ jobs: with: runtime: "electronjs" chroot: "sudo --preserve-env chroot --userspec=runner:docker ${{ env.SYSTEM_RASPBIAN }}/ ${{ github.workspace }}" - build-flavor: ${{ matrix.build-flavor }} bitrate: ${{ matrix.bitrate }} model-kind: ${{ matrix.models }} timeout-minutes: 5 diff --git a/ci_scripts/all-utils.sh b/ci_scripts/all-utils.sh index 94807a0e..7860d978 100755 --- a/ci_scripts/all-utils.sh +++ b/ci_scripts/all-utils.sh @@ -55,23 +55,6 @@ maybe_install_xldd() fi } -# Checks whether we run a patched version of bazel. -# Patching is required to dump computeKey() parameters to .ckd files -# See bazel.patch -# Return 0 (success exit code) on patched version, 1 on release version -is_patched_bazel() -{ - bazel_version=$(bazel version | grep 'Build label:' | cut -d':' -f2) - - bazel shutdown - - if [ -z "${bazel_version}" ]; then - return 0; - else - return 1; - fi; -} - verify_bazel_rebuild() { bazel_explain_file="$1" diff --git a/ci_scripts/build-utils.sh b/ci_scripts/build-utils.sh index 32974eb3..df57e8bc 100755 --- a/ci_scripts/build-utils.sh +++ b/ci_scripts/build-utils.sh @@ -9,21 +9,15 @@ do_bazel_build() cd ${DS_TFDIR} eval "export ${BAZEL_ENV_FLAGS}" - if [ "${_opt_or_dbg}" = "opt" ]; then - if is_patched_bazel; then - find ${DS_ROOT_TASK}/tensorflow/bazel-out/ -iname "*.ckd" | tar -cf ${DS_ROOT_TASK}/bazel-ckd-tf.tar -T - - fi; - fi; - bazel ${BAZEL_OUTPUT_USER_ROOT} build \ - -s --explain bazel_monolithic.log --verbose_explanations --experimental_strict_action_env --workspace_status_command="bash native_client/bazel_workspace_status_cmd.sh" --config=monolithic -c ${_opt_or_dbg} ${BAZEL_BUILD_FLAGS} ${BAZEL_TARGETS} + -s --explain bazel_explain.log --verbose_explanations \ + --experimental_strict_action_env \ + --workspace_status_command="bash native_client/bazel_workspace_status_cmd.sh" \ + -c ${_opt_or_dbg} ${BAZEL_BUILD_FLAGS} ${BAZEL_TARGETS} if [ "${_opt_or_dbg}" = "opt" ]; then - if is_patched_bazel; then - find ${DS_ROOT_TASK}/tensorflow/bazel-out/ -iname "*.ckd" | tar -cf ${DS_ROOT_TASK}/bazel-ckd-ds.tar -T - - fi; - verify_bazel_rebuild "${DS_ROOT_TASK}/tensorflow/bazel_monolithic.log" - fi; + verify_bazel_rebuild "${DS_ROOT_TASK}/tensorflow/bazel_explain.log" + fi } shutdown_bazel() diff --git a/ci_scripts/cpp-tests-prod.sh b/ci_scripts/cpp-tests-prod.sh deleted file mode 100755 index 79c1d994..00000000 --- a/ci_scripts/cpp-tests-prod.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/bash - -set -xe - -source $(dirname "$0")/all-vars.sh -source $(dirname "$0")/all-utils.sh -source $(dirname "$0")/asserts.sh - -bitrate=$1 -set_ldc_sample_filename "${bitrate}" - -model_source=${STT_PROD_MODEL} -model_name=$(basename "${model_source}") - -model_source_mmap=${STT_PROD_MODEL_MMAP} -model_name_mmap=$(basename "${model_source_mmap}") - -download_model_prod - -download_material - -export PATH=${CI_TMP_DIR}/ds/:$PATH - -check_versions - -run_prod_inference_tests "${bitrate}" diff --git a/ci_scripts/cpp-tests.sh b/ci_scripts/cpp-tests.sh deleted file mode 100755 index 460fc36d..00000000 --- a/ci_scripts/cpp-tests.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/bash - -set -xe - -source $(dirname "$0")/all-vars.sh -source $(dirname "$0")/all-utils.sh -source $(dirname "$0")/asserts.sh - -bitrate=$1 -set_ldc_sample_filename "${bitrate}" - -download_data - -export PATH=${CI_TMP_DIR}/ds/:$PATH - -check_versions - -run_all_inference_tests - -run_multi_inference_tests - -run_cpp_only_inference_tests - -run_hotword_tests diff --git a/ci_scripts/cppwin-tests.sh b/ci_scripts/cppwin-tests.sh deleted file mode 100755 index 81acf862..00000000 --- a/ci_scripts/cppwin-tests.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/bash - -set -xe - -source $(dirname "$0")/all-vars.sh -source $(dirname "$0")/all-utils.sh -source $(dirname "$0")/asserts.sh - -bitrate=$1 -set_ldc_sample_filename "${bitrate}" - -download_material "${CI_TMP_DIR}/ds" - -export PATH=${CI_TMP_DIR}/ds/:$PATH - -check_versions - -ensure_cuda_usage "$2" - -run_basic_inference_tests diff --git a/ci_scripts/electronjs-tests-prod.sh b/ci_scripts/electronjs-tests-prod.sh deleted file mode 100755 index 43c789a3..00000000 --- a/ci_scripts/electronjs-tests-prod.sh +++ /dev/null @@ -1,48 +0,0 @@ -#!/bin/bash - -set -xe - -source $(dirname "$0")/all-vars.sh -source $(dirname "$0")/all-utils.sh -source $(dirname "$0")/asserts.sh - -bitrate=$1 -set_ldc_sample_filename "${bitrate}" - -model_source=${STT_PROD_MODEL} -model_name=$(basename "${model_source}") -model_source_mmap=${STT_PROD_MODEL_MMAP} -model_name_mmap=$(basename "${model_source_mmap}") - -download_model_prod - -download_data - -node --version -npm --version - -symlink_electron - -export_node_bin_path - -which electron -which node - -if [ "${OS}" = "Linux" ]; then - export DISPLAY=':99.0' - sudo Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 & - xvfb_process=$! -fi - -node --version - -stt --version - -check_runtime_electronjs - -run_electronjs_prod_inference_tests "${bitrate}" - -if [ "${OS}" = "Linux" ]; then - sleep 1 - sudo kill -9 ${xvfb_process} || true -fi diff --git a/ci_scripts/electronjs-tests.sh b/ci_scripts/electronjs-tests.sh deleted file mode 100755 index 368d4483..00000000 --- a/ci_scripts/electronjs-tests.sh +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/bash - -set -xe - -source $(dirname "$0")/all-vars.sh -source $(dirname "$0")/all-utils.sh -source $(dirname "$0")/asserts.sh - -bitrate=$1 -set_ldc_sample_filename "${bitrate}" - -download_data - -node --version -npm --version - -symlink_electron - -export_node_bin_path - -which electron -which node - -if [ "${OS}" = "Linux" ]; then - export DISPLAY=':99.0' - sudo Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 & - xvfb_process=$! -fi - -node --version - -stt --version - -check_runtime_electronjs - -run_electronjs_inference_tests - -if [ "${OS}" = "Linux" ]; then - sleep 1 - sudo kill -9 ${xvfb_process} || true -fi diff --git a/ci_scripts/host-build.sh b/ci_scripts/host-build.sh index 36afa054..ab0970c8 100755 --- a/ci_scripts/host-build.sh +++ b/ci_scripts/host-build.sh @@ -2,8 +2,6 @@ set -xe -runtime=$1 - source $(dirname "$0")/all-vars.sh source $(dirname "$0")/all-utils.sh source $(dirname "$0")/build-utils.sh @@ -15,10 +13,7 @@ BAZEL_TARGETS=" //native_client:generate_scorer_package " -if [ "${runtime}" = "tflite" ]; then - BAZEL_BUILD_TFLITE="--define=runtime=tflite" -fi; -BAZEL_BUILD_FLAGS="${BAZEL_BUILD_TFLITE} ${BAZEL_OPT_FLAGS} ${BAZEL_EXTRA_FLAGS}" +BAZEL_BUILD_FLAGS="${BAZEL_OPT_FLAGS} ${BAZEL_EXTRA_FLAGS}" BAZEL_ENV_FLAGS="TF_NEED_CUDA=0" SYSTEM_TARGET=host diff --git a/ci_scripts/node-tests-prod.sh b/ci_scripts/node-tests-prod.sh deleted file mode 100755 index 7f0580b2..00000000 --- a/ci_scripts/node-tests-prod.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/bin/bash - -set -xe - -source $(dirname "$0")/all-vars.sh -source $(dirname "$0")/all-utils.sh -source $(dirname "$0")/asserts.sh - -bitrate=$1 -set_ldc_sample_filename "${bitrate}" - -model_source=${STT_PROD_MODEL} -model_name=$(basename "${model_source}") -model_source_mmap=${STT_PROD_MODEL_MMAP} -model_name_mmap=$(basename "${model_source_mmap}") - -download_model_prod - -download_data - -node --version -npm --version - -export_node_bin_path - -check_runtime_nodejs - -run_prod_inference_tests "${bitrate}" - -run_js_streaming_prod_inference_tests "${bitrate}" diff --git a/ci_scripts/node-tests.sh b/ci_scripts/node-tests.sh deleted file mode 100755 index cd386db0..00000000 --- a/ci_scripts/node-tests.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/bash - -set -xe - -source $(dirname "$0")/all-vars.sh -source $(dirname "$0")/all-utils.sh -source $(dirname "$0")/asserts.sh - -bitrate=$1 -set_ldc_sample_filename "${bitrate}" - -download_data - -node --version -npm --version - -export_node_bin_path - -check_runtime_nodejs - -run_all_inference_tests - -run_js_streaming_inference_tests - -run_hotword_tests diff --git a/ci_scripts/package-utils.sh b/ci_scripts/package-utils.sh index 9fdef33d..c59e6f8c 100755 --- a/ci_scripts/package-utils.sh +++ b/ci_scripts/package-utils.sh @@ -30,10 +30,15 @@ package_native_client() win_lib="$win_lib -C ${tensorflow_dir}/bazel-bin/native_client/ libkenlm.so.if.lib" fi; + if [ -f "${tensorflow_dir}/bazel-bin/tensorflow/lite/libtensorflowlite.so.if.lib" ]; then + win_lib="$win_lib -C ${tensorflow_dir}/bazel-bin/tensorflow/lite/ libtensorflowlite.so.if.lib" + fi; + ${TAR} --verbose -cf - \ --transform='flags=r;s|README.coqui|KenLM_License_Info.txt|' \ -C ${tensorflow_dir}/bazel-bin/native_client/ libstt.so \ -C ${tensorflow_dir}/bazel-bin/native_client/ libkenlm.so \ + -C ${tensorflow_dir}/bazel-bin/tensorflow/lite/ libtensorflowlite.so \ ${win_lib} \ -C ${tensorflow_dir}/bazel-bin/native_client/ generate_scorer_package \ -C ${stt_dir}/ LICENSE \ @@ -94,5 +99,8 @@ package_libstt_as_zip() echo "Please specify artifact name." fi; - ${ZIP} -r9 --junk-paths "${artifacts_dir}/${artifact_name}" ${tensorflow_dir}/bazel-bin/native_client/libstt.so + ${ZIP} -r9 --junk-paths "${artifacts_dir}/${artifact_name}" \ + ${tensorflow_dir}/bazel-bin/native_client/libstt.so \ + ${tensorflow_dir}/bazel-bin/native_client/libkenlm.so \ + ${tensorflow_dir}/bazel-bin/tensorflow/lite/libtensorflowlite.so } diff --git a/ci_scripts/python-tests-prod.sh b/ci_scripts/python-tests-prod.sh deleted file mode 100755 index e1528f29..00000000 --- a/ci_scripts/python-tests-prod.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/bash - -set -xe - -source $(dirname "$0")/all-vars.sh -source $(dirname "$0")/all-utils.sh -source $(dirname "$0")/asserts.sh - -bitrate=$1 -set_ldc_sample_filename "${bitrate}" - -model_source=${STT_PROD_MODEL} -model_name=$(basename "${model_source}") - -model_source_mmap=${STT_PROD_MODEL_MMAP} -model_name_mmap=$(basename "${model_source_mmap}") - -download_model_prod - -download_material - -export_py_bin_path - -which stt -stt --version - -run_prod_inference_tests "${bitrate}" - -run_prod_concurrent_stream_tests "${bitrate}" diff --git a/ci_scripts/python-tests.sh b/ci_scripts/python-tests.sh deleted file mode 100755 index 1df9dc17..00000000 --- a/ci_scripts/python-tests.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash - -set -xe - -source $(dirname "$0")/all-vars.sh -source $(dirname "$0")/all-utils.sh -source $(dirname "$0")/asserts.sh - -bitrate=$1 -set_ldc_sample_filename "${bitrate}" - -download_data - -export_py_bin_path - -which stt -stt --version - -run_all_inference_tests - -run_hotword_tests diff --git a/ci_scripts/tf-build.sh b/ci_scripts/tf-build.sh index 943acb9d..0f5aba63 100755 --- a/ci_scripts/tf-build.sh +++ b/ci_scripts/tf-build.sh @@ -6,7 +6,7 @@ set -o pipefail source $(dirname $0)/tf-vars.sh pushd ${DS_ROOT_TASK}/tensorflow/ - BAZEL_BUILD="bazel ${BAZEL_OUTPUT_USER_ROOT} build -s --explain bazel_monolithic_tf.log --verbose_explanations --experimental_strict_action_env --config=monolithic" + BAZEL_BUILD="bazel ${BAZEL_OUTPUT_USER_ROOT} build -s" # Start a bazel process to ensure reliability on Windows and avoid: # FATAL: corrupt installation: file 'c:\builds\tc-workdir\.bazel_cache/install/6b1660721930e9d5f231f7d2a626209b/_embedded_binaries/build-runfiles.exe' missing. @@ -18,18 +18,15 @@ pushd ${DS_ROOT_TASK}/tensorflow/ MAYBE_DEBUG=$2 OPT_OR_DBG="-c opt" if [ "${MAYBE_DEBUG}" = "dbg" ]; then - OPT_OR_DBG="-c dbg" + OPT_OR_DBG="-c dbg" fi; case "$1" in "--windows-cpu") - echo "" | TF_NEED_CUDA=0 ./configure && ${BAZEL_BUILD} ${OPT_OR_DBG} ${BAZEL_OPT_FLAGS} ${BAZEL_EXTRA_FLAGS} ${BUILD_TARGET_LIBSTT} ${BUILD_TARGET_LITE_LIB} --workspace_status_command="bash native_client/bazel_workspace_status_cmd.sh" + echo "" | TF_NEED_CUDA=0 ./configure && ${BAZEL_BUILD} ${OPT_OR_DBG} ${BAZEL_OPT_FLAGS} ${BAZEL_EXTRA_FLAGS} ${BUILD_TARGET_LITE_LIB} ;; "--linux-cpu"|"--darwin-cpu") - echo "" | TF_NEED_CUDA=0 ./configure && ${BAZEL_BUILD} ${OPT_OR_DBG} ${BAZEL_OPT_FLAGS} ${BAZEL_EXTRA_FLAGS} ${BUILD_TARGET_LIB_CPP_API} ${BUILD_TARGET_LITE_LIB} - ;; - "--linux-cuda"|"--windows-cuda") - eval "export ${TF_CUDA_FLAGS}" && (echo "" | TF_NEED_CUDA=1 ./configure) && ${BAZEL_BUILD} ${OPT_OR_DBG} ${BAZEL_CUDA_FLAGS} ${BAZEL_EXTRA_FLAGS} ${BAZEL_OPT_FLAGS} ${BUILD_TARGET_LIB_CPP_API} + echo "" | TF_NEED_CUDA=0 ./configure && ${BAZEL_BUILD} ${OPT_OR_DBG} ${BAZEL_OPT_FLAGS} ${BAZEL_EXTRA_FLAGS} ${BUILD_TARGET_LITE_LIB} ;; "--linux-armv7") echo "" | TF_NEED_CUDA=0 ./configure && ${BAZEL_BUILD} ${OPT_OR_DBG} ${BAZEL_ARM_FLAGS} ${BAZEL_EXTRA_FLAGS} ${BUILD_TARGET_LITE_LIB} diff --git a/ci_scripts/tf-package.sh b/ci_scripts/tf-package.sh index 3a17672f..c856ec75 100755 --- a/ci_scripts/tf-package.sh +++ b/ci_scripts/tf-package.sh @@ -6,26 +6,17 @@ source $(dirname $0)/tf-vars.sh mkdir -p ${CI_ARTIFACTS_DIR} || true -cp ${DS_ROOT_TASK}/tensorflow/bazel_*.log ${CI_ARTIFACTS_DIR} || true - OUTPUT_ROOT="${DS_ROOT_TASK}/tensorflow/bazel-bin" -for output_bin in \ - tensorflow/lite/experimental/c/libtensorflowlite_c.so \ - tensorflow/tools/graph_transforms/transform_graph \ - tensorflow/tools/graph_transforms/summarize_graph \ - tensorflow/tools/benchmark/benchmark_model \ - tensorflow/contrib/util/convert_graphdef_memmapped_format \ - tensorflow/lite/toco/toco; +for output_bin in \ + tensorflow/lite/libtensorflow.so \ + tensorflow/lite/libtensorflow.so.if.lib \ + ; do if [ -f "${OUTPUT_ROOT}/${output_bin}" ]; then cp ${OUTPUT_ROOT}/${output_bin} ${CI_ARTIFACTS_DIR}/ fi; -done; - -if [ -f "${OUTPUT_ROOT}/tensorflow/lite/tools/benchmark/benchmark_model" ]; then - cp ${OUTPUT_ROOT}/tensorflow/lite/tools/benchmark/benchmark_model ${CI_ARTIFACTS_DIR}/lite_benchmark_model -fi +done # It seems that bsdtar and gnutar are behaving a bit differently on the way # they deal with --exclude="./public/*" ; this caused ./STT/tensorflow/core/public/ diff --git a/ci_scripts/tf-setup.sh b/ci_scripts/tf-setup.sh index 9c41952a..cde2ad76 100755 --- a/ci_scripts/tf-setup.sh +++ b/ci_scripts/tf-setup.sh @@ -5,12 +5,7 @@ set -ex source $(dirname $0)/tf-vars.sh install_android= -install_cuda= case "$1" in - "--linux-cuda"|"--windows-cuda") - install_cuda=yes - ;; - "--android-armv7"|"--android-arm64") install_android=yes ;; @@ -29,11 +24,6 @@ download() mkdir -p ${DS_ROOT_TASK}/dls || true download $BAZEL_URL $BAZEL_SHA256 -if [ ! -z "${install_cuda}" ]; then - download $CUDA_URL $CUDA_SHA256 - download $CUDNN_URL $CUDNN_SHA256 -fi; - if [ ! -z "${install_android}" ]; then download $ANDROID_NDK_URL $ANDROID_NDK_SHA256 download $ANDROID_SDK_URL $ANDROID_SDK_SHA256 @@ -63,30 +53,6 @@ bazel version bazel shutdown -if [ ! -z "${install_cuda}" ]; then - # Install CUDA and CuDNN - mkdir -p ${DS_ROOT_TASK}/STT/CUDA/ || true - pushd ${DS_ROOT_TASK} - CUDA_FILE=`basename ${CUDA_URL}` - PERL5LIB=. sh ${DS_ROOT_TASK}/dls/${CUDA_FILE} --silent --override --toolkit --toolkitpath=${DS_ROOT_TASK}/STT/CUDA/ --defaultroot=${DS_ROOT_TASK}/STT/CUDA/ - - CUDNN_FILE=`basename ${CUDNN_URL}` - tar xvf ${DS_ROOT_TASK}/dls/${CUDNN_FILE} --strip-components=1 -C ${DS_ROOT_TASK}/STT/CUDA/ - popd - - LD_LIBRARY_PATH=${DS_ROOT_TASK}/STT/CUDA/lib64/:${DS_ROOT_TASK}/STT/CUDA/lib64/stubs/:$LD_LIBRARY_PATH - export LD_LIBRARY_PATH - - # We might lack libcuda.so.1 symlink, let's fix as upstream does: - # https://github.com/tensorflow/tensorflow/pull/13811/files?diff=split#diff-2352449eb75e66016e97a591d3f0f43dR96 - if [ ! -h "${DS_ROOT_TASK}/STT/CUDA/lib64/stubs/libcuda.so.1" ]; then - ln -s "${DS_ROOT_TASK}/STT/CUDA/lib64/stubs/libcuda.so" "${DS_ROOT_TASK}/STT/CUDA/lib64/stubs/libcuda.so.1" - fi; - -else - echo "No CUDA/CuDNN to install" -fi - if [ ! -z "${install_android}" ]; then mkdir -p ${DS_ROOT_TASK}/STT/Android/SDK || true ANDROID_NDK_FILE=`basename ${ANDROID_NDK_URL}` diff --git a/ci_scripts/tf-vars.sh b/ci_scripts/tf-vars.sh index 215e825a..ebf4a5fd 100755 --- a/ci_scripts/tf-vars.sh +++ b/ci_scripts/tf-vars.sh @@ -9,13 +9,6 @@ if [ "${OS}" = "Linux" ]; then BAZEL_URL=https://github.com/bazelbuild/bazel/releases/download/3.1.0/bazel-3.1.0-installer-linux-x86_64.sh BAZEL_SHA256=7ba815cbac712d061fe728fef958651512ff394b2708e89f79586ec93d1185ed - CUDA_URL=http://developer.download.nvidia.com/compute/cuda/10.1/Prod/local_installers/cuda_10.1.243_418.87.00_linux.run - CUDA_SHA256=e7c22dc21278eb1b82f34a60ad7640b41ad3943d929bebda3008b72536855d31 - - # From https://gitlab.com/nvidia/cuda/blob/centos7/10.1/devel/cudnn7/Dockerfile - CUDNN_URL=http://developer.download.nvidia.com/compute/redist/cudnn/v7.6.0/cudnn-10.1-linux-x64-v7.6.0.64.tgz - CUDNN_SHA256=e956c6f9222fcb867a10449cfc76dee5cfd7c7531021d95fe9586d7e043b57d7 - ANDROID_NDK_URL=https://dl.google.com/android/repository/android-ndk-r18b-linux-x86_64.zip ANDROID_NDK_SHA256=4f61cbe4bbf6406aa5ef2ae871def78010eed6271af72de83f8bd0b07a9fd3fd @@ -48,8 +41,6 @@ elif [ "${OS}" = "${CI_MSYS_VERSION}" ]; then BAZEL_URL=https://github.com/bazelbuild/bazel/releases/download/3.1.0/bazel-3.1.0-windows-x86_64.exe BAZEL_SHA256=776db1f4986dacc3eda143932f00f7529f9ee65c7c1c004414c44aaa6419d0e9 - CUDA_INSTALL_DIRECTORY=$(cygpath 'C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1') - TAR=/usr/bin/tar.exe elif [ "${OS}" = "Darwin" ]; then if [ -z "${CI_TASK_DIR}" -o -z "${CI_ARTIFACTS_DIR}" ]; then @@ -89,7 +80,6 @@ fi; export PATH if [ "${OS}" = "Linux" ]; then - export LD_LIBRARY_PATH=${DS_ROOT_TASK}/STT/CUDA/lib64/:${DS_ROOT_TASK}/STT/CUDA/lib64/stubs/:$LD_LIBRARY_PATH export ANDROID_SDK_HOME=${DS_ROOT_TASK}/STT/Android/SDK/ export ANDROID_NDK_HOME=${DS_ROOT_TASK}/STT/Android/android-ndk-r18b/ fi; @@ -160,27 +150,15 @@ export BAZEL_OUTPUT_USER_ROOT NVCC_COMPUTE="3.5" -### Define build parameters/env variables that we will re-ues in sourcing scripts. -if [ "${OS}" = "${CI_MSYS_VERSION}" ]; then - TF_CUDA_FLAGS="TF_CUDA_CLANG=0 TF_CUDA_VERSION=10.1 TF_CUDNN_VERSION=7.6.0 CUDNN_INSTALL_PATH=\"${CUDA_INSTALL_DIRECTORY}\" TF_CUDA_PATHS=\"${CUDA_INSTALL_DIRECTORY}\" TF_CUDA_COMPUTE_CAPABILITIES=\"${NVCC_COMPUTE}\"" -else - TF_CUDA_FLAGS="TF_CUDA_CLANG=0 TF_CUDA_VERSION=10.1 TF_CUDNN_VERSION=7.6.0 CUDNN_INSTALL_PATH=\"${DS_ROOT_TASK}/STT/CUDA\" TF_CUDA_PATHS=\"${DS_ROOT_TASK}/STT/CUDA\" TF_CUDA_COMPUTE_CAPABILITIES=\"${NVCC_COMPUTE}\"" -fi BAZEL_ARM_FLAGS="--config=rpi3 --config=rpi3_opt --copt=-DTFLITE_WITH_RUY_GEMV" BAZEL_ARM64_FLAGS="--config=rpi3-armv8 --config=rpi3-armv8_opt --copt=-DTFLITE_WITH_RUY_GEMV" BAZEL_ANDROID_ARM_FLAGS="--config=android --config=android_arm --action_env ANDROID_NDK_API_LEVEL=21 --cxxopt=-std=c++14 --copt=-D_GLIBCXX_USE_C99 --copt=-DTFLITE_WITH_RUY_GEMV" BAZEL_ANDROID_ARM64_FLAGS="--config=android --config=android_arm64 --action_env ANDROID_NDK_API_LEVEL=21 --cxxopt=-std=c++14 --copt=-D_GLIBCXX_USE_C99 --copt=-DTFLITE_WITH_RUY_GEMV" -BAZEL_CUDA_FLAGS="--config=cuda" -if [ "${OS}" = "Linux" ]; then - # constexpr usage in tensorflow's absl dep fails badly because of gcc-5 - # so let's skip that - BAZEL_CUDA_FLAGS="${BAZEL_CUDA_FLAGS} --copt=-DNO_CONSTEXPR_FOR_YOU=1" -fi BAZEL_IOS_ARM64_FLAGS="--config=ios_arm64 --define=runtime=tflite --copt=-DTFLITE_WITH_RUY_GEMV" BAZEL_IOS_X86_64_FLAGS="--config=ios_x86_64 --define=runtime=tflite --copt=-DTFLITE_WITH_RUY_GEMV" if [ "${OS}" != "${CI_MSYS_VERSION}" ]; then - BAZEL_EXTRA_FLAGS="--config=noaws --config=nogcp --config=nohdfs --config=nonccl --copt=-fvisibility=hidden" + BAZEL_EXTRA_FLAGS="--config=noaws --config=nogcp --config=nohdfs --config=nonccl" fi if [ "${OS}" = "Darwin" ]; then @@ -189,11 +167,5 @@ fi ### Define build targets that we will re-ues in sourcing scripts. BUILD_TARGET_LIB_CPP_API="//tensorflow:tensorflow_cc" -BUILD_TARGET_GRAPH_TRANSFORMS="//tensorflow/tools/graph_transforms:transform_graph" -BUILD_TARGET_GRAPH_SUMMARIZE="//tensorflow/tools/graph_transforms:summarize_graph" -BUILD_TARGET_GRAPH_BENCHMARK="//tensorflow/tools/benchmark:benchmark_model" -#BUILD_TARGET_CONVERT_MMAP="//tensorflow/contrib/util:convert_graphdef_memmapped_format" -BUILD_TARGET_TOCO="//tensorflow/lite/toco:toco" -BUILD_TARGET_LITE_BENCHMARK="//tensorflow/lite/tools/benchmark:benchmark_model" -BUILD_TARGET_LITE_LIB="//tensorflow/lite/c:libtensorflowlite_c.so" +BUILD_TARGET_LITE_LIB="//tensorflow/lite:libtensorflowlite.so" BUILD_TARGET_LIBSTT="//native_client:libstt.so" diff --git a/native_client/BUILD b/native_client/BUILD index d11a55bf..d0a5f5d9 100644 --- a/native_client/BUILD +++ b/native_client/BUILD @@ -1,22 +1,9 @@ # Description: Coqui STT native client library. -load("@org_tensorflow//tensorflow:tensorflow.bzl", "tf_cc_shared_object", "tf_copts", "lrt_if_needed") -load("@local_config_cuda//cuda:build_defs.bzl", "if_cuda") +load("@org_tensorflow//tensorflow:tensorflow.bzl", "lrt_if_needed") load("@com_github_nelhage_rules_boost//:boost/boost.bzl", "boost_deps") load("@build_bazel_rules_apple//apple:ios.bzl", "ios_static_framework") -load( - "@org_tensorflow//tensorflow/lite:build_def.bzl", - "tflite_copts", - "tflite_linkopts", -) - -config_setting( - name = "tflite", - define_values = { - "runtime": "tflite", - }, -) config_setting( name = "rpi3", @@ -85,7 +72,7 @@ LINUX_LINKOPTS = [ "-Wl,-export-dynamic", ] -tf_cc_shared_object( +cc_binary( name = "libkenlm.so", srcs = glob([ "kenlm/lm/*.hh", @@ -107,8 +94,19 @@ tf_cc_shared_object( }), defines = ["KENLM_MAX_ORDER=6"], includes = ["kenlm"], - framework_so = [], - linkopts = [], + linkshared = 1, + linkopts = select({ + "//tensorflow:ios": [ + "-Wl,-install_name,@rpath/libkenlm.so", + ], + "//tensorflow:macos": [ + "-Wl,-install_name,@rpath/libkenlm.so", + ], + "//tensorflow:windows": [], + "//conditions:default": [ + "-Wl,-soname,libkenlm.so", + ], + }), ) cc_library( @@ -132,6 +130,20 @@ cc_library( copts = ["-fexceptions"], ) +cc_library( + name="tflite", + hdrs = [ + "//tensorflow/lite:model.h", + "//tensorflow/lite/kernels:register.h", + "//tensorflow/lite/tools/evaluation:utils.h", + ], + srcs = [ + "//tensorflow/lite:libtensorflowlite.so", + ], + includes = ["tensorflow"], + deps = ["//tensorflow/lite:libtensorflowlite.so"], +) + cc_library( name = "coqui_stt_bundle", srcs = [ @@ -142,17 +154,10 @@ cc_library( "modelstate.h", "workspace_status.cc", "workspace_status.h", - ] + select({ - "//native_client:tflite": [ - "tflitemodelstate.h", - "tflitemodelstate.cc", - ], - "//conditions:default": [ - "tfmodelstate.h", - "tfmodelstate.cc", - ], - }) + DECODER_SOURCES, - copts = tf_copts(allow_exceptions=True) + select({ + "tflitemodelstate.h", + "tflitemodelstate.cc", + ] + DECODER_SOURCES, + copts = select({ # -fvisibility=hidden is not required on Windows, MSCV hides all declarations by default "//tensorflow:windows": ["/w"], # -Wno-sign-compare to silent a lot of warnings from tensorflow itself, @@ -161,9 +166,6 @@ cc_library( "-Wno-sign-compare", "-fvisibility=hidden", ], - }) + select({ - "//native_client:tflite": ["-DUSE_TFLITE"], - "//conditions:default": ["-UUSE_TFLITE"], }), linkopts = lrt_if_needed() + select({ "//tensorflow:macos": [], @@ -174,64 +176,32 @@ cc_library( # Bazel is has too strong opinions about static linking, so it's # near impossible to get it to link a DLL against another DLL on Windows. # We simply force the linker option manually here as a hacky fix. - "//tensorflow:windows": ["bazel-out/x64_windows-opt/bin/native_client/libkenlm.so.if.lib"], + "//tensorflow:windows": [ + "bazel-out/x64_windows-opt/bin/native_client/libkenlm.so.if.lib", + "bazel-out/x64_windows-opt/bin/tensorflow/lite/libtensorflowlite.so.if.lib", + ], "//conditions:default": [], - }) + tflite_linkopts() + DECODER_LINKOPTS, + }) + DECODER_LINKOPTS, includes = DECODER_INCLUDES, - deps = select({ - "//native_client:tflite": [ - "//tensorflow/lite/kernels:builtin_ops", - "//tensorflow/lite/tools/evaluation:utils", - ], - "//conditions:default": [ - "//tensorflow/core:core_cpu", - "//tensorflow/core:direct_session", - "//third_party/eigen3", - #"//tensorflow/core:all_kernels", - ### => Trying to be more fine-grained - ### Use bin/ops_in_graph.py to list all the ops used by a frozen graph. - ### CPU only build, libstt.so file size reduced by ~50% - "//tensorflow/core/kernels:spectrogram_op", # AudioSpectrogram - "//tensorflow/core/kernels:bias_op", # BiasAdd - "//tensorflow/core/kernels:cast_op", # Cast - "//tensorflow/core/kernels:concat_op", # ConcatV2 - "//tensorflow/core/kernels:constant_op", # Const, Placeholder - "//tensorflow/core/kernels:shape_ops", # ExpandDims, Shape - "//tensorflow/core/kernels:gather_nd_op", # GatherNd - "//tensorflow/core/kernels:identity_op", # Identity - "//tensorflow/core/kernels:immutable_constant_op", # ImmutableConst (used in memmapped models) - "//tensorflow/core/kernels:deepspeech_cwise_ops", # Less, Minimum, Mul - "//tensorflow/core/kernels:matmul_op", # MatMul - "//tensorflow/core/kernels:reduction_ops", # Max - "//tensorflow/core/kernels:mfcc_op", # Mfcc - "//tensorflow/core/kernels:no_op", # NoOp - "//tensorflow/core/kernels:pack_op", # Pack - "//tensorflow/core/kernels:sequence_ops", # Range - "//tensorflow/core/kernels:relu_op", # Relu - "//tensorflow/core/kernels:reshape_op", # Reshape - "//tensorflow/core/kernels:softmax_op", # Softmax - "//tensorflow/core/kernels:tile_ops", # Tile - "//tensorflow/core/kernels:transpose_op", # Transpose - "//tensorflow/core/kernels:rnn_ops", # BlockLSTM - # And we also need the op libs for these ops used in the model: - "//tensorflow/core:audio_ops_op_lib", # AudioSpectrogram, Mfcc - "//tensorflow/core:rnn_ops_op_lib", # BlockLSTM - "//tensorflow/core:math_ops_op_lib", # Cast, Less, Max, MatMul, Minimum, Range - "//tensorflow/core:array_ops_op_lib", # ConcatV2, Const, ExpandDims, Fill, GatherNd, Identity, Pack, Placeholder, Reshape, Tile, Transpose - "//tensorflow/core:no_op_op_lib", # NoOp - "//tensorflow/core:nn_ops_op_lib", # Relu, Softmax, BiasAdd - # And op libs for these ops brought in by dependencies of dependencies to silence unknown OpKernel warnings: - "//tensorflow/core:dataset_ops_op_lib", # UnwrapDatasetVariant, WrapDatasetVariant - "//tensorflow/core:sendrecv_ops_op_lib", # _HostRecv, _HostSend, _Recv, _Send - ], - }) + if_cuda([ - "//tensorflow/core:core", - ]) + [":kenlm"], + deps = [":kenlm", ":tflite"], ) -tf_cc_shared_object( +cc_binary( name = "libstt.so", deps = [":coqui_stt_bundle"], + linkshared = 1, + linkopts = select({ + "//tensorflow:ios": [ + "-Wl,-install_name,@rpath/libstt.so", + ], + "//tensorflow:macos": [ + "-Wl,-install_name,@rpath/libstt.so", + ], + "//tensorflow:windows": [], + "//conditions:default": [ + "-Wl,-soname,libstt.so", + ], + }), ) ios_static_framework( diff --git a/native_client/definitions.mk b/native_client/definitions.mk index 9280614e..03adcdd9 100644 --- a/native_client/definitions.mk +++ b/native_client/definitions.mk @@ -20,8 +20,8 @@ endif STT_BIN := stt$(PLATFORM_EXE_SUFFIX) CFLAGS_STT := -std=c++11 -o $(STT_BIN) -LINK_STT := -lstt -lkenlm -LINK_PATH_STT := -L${TFDIR}/bazel-bin/native_client +LINK_STT := -lstt -lkenlm -ltensorflowlite +LINK_PATH_STT := -L${TFDIR}/bazel-bin/native_client -L${TFDIR}/bazel-bin/tensorflow/lite ifeq ($(TARGET),host) TOOLCHAIN := @@ -61,7 +61,7 @@ TOOL_CC := cl.exe TOOL_CXX := cl.exe TOOL_LD := link.exe TOOL_LIBEXE := lib.exe -LINK_STT := $(shell cygpath "$(TFDIR)/bazel-bin/native_client/libstt.so.if.lib") $(shell cygpath "$(TFDIR)/bazel-bin/native_client/libkenlm.so.if.lib") +LINK_STT := $(shell cygpath "$(TFDIR)/bazel-bin/native_client/libstt.so.if.lib") $(shell cygpath "$(TFDIR)/bazel-bin/native_client/libkenlm.so.if.lib") $(shell cygpath "$(TFDIR)/bazel-bin/tensorflow/lite/libtensorflowlite.so.if.lib") LINK_PATH_STT := CFLAGS_STT := -nologo -Fe$(STT_BIN) SOX_CFLAGS := @@ -185,7 +185,7 @@ define copy_missing_libs new_missing="$$( (for f in $$(otool -L $$lib 2>/dev/null | tail -n +2 | awk '{ print $$1 }' | grep -v '$$lib'); do ls -hal $$f; done;) 2>&1 | grep 'No such' | cut -d':' -f2 | xargs basename -a)"; \ missing_libs="$$missing_libs $$new_missing"; \ elif [ "$(OS)" = "${CI_MSYS_VERSION}" ]; then \ - missing_libs="libstt.so libkenlm.so"; \ + missing_libs="libstt.so libkenlm.so libtensorflowlite.so"; \ else \ missing_libs="$$missing_libs $$($(LDD) $$lib | grep 'not found' | awk '{ print $$1 }')"; \ fi; \ diff --git a/native_client/javascript/binding.gyp b/native_client/javascript/binding.gyp index 91d9d19a..af949066 100644 --- a/native_client/javascript/binding.gyp +++ b/native_client/javascript/binding.gyp @@ -27,12 +27,14 @@ "libraries": [ "../../../tensorflow/bazel-bin/native_client/libstt.so.if.lib", "../../../tensorflow/bazel-bin/native_client/libkenlm.so.if.lib", + "../../../tensorflow/bazel-bin/tensorflow/lite/libtensorflowlite.so.if.lib", ], }, { "libraries": [ "../../../tensorflow/bazel-bin/native_client/libstt.so", "../../../tensorflow/bazel-bin/native_client/libkenlm.so", + "../../../tensorflow/bazel-bin/tensorflow/lite/libtensorflowlite.so", ], }, ], diff --git a/native_client/stt.cc b/native_client/stt.cc index 28715ec5..9614bd63 100644 --- a/native_client/stt.cc +++ b/native_client/stt.cc @@ -14,13 +14,7 @@ #include "modelstate.h" #include "workspace_status.h" - -#ifndef USE_TFLITE -#include "tfmodelstate.h" -#else #include "tflitemodelstate.h" -#endif // USE_TFLITE - #include "ctcdecode/ctc_beam_search_decoder.h" #ifdef __ANDROID__ @@ -282,13 +276,7 @@ STT_CreateModel(const char* aModelPath, return STT_ERR_NO_MODEL; } - std::unique_ptr model( -#ifndef USE_TFLITE - new TFModelState() -#else - new TFLiteModelState() -#endif - ); + std::unique_ptr model(new TFLiteModelState()); if (!model) { std::cerr << "Could not allocate model state." << std::endl; diff --git a/native_client/tfmodelstate.cc b/native_client/tfmodelstate.cc deleted file mode 100644 index df712b68..00000000 --- a/native_client/tfmodelstate.cc +++ /dev/null @@ -1,263 +0,0 @@ -#include "tfmodelstate.h" - -#include "workspace_status.h" - -using namespace tensorflow; -using std::vector; - -TFModelState::TFModelState() - : ModelState() - , mmap_env_(nullptr) - , session_(nullptr) -{ -} - -TFModelState::~TFModelState() -{ - if (session_) { - Status status = session_->Close(); - if (!status.ok()) { - std::cerr << "Error closing TensorFlow session: " << status << std::endl; - } - } -} - -int -TFModelState::init(const char* model_path) -{ - int err = ModelState::init(model_path); - if (err != STT_ERR_OK) { - return err; - } - - Status status; - SessionOptions options; - - mmap_env_.reset(new MemmappedEnv(Env::Default())); - - bool is_mmap = std::string(model_path).find(".pbmm") != std::string::npos; - if (!is_mmap) { - std::cerr << "Warning: reading entire model file into memory. Transform model file into an mmapped graph to reduce heap usage." << std::endl; - } else { - status = mmap_env_->InitializeFromFile(model_path); - if (!status.ok()) { - std::cerr << status << std::endl; - return STT_ERR_FAIL_INIT_MMAP; - } - - options.config.mutable_graph_options() - ->mutable_optimizer_options() - ->set_opt_level(::OptimizerOptions::L0); - options.env = mmap_env_.get(); - } - - Session* session; - status = NewSession(options, &session); - if (!status.ok()) { - std::cerr << status << std::endl; - return STT_ERR_FAIL_INIT_SESS; - } - session_.reset(session); - - if (is_mmap) { - status = ReadBinaryProto(mmap_env_.get(), - MemmappedFileSystem::kMemmappedPackageDefaultGraphDef, - &graph_def_); - } else { - status = ReadBinaryProto(Env::Default(), model_path, &graph_def_); - } - if (!status.ok()) { - std::cerr << status << std::endl; - return STT_ERR_FAIL_READ_PROTOBUF; - } - - status = session_->Create(graph_def_); - if (!status.ok()) { - std::cerr << status << std::endl; - return STT_ERR_FAIL_CREATE_SESS; - } - - std::vector version_output; - status = session_->Run({}, { - "metadata_version" - }, {}, &version_output); - if (!status.ok()) { - std::cerr << "Unable to fetch graph version: " << status << std::endl; - return STT_ERR_MODEL_INCOMPATIBLE; - } - - int graph_version = version_output[0].scalar()(); - if (graph_version < ds_graph_version()) { - std::cerr << "Specified model file version (" << graph_version << ") is " - << "incompatible with minimum version supported by this client (" - << ds_graph_version() << "). See " - << "https://stt.readthedocs.io/en/latest/USING.html#model-compatibility " - << "for more information" << std::endl; - return STT_ERR_MODEL_INCOMPATIBLE; - } - - std::vector metadata_outputs; - status = session_->Run({}, { - "metadata_sample_rate", - "metadata_feature_win_len", - "metadata_feature_win_step", - "metadata_beam_width", - "metadata_alphabet", - }, {}, &metadata_outputs); - if (!status.ok()) { - std::cout << "Unable to fetch metadata: " << status << std::endl; - return STT_ERR_MODEL_INCOMPATIBLE; - } - - sample_rate_ = metadata_outputs[0].scalar()(); - int win_len_ms = metadata_outputs[1].scalar()(); - int win_step_ms = metadata_outputs[2].scalar()(); - audio_win_len_ = sample_rate_ * (win_len_ms / 1000.0); - audio_win_step_ = sample_rate_ * (win_step_ms / 1000.0); - int beam_width = metadata_outputs[3].scalar()(); - beam_width_ = (unsigned int)(beam_width); - - string serialized_alphabet = metadata_outputs[4].scalar()(); - err = alphabet_.Deserialize(serialized_alphabet.data(), serialized_alphabet.size()); - if (err != 0) { - return STT_ERR_INVALID_ALPHABET; - } - - assert(sample_rate_ > 0); - assert(audio_win_len_ > 0); - assert(audio_win_step_ > 0); - assert(beam_width_ > 0); - assert(alphabet_.GetSize() > 0); - - for (int i = 0; i < graph_def_.node_size(); ++i) { - NodeDef node = graph_def_.node(i); - if (node.name() == "input_node") { - const auto& shape = node.attr().at("shape").shape(); - n_steps_ = shape.dim(1).size(); - n_context_ = (shape.dim(2).size()-1)/2; - n_features_ = shape.dim(3).size(); - mfcc_feats_per_timestep_ = shape.dim(2).size() * shape.dim(3).size(); - } else if (node.name() == "previous_state_c") { - const auto& shape = node.attr().at("shape").shape(); - state_size_ = shape.dim(1).size(); - } else if (node.name() == "logits_shape") { - Tensor logits_shape = Tensor(DT_INT32, TensorShape({3})); - if (!logits_shape.FromProto(node.attr().at("value").tensor())) { - continue; - } - - int final_dim_size = logits_shape.vec()(2) - 1; - if (final_dim_size != alphabet_.GetSize()) { - std::cerr << "Error: Alphabet size does not match loaded model: alphabet " - << "has size " << alphabet_.GetSize() - << ", but model has " << final_dim_size - << " classes in its output. Make sure you're passing an alphabet " - << "file with the same size as the one used for training." - << std::endl; - return STT_ERR_INVALID_ALPHABET; - } - } - } - - if (n_context_ == -1 || n_features_ == -1) { - std::cerr << "Error: Could not infer input shape from model file. " - << "Make sure input_node is a 4D tensor with shape " - << "[batch_size=1, time, window_size, n_features]." - << std::endl; - return STT_ERR_INVALID_SHAPE; - } - - return STT_ERR_OK; -} - -Tensor -tensor_from_vector(const std::vector& vec, const TensorShape& shape) -{ - Tensor ret(DT_FLOAT, shape); - auto ret_mapped = ret.flat(); - int i; - for (i = 0; i < vec.size(); ++i) { - ret_mapped(i) = vec[i]; - } - for (; i < shape.num_elements(); ++i) { - ret_mapped(i) = 0.f; - } - return ret; -} - -void -copy_tensor_to_vector(const Tensor& tensor, vector& vec, int num_elements = -1) -{ - auto tensor_mapped = tensor.flat(); - if (num_elements == -1) { - num_elements = tensor.shape().num_elements(); - } - for (int i = 0; i < num_elements; ++i) { - vec.push_back(tensor_mapped(i)); - } -} - -void -TFModelState::infer(const std::vector& mfcc, - unsigned int n_frames, - const std::vector& previous_state_c, - const std::vector& previous_state_h, - vector& logits_output, - vector& state_c_output, - vector& state_h_output) -{ - const size_t num_classes = alphabet_.GetSize() + 1; // +1 for blank - - Tensor input = tensor_from_vector(mfcc, TensorShape({BATCH_SIZE, n_steps_, 2*n_context_+1, n_features_})); - Tensor previous_state_c_t = tensor_from_vector(previous_state_c, TensorShape({BATCH_SIZE, (long long)state_size_})); - Tensor previous_state_h_t = tensor_from_vector(previous_state_h, TensorShape({BATCH_SIZE, (long long)state_size_})); - - Tensor input_lengths(DT_INT32, TensorShape({1})); - input_lengths.scalar()() = n_frames; - - vector outputs; - Status status = session_->Run( - { - {"input_node", input}, - {"input_lengths", input_lengths}, - {"previous_state_c", previous_state_c_t}, - {"previous_state_h", previous_state_h_t} - }, - {"logits", "new_state_c", "new_state_h"}, - {}, - &outputs); - - if (!status.ok()) { - std::cerr << "Error running session: " << status << "\n"; - return; - } - - copy_tensor_to_vector(outputs[0], logits_output, n_frames * BATCH_SIZE * num_classes); - - state_c_output.clear(); - state_c_output.reserve(state_size_); - copy_tensor_to_vector(outputs[1], state_c_output); - - state_h_output.clear(); - state_h_output.reserve(state_size_); - copy_tensor_to_vector(outputs[2], state_h_output); -} - -void -TFModelState::compute_mfcc(const vector& samples, vector& mfcc_output) -{ - Tensor input = tensor_from_vector(samples, TensorShape({audio_win_len_})); - - vector outputs; - Status status = session_->Run({{"input_samples", input}}, {"mfccs"}, {}, &outputs); - - if (!status.ok()) { - std::cerr << "Error running session: " << status << "\n"; - return; - } - - // The feature computation graph is hardcoded to one audio length for now - const int n_windows = 1; - assert(outputs[0].shape().num_elements() / n_features_ == n_windows); - copy_tensor_to_vector(outputs[0], mfcc_output); -} diff --git a/native_client/tfmodelstate.h b/native_client/tfmodelstate.h deleted file mode 100644 index 2a8db699..00000000 --- a/native_client/tfmodelstate.h +++ /dev/null @@ -1,35 +0,0 @@ -#ifndef TFMODELSTATE_H -#define TFMODELSTATE_H - -#include - -#include "tensorflow/core/public/session.h" -#include "tensorflow/core/platform/env.h" -#include "tensorflow/core/util/memmapped_file_system.h" - -#include "modelstate.h" - -struct TFModelState : public ModelState -{ - std::unique_ptr mmap_env_; - std::unique_ptr session_; - tensorflow::GraphDef graph_def_; - - TFModelState(); - virtual ~TFModelState(); - - virtual int init(const char* model_path) override; - - virtual void infer(const std::vector& mfcc, - unsigned int n_frames, - const std::vector& previous_state_c, - const std::vector& previous_state_h, - std::vector& logits_output, - std::vector& state_c_output, - std::vector& state_h_output) override; - - virtual void compute_mfcc(const std::vector& audio_buffer, - std::vector& mfcc_output) override; -}; - -#endif // TFMODELSTATE_H From c69735e3b6d434913ba50a17d9b2cde944adfe2c Mon Sep 17 00:00:00 2001 From: Reuben Morais Date: Wed, 28 Jul 2021 17:52:51 +0200 Subject: [PATCH 3/4] Build swig and decoder on manylinux_2_24 --- .github/workflows/build-and-test.yml | 37 +++++++++++++++++----------- native_client/ctcdecode/Makefile | 4 +-- native_client/definitions.mk | 5 +--- native_client/python/Makefile | 2 +- 4 files changed, 27 insertions(+), 21 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 68fc5b7f..ab3ab4ac 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -71,6 +71,10 @@ jobs: swig_Linux: name: "Lin|Build SWIG" runs-on: ubuntu-20.04 + container: + image: quay.io/pypa/manylinux_2_24_x86_64:2021-07-25-cfe8a6c + volumes: + - ${{ github.workspace }}:${{ github.workspace }} env: swig_hash: "90cdbee6a69d13b39d734083b9f91069533b0d7b" steps: @@ -84,10 +88,7 @@ jobs: id: swig-build-cache with: path: build-static/ - key: swig-2-${{ runner.os }}-${{ env.swig_hash }} - - run: | - sudo apt-get install -y --no-install-recommends autoconf automake bison build-essential - if: steps.swig-build-cache.outputs.cache-hit != 'true' + key: swig-4-${{ runner.os }}-${{ env.swig_hash }} - run: | curl -sSL https://ftp.pcre.org/pub/pcre/pcre-8.43.tar.gz > pcre-8.43.tar.gz if: steps.swig-build-cache.outputs.cache-hit != 'true' @@ -114,6 +115,10 @@ jobs: name: "Lin|Build CTC decoder Python package" needs: [ swig_Linux ] runs-on: ubuntu-20.04 + container: + image: quay.io/pypa/manylinux_2_24_x86_64:2021-07-25-cfe8a6c + volumes: + - ${{ github.workspace }}:${{ github.workspace }} strategy: matrix: python-version: [3.6, 3.7, 3.8, 3.9] @@ -121,12 +126,6 @@ jobs: - uses: actions/checkout@v2 with: fetch-depth: 0 - - uses: actions/setup-python@v2 - with: - python-version: ${{ matrix.python-version }} - - run: | - python --version - pip --version - uses: actions/download-artifact@v2 with: name: "swig_Linux" @@ -142,17 +141,27 @@ jobs: pyver: ${{ matrix.python-version }} - name: Make decoder package run: | + # Setup venv + /opt/_internal/cpython-${{ matrix.python-version }}*/bin/python -m venv /tmp/venv-${{ matrix.python-version }} + source /tmp/venv-${{ matrix.python-version }}/bin/activate + + # Check versions + python --version + pip --version + + # Build decoder package NUMPY_BUILD_VERSION="${{ steps.get_numpy.outputs.build_version }}" \ NUMPY_DEP_VERSION="${{ steps.get_numpy.outputs.dep_version }}" \ make -C native_client/ctcdecode/ \ NUM_PROCESSES=$(nproc) \ bindings + - name: Auditwheel repair + run: | + auditwheel repair native_client/ctcdecode/dist/*.whl - uses: actions/upload-artifact@v2 with: name: "coqui_stt_ctcdecoder-Linux-${{ matrix.python-version }}.whl" - path: ${{ github.workspace }}/native_client/ctcdecode/dist/*.whl - - run: | - make -C native_client/ctcdecode clean-keep-third-party + path: ${{ github.workspace }}/wheelhouse/*.whl train-test-model-Linux: name: "Lin|Train a test model" needs: [ "build-ctc-decoder-Linux" ] @@ -175,7 +184,7 @@ jobs: python --version pip --version - run: | - pip install --upgrade pip==19.3.1 setuptools==45.0.0 wheel==0.33.6 + pip install --upgrade pip setuptools wheel - run: | pip install coqui_stt_ctcdecoder-*-cp36-cp36m-*_x86_64.whl DS_NODECODER=y pip install --upgrade . diff --git a/native_client/ctcdecode/Makefile b/native_client/ctcdecode/Makefile index 509573e6..a069e809 100644 --- a/native_client/ctcdecode/Makefile +++ b/native_client/ctcdecode/Makefile @@ -45,14 +45,14 @@ workspace_status.cc: # Enforce PATH here because swig calls from build_ext looses track of some # variables over several runs bindings: clean-keep-third-party workspace_status.cc $(DS_SWIG_DEP) - python -m pip install --quiet $(PYTHON_PACKAGES) wheel==0.33.6 setuptools==45.0.0 + python -m pip install --quiet $(PYTHON_PACKAGES) wheel setuptools DISTUTILS_USE_SDK=1 PATH=$(DS_SWIG_BIN_PATH):$(TOOLCHAIN_DIR):$$PATH SWIG_LIB="$(SWIG_LIB)" AS=$(AS) CC=$(CC) CXX=$(CXX) LD=$(LD) LIBEXE=$(LIBEXE) CFLAGS="$(CFLAGS) $(CXXFLAGS)" LDFLAGS="$(LDFLAGS_NEEDED)" $(PYTHON_PATH) $(NUMPY_INCLUDE) python ./setup.py build_ext --num_processes $(NUM_PROCESSES) $(PYTHON_PLATFORM_NAME) $(SETUP_FLAGS) find temp_build -type f -name "*.o" -delete DISTUTILS_USE_SDK=1 AS=$(AS) CC=$(CC) CXX=$(CXX) LD=$(LD) LIBEXE=$(LIBEXE) CFLAGS="$(CFLAGS) $(CXXFLAGS)" LDFLAGS="$(LDFLAGS_NEEDED)" $(PYTHON_PATH) $(NUMPY_INCLUDE) python ./setup.py bdist_wheel $(PYTHON_PLATFORM_NAME) $(SETUP_FLAGS) rm -rf temp_build bindings-debug: clean-keep-third-party workspace_status.cc $(DS_SWIG_DEP) - python -m pip install --quiet $(PYTHON_PACKAGES) wheel==0.33.6 setuptools==45.0.0 + python -m pip install --quiet $(PYTHON_PACKAGES) wheel setuptools DISTUTILS_USE_SDK=1 PATH=$(DS_SWIG_BIN_PATH):$(TOOLCHAIN_DIR):$$PATH SWIG_LIB="$(SWIG_LIB)" AS=$(AS) CC=$(CC) CXX=$(CXX) LD=$(LD) LIBEXE=$(LIBEXE) CFLAGS="$(CFLAGS) $(CXXFLAGS) -DDEBUG" LDFLAGS="$(LDFLAGS_NEEDED)" $(PYTHON_PATH) $(NUMPY_INCLUDE) python ./setup.py build_ext --debug --num_processes $(NUM_PROCESSES) $(PYTHON_PLATFORM_NAME) $(SETUP_FLAGS) $(GENERATE_DEBUG_SYMS) find temp_build -type f -name "*.o" -delete diff --git a/native_client/definitions.mk b/native_client/definitions.mk index 03adcdd9..e630001b 100644 --- a/native_client/definitions.mk +++ b/native_client/definitions.mk @@ -50,9 +50,6 @@ else SOX_LDFLAGS := `pkg-config --libs sox` endif # OS others PYTHON_PACKAGES := numpy${NUMPY_BUILD_VERSION} -ifeq ($(OS),Linux) -PYTHON_PLATFORM_NAME ?= --plat-name manylinux1_x86_64 -endif endif ifeq ($(findstring _NT,$(OS)),_NT) @@ -237,7 +234,7 @@ DS_SWIG_ENV := SWIG_LIB="$(SWIG_LIB)" PATH="$(DS_SWIG_BIN_PATH):${PATH}" $(DS_SWIG_BIN_PATH)/swig: mkdir -p $(SWIG_ROOT) - wget -O - "$(SWIG_DIST_URL)" | tar -C $(SWIG_ROOT) -zxf - + curl -sSL "$(SWIG_DIST_URL)" | tar -C $(SWIG_ROOT) -zxf - ln -s $(DS_SWIG_BIN) $(DS_SWIG_BIN_PATH)/$(SWIG_BIN) ds-swig: $(DS_SWIG_BIN_PATH)/swig diff --git a/native_client/python/Makefile b/native_client/python/Makefile index 2ead3b9e..fb313204 100644 --- a/native_client/python/Makefile +++ b/native_client/python/Makefile @@ -9,7 +9,7 @@ bindings-clean: # Enforce PATH here because swig calls from build_ext looses track of some # variables over several runs bindings-build: ds-swig - pip3 install --quiet $(PYTHON_PACKAGES) wheel==0.33.6 setuptools==45.0.0 + pip3 install --quiet $(PYTHON_PACKAGES) wheel setuptools DISTUTILS_USE_SDK=1 PATH=$(TOOLCHAIN_DIR):$(DS_SWIG_BIN_PATH):$$PATH SWIG_LIB="$(SWIG_LIB)" AS=$(AS) CC=$(CC) CXX=$(CXX) LD=$(LD) CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS_NEEDED) $(RPATH_PYTHON)" MODEL_LDFLAGS="$(LDFLAGS_DIRS)" MODEL_LIBS="$(LIBS)" $(PYTHON_PATH) $(PYTHON_SYSCONFIGDATA) $(NUMPY_INCLUDE) python3 ./setup.py build_ext $(PYTHON_PLATFORM_NAME) MANIFEST.in: bindings-build From d119957586053765dc80ea00b9f575de29562a09 Mon Sep 17 00:00:00 2001 From: Reuben Morais Date: Thu, 29 Jul 2021 16:34:49 +0200 Subject: [PATCH 4/4] Update supported architectures doc --- doc/SUPPORTED_PLATFORMS.rst | 39 ++++++++++--------------------------- 1 file changed, 10 insertions(+), 29 deletions(-) diff --git a/doc/SUPPORTED_PLATFORMS.rst b/doc/SUPPORTED_PLATFORMS.rst index f79f6484..e505b218 100644 --- a/doc/SUPPORTED_PLATFORMS.rst +++ b/doc/SUPPORTED_PLATFORMS.rst @@ -7,65 +7,46 @@ Here we maintain the list of supported platforms for deployment. *Note that 🐸STT currently only provides packages for CPU deployment with Python 3.5 or higher on Linux. We're working to get the rest of our usually supported packages back up and running as soon as possible.* -Linux / AMD64 without GPU +Linux / AMD64 ^^^^^^^^^^^^^^^^^^^^^^^^^ * x86-64 CPU with AVX/FMA (one can rebuild without AVX/FMA, but it might slow down performance) -* Ubuntu 14.04+ (glibc >= 2.19, libstdc++6 >= 4.8) -* Full TensorFlow runtime (``stt`` packages) -* TensorFlow Lite runtime (``stt-tflite`` packages) - -Linux / AMD64 with GPU -^^^^^^^^^^^^^^^^^^^^^^ -* x86-64 CPU with AVX/FMA (one can rebuild without AVX/FMA, but it might slow down performance) -* Ubuntu 14.04+ (glibc >= 2.19, libstdc++6 >= 4.8) -* CUDA 10.0 (and capable GPU) -* Full TensorFlow runtime (``stt`` packages) -* TensorFlow Lite runtime (``stt-tflite`` packages) +* glibc >= 2.24, libstdc++6 >= 6.3 +* TensorFlow Lite runtime Linux / ARMv7 ^^^^^^^^^^^^^ * Cortex-A53 compatible ARMv7 SoC with Neon support * Raspbian Buster-compatible distribution -* TensorFlow Lite runtime (``stt-tflite`` packages) +* TensorFlow Lite runtime Linux / Aarch64 ^^^^^^^^^^^^^^^ * Cortex-A72 compatible Aarch64 SoC * ARMbian Buster-compatible distribution -* TensorFlow Lite runtime (``stt-tflite`` packages) +* TensorFlow Lite runtime Android / ARMv7 ^^^^^^^^^^^^^^^ * ARMv7 SoC with Neon support * Android 7.0-10.0 * NDK API level >= 21 -* TensorFlow Lite runtime (``stt-tflite`` packages) +* TensorFlow Lite runtime Android / Aarch64 ^^^^^^^^^^^^^^^^^ * Aarch64 SoC * Android 7.0-10.0 * NDK API level >= 21 -* TensorFlow Lite runtime (``stt-tflite`` packages) +* TensorFlow Lite runtime macOS / AMD64 ^^^^^^^^^^^^^ * x86-64 CPU with AVX/FMA (one can rebuild without AVX/FMA, but it might slow down performance) * macOS >= 10.10 -* Full TensorFlow runtime (``stt`` packages) -* TensorFlow Lite runtime (``stt-tflite`` packages) +* TensorFlow Lite runtime -Windows / AMD64 without GPU +Windows / AMD64 ^^^^^^^^^^^^^^^^^^^^^^^^^^^ * x86-64 CPU with AVX/FMA (one can rebuild without AVX/FMA, but it might slow down performance) * Windows Server >= 2012 R2 ; Windows >= 8.1 -* Full TensorFlow runtime (``stt`` packages) -* TensorFlow Lite runtime (``stt-tflite`` packages) - -Windows / AMD64 with GPU -^^^^^^^^^^^^^^^^^^^^^^^^ -* x86-64 CPU with AVX/FMA (one can rebuild without AVX/FMA, but it might slow down performance) -* Windows Server >= 2012 R2 ; Windows >= 8.1 -* CUDA 10.0 (and capable GPU) -* Full TensorFlow runtime (``stt`` packages) -* TensorFlow Lite runtime (``stt-tflite`` packages) +* TensorFlow Lite runtime