Merge pull request #1981 from coqui-ai/aar-publish

AAR build+publish
This commit is contained in:
Reuben Morais 2021-10-02 13:39:28 +02:00 committed by GitHub
commit 18812376dc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 219 additions and 79 deletions

View File

@ -19,10 +19,6 @@ inputs:
description: "Tag of release to check artifacts under"
required: false
default: "v0.10.0-alpha.7"
should-create-release:
description: "Whether this action should automatically create a release for the given tag if one doesn't already exist"
required: false
default: false
runs:
using: "composite"
steps:
@ -51,7 +47,6 @@ runs:
owner=$(echo "${{inputs.repo}}" | cut -f1 -d/)
repo=$(echo "${{inputs.repo}}" | cut -f2 -d/)
tag="${{ inputs.release-tag }}"
should_create="${{ inputs.should-create-release }}"
GH_REPO="https://api.github.com/repos/${owner}/${repo}"
@ -75,21 +70,9 @@ runs:
response=$(curl -sH "$AUTH" $GH_TAGS)
eval $(echo "$response" | grep -m 1 "id.:" | grep -w id | tr : = | tr -cd '[[:alnum:]]=')
[ "$id" ] || {
# If release does not exist, create it
if [[ "$should_create" == "true" ]]; then
echo "Tag does not have corresponding release, creating release for tag: $tag..."
response=$(curl -X POST -sH "$AUTH" -H "Content-Type: application/json" "${GH_REPO}/releases" -d '{"tag_name":"'"$tag"'","name":"Coqui STT '"$tag"'","prerelease":true}')
eval $(echo "$response" | grep -m 1 "id.:" | grep -w id | tr : = | tr -cd '[[:alnum:]]=')
[ "$id" ] || {
echo "Error: Could not create release for tag: $tag"
echo "$response" | awk 'length($0)<100' >&2
exit 1
}
else
echo "Error: Could not find release for tag: $tag"
echo "$response" | awk 'length($0)<100' >&2
exit 1
fi
echo "Error: Could not find release for tag: $tag"
echo "$response" | awk 'length($0)<100' >&2
exit 1
}
# Upload assets

View File

@ -23,6 +23,57 @@ defaults:
run:
shell: bash
jobs:
create-release:
name: "Create release for tag"
runs-on: ubuntu-20.04
outputs:
release-tag: ${{ steps.check-version.outputs.release-tag }}
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Check VERSION file matches pushed Git tag and check if prerelease
id: check-version
run: |
set -xe
if [[ "${{ startsWith(github.ref, 'refs/tags/') }}" != "true" ]]; then
echo "Should never happen (this job only runs on tag pushes)"
exit 1
fi
VERSION="v$(cat VERSION)"
if [[ "${{ github.ref }}" != "refs/tags/${VERSION}" ]]; then
echo "Pushed tag does not match VERSION file. Aborting release."
exit 1
fi
# Tag for this release (version with leading v)
tag=$(echo "${{ github.ref }}" | sed -e 's|^refs/tags/||')
echo ::set-output name=release-tag::${tag}
# Version without leading v
version=$(cat VERSION)
echo ::set-output name=version::${version}
# Is this a prerelease or not?
cat <<EOF | python - "${{ github.ref }}"
import sys
import semver
ref = sys.argv[1]
prefix = "refs/tags/v"
assert ref.startswith(prefix)
parsed = semver.parse_version_info(ref[len(prefix):])
print("::set-output name=is-prerelease::{}".format("true" if parsed.prerelease else "false"))
EOF
- uses: softprops/action-gh-release@v1
with:
body_path: RELEASE_NOTES.md
prerelease: ${{ steps.check-version.outputs.prerelease }}
name: ${{ format('Coqui STT {0}', steps.check-version.outputs.version) }}
# Linux jobs
swig_Windows_crosscompiled:
name: "Lin|Build SWIG for Windows"
@ -779,6 +830,7 @@ jobs:
twine-upload-training:
name: "Upload STT training packages to PyPI"
runs-on: ubuntu-20.04
needs: [create-release]
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
steps:
- uses: actions/checkout@v2
@ -809,13 +861,12 @@ jobs:
with:
name: '' # use filename
path: "dist/*.whl"
release-tag: ${{ steps.get-tag.outputs.tag }}
should-create-release: true
release-tag: ${{ needs.create-release.outputs.release-tag }}
twine-upload-stt:
name: "Upload STT 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]
needs: [create-release, build-python-Linux, build-python-macOS, build-python-Windows, build-python-LinuxArmv7, build-python-LinuxAarch64]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
@ -889,13 +940,12 @@ jobs:
with:
name: '' # use filename
path: "*.whl"
release-tag: ${{ steps.get-tag.outputs.tag }}
should-create-release: true
release-tag: ${{ needs.create-release.outputs.release-tag }}
upload-nc-release-assets:
name: "Upload native client artifacts to release assets"
runs-on: ubuntu-20.04
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
needs: [build-lib_Windows, build-lib_Linux, build-lib_macOS, build-lib_LinuxAarch64, build-lib_LinuxArmv7]
needs: [create-release, build-lib_Windows, build-lib_Linux, build-lib_macOS, build-lib_LinuxAarch64, build-lib_LinuxArmv7]
steps:
- uses: actions/checkout@v2
- uses: actions/download-artifact@v2
@ -940,14 +990,12 @@ jobs:
with:
name: '' # use filename
path: "*.tar.xz"
release-tag: ${{ steps.get-tag.outputs.tag }}
should-create-release: true
release-tag: ${{ needs.create-release.outputs.release-tag }}
- uses: ./.github/actions/upload-release-asset
with:
name: '' # use filename
path: "*.zip"
release-tag: ${{ steps.get-tag.outputs.tag }}
should-create-release: true
release-tag: ${{ needs.create-release.outputs.release-tag }}
docker-build:
name: "Build Dockerfile.build image"
runs-on: ubuntu-20.04
@ -1016,7 +1064,7 @@ jobs:
name: "Upload coqui_stt_ctcdecoder packages to PyPI"
runs-on: ubuntu-20.04
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
needs: [build-ctc-decoder-Linux, build-ctc-decoder-macos, build-ctc-decoder-windows]
needs: [create-release, build-ctc-decoder-Linux, build-ctc-decoder-macos, build-ctc-decoder-windows]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
@ -1072,13 +1120,12 @@ jobs:
with:
name: '' # use filename
path: "*.whl"
release-tag: ${{ steps.get-tag.outputs.tag }}
should-create-release: true
release-tag: ${{ needs.create-release.outputs.release-tag }}
npmjs-publish:
name: "Upload STT packages to npmjs.com"
runs-on: ubuntu-20.04
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
needs: [repackage-nodejs-allplatforms]
needs: [create-release, repackage-nodejs-allplatforms]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
@ -1119,8 +1166,7 @@ jobs:
with:
name: '' # use filename
path: "*.tgz"
release-tag: ${{ steps.get-tag.outputs.tag }}
should-create-release: true
release-tag: ${{ needs.create-release.outputs.release-tag }}
# macOS jobs
swig_macOS:
name: "Mac|Build SWIG"
@ -3363,10 +3409,6 @@ jobs:
with:
name: "native_client.tflite.android.armv7.tar.xz"
path: ${{ github.workspace }}/artifacts/native_client.tar.xz
- uses: actions/upload-artifact@v2
with:
name: "libstt.tflite.android.armv7.zip"
path: ${{ github.workspace }}/artifacts/libstt.zip
tensorflow_opt-AndroidArm64:
name: "AndroidArm64|Check TensorFlow cache"
runs-on: ubuntu-20.04
@ -3439,7 +3481,114 @@ jobs:
with:
name: "native_client.tflite.android.arm64.tar.xz"
path: ${{ github.workspace }}/artifacts/native_client.tar.xz
build-lib_Androidx86_64:
name: "Androidx86_64|Build libstt+client"
runs-on: ubuntu-20.04
needs: [ build-tensorflow-AndroidArm64, tensorflow_opt-AndroidArm64 ]
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: ./.github/actions/check_artifact_exists
with:
name: ${{ needs.tensorflow_opt-AndroidArm64.outputs.cache_key }}.tar.xz
path: ${{ github.workspace }}/
download: true
- run: |
tar --skip-old-files -xf ${{ needs.tensorflow_opt-AndroidArm64.outputs.cache_key }}.tar.xz
rm ${{ needs.tensorflow_opt-AndroidArm64.outputs.cache_key }}.tar.xz
- uses: ./.github/actions/libstt-build
with:
arch: android-x86_64
- run: ./ci_scripts/android-package.sh x86_64
- uses: actions/upload-artifact@v2
with:
name: "libstt.tflite.android.arm64.zip"
path: ${{ github.workspace }}/artifacts/libstt.zip
name: "native_client.tflite.android.x86_64.tar.xz"
path: ${{ github.workspace }}/artifacts/native_client.tar.xz
build-android-apk-aar:
name: "Android|Build AAR+APK"
runs-on: ubuntu-20.04
needs: [build-lib_AndroidArmv7, build-lib_AndroidArm64, build-lib_Androidx86_64]
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: actions/download-artifact@v2
with:
name: native_client.tflite.android.armv7.tar.xz
path: /tmp/nc
- run: |
mkdir -p native_client/java/libstt/libs/armeabi-v7a
cd /tmp/nc
tar xvf native_client.tar.xz
mv libstt.so ${CI_TASK_DIR}/native_client/java/libstt/libs/armeabi-v7a/libstt.so
rm -f *
- uses: actions/download-artifact@v2
with:
name: native_client.tflite.android.arm64.tar.xz
path: /tmp/nc
- run: |
mkdir -p native_client/java/libstt/libs/arm64-v8a
cd /tmp/nc
tar xvf native_client.tar.xz
mv libstt.so ${CI_TASK_DIR}/native_client/java/libstt/libs/arm64-v8a/libstt.so
rm -f *
- uses: actions/download-artifact@v2
with:
name: native_client.tflite.android.x86_64.tar.xz
path: /tmp/nc
- run: |
mkdir -p native_client/java/libstt/libs/x86_64
cd /tmp/nc
tar xvf native_client.tar.xz
mv libstt.so ${CI_TASK_DIR}/native_client/java/libstt/libs/x86_64/libstt.so
rm -f *
- name: Use Java 8 instead of Java 11
run: echo "JAVA_HOME=$JAVA_HOME_8_X64" >> $GITHUB_ENV
# This particular version of CMake confuses Gradle by not being semver.
# We're fine with 3.10.2 which is also installed. Keep an eye on the
# virtual environments though:
# https://github.com/actions/virtual-environments/blob/main/images/macos/macos-10.15-Readme.md#android
- name: Remove CMake 3.18.1-g262b901
run: |
${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager --uninstall 'cmake;3.18.1'
- run: |
make GRADLE="./gradlew " -C native_client/java
- run: |
make GRADLE="./gradlew " -C native_client/java maven-bundle
- uses: actions/upload-artifact@v2
with:
name: "app.apk"
path: ${{ github.workspace }}/native_client/java/app/build/outputs/apk/release/app*.apk
- uses: actions/upload-artifact@v2
with:
name: "libstt.aar"
path: ${{ github.workspace }}/native_client/java/libstt/build/outputs/aar/libstt*.aar
- uses: actions/upload-artifact@v2
with:
name: "libstt.maven.zip"
path: ${{ github.workspace }}/native_client/java/libstt/build/libstt-*.maven.zip
publish-android-aar:
name: "Android|Publish AAR"
runs-on: ubuntu-20.04
needs: [create-release, build-android-apk-aar]
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: actions/download-artifact@v2
with:
name: "libstt.aar"
path: ${{ github.workspace }}/
- run: ls -lh
- name: Get tag name
id: get-tag
run: |
tag=$(echo "${{ github.ref }}" | sed -e 's|^refs/tags/||')
echo "::set-output name=tag::$tag"
- uses: ./.github/actions/upload-release-asset
with:
name: '' # use filename
path: "*.aar"
release-tag: ${{ needs.create-release.outputs.release-tag }}

0
RELEASE_NOTES.md Normal file
View File

View File

@ -126,7 +126,7 @@ Included are a set of generated Python bindings. After following the above build
make bindings
pip install dist/stt-*
The API mirrors the C++ API and is demonstrated in `client.py <python/client.py>`_. Refer to `coqui-stt.h <coqui-stt.h>`_ for documentation.
`Reference documentation <python-api>`_ is available for the Python bindings, as well as examples in the `STT-examples repository <https://github.com/coqui-ai/STT-examples>`_ and the `source code for the CLI tool installed alongside the Python bindings <py-api-example>`_.
Install NodeJS / ElectronJS bindings
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -186,7 +186,7 @@ Cross-building
RPi3 ARMv7 and LePotato ARM64
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
We do support cross-compilation. Please refer to our ``coqui-ai/tensorflow`` fork, where we define the following ``--config`` flags:
We support cross-compilation from Linux hosts. The following ``--config`` flags can be specified when building with bazel:
* ``--config=rpi3_opt`` for Raspbian / ARMv7
* ``--config=rpi3-armv8_opt`` for ARMBian / ARM64
@ -213,28 +213,8 @@ The path of the system tree can be overridden from the default values defined in
cd ../STT/native_client
make TARGET=<system> stt
Android devices support
-----------------------
Using the library from Android project
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Due to the discontinuation of Bintray JCenter we do not have pre-built Android packages published for now. We are working to move to Maven Central and will update this section when it's available.
.. We provide uptodate and tested ``libstt`` usable as an ``AAR`` package,
for Android versions starting with 7.0 to 11.0. The package is published on
`JCenter <https://bintray.com/coqui/ai.coqui.stt/libstt>`_,
and the ``JCenter`` repository should be available by default in any Android
project. Please make sure your project is setup to pull from this repository.
You can then include the library by just adding this line to your
``gradle.build``, adjusting ``VERSION`` to the version you need:
.. code-block::
implementation 'stt.coqui.ai:libstt:VERSION@aar'
Building ``libstt.so`` for Android
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
----------------------------------
Prerequisites
^^^^^^^^^^^^^

View File

@ -13,8 +13,8 @@ Creating a model instance and loading model
:start-after: sphinx-doc: c_ref_model_start
:end-before: sphinx-doc: c_ref_model_stop
Deploying trained model
-----------------------
Transcribing audio with the loaded model
----------------------------------------
.. literalinclude:: ../native_client/client.cc
:language: c

View File

@ -14,6 +14,7 @@ You can deploy 🐸STT models either via a command-line client or a language bin
* :ref:`The Python package + language binding <py-usage>`
* :ref:`The Node.JS package + language binding <nodejs-usage>`
* :ref:`The Android libstt AAR package <android-usage>`
* :ref:`The command-line client <cli-usage>`
* :ref:`The native C API <c-usage>`
@ -133,6 +134,31 @@ See the `release notes <https://github.com/coqui-ai/STT/releases>`_ to find whic
See the :ref:`TypeScript client <js-api-example>` for an example of how to use the bindings programatically.
.. _android-usage:
Using the Android AAR libstt package
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
A pre-built ``libstt`` Android AAR package can be downloaded from GitHub Releases, for Android versions 7.0+. In order to use it in your Android application, first modify your app's ``build.gradle`` file to add a local dir as a repository. In the ``repository`` section, add the following definition:
.. code-block:: groovy
repositories {
flatDir {
dirs 'libs'
}
}
Then, create a libs directory inside your app's folder, and place the libstt AAR file there. Finally, add the following dependency declaration in your app's ``build.gradle`` file:
.. code-block:: groovy
dependencies {
implementation fileTree(dir: 'libs', include: ['*.aar'])
}
This will link all .aar files in the ``libs`` directory you just created, including libstt.
.. _cli-usage:
Using the command-line client

View File

@ -13,8 +13,8 @@ Creating a model instance and loading model
:start-after: sphinx-doc: csharp_ref_model_start
:end-before: sphinx-doc: csharp_ref_model_stop
Deploying trained model
-----------------------
Transcribing audio with the loaded model
----------------------------------------
.. literalinclude:: ../native_client/dotnet/STTConsole/Program.cs
:language: csharp

View File

@ -13,8 +13,8 @@ Creating a model instance and loading model
:start-after: sphinx-doc: java_ref_model_start
:end-before: sphinx-doc: java_ref_model_stop
Deploying trained model
-----------------------
Transcribing audio with the loaded model
----------------------------------------
.. literalinclude:: ../native_client/java/app/src/main/java/ai/coqui/sttexampleapp/STTActivity.java
:language: java

View File

@ -15,8 +15,8 @@ Creating a model instance and loading model
:start-after: sphinx-doc: js_ref_model_start
:end-before: sphinx-doc: js_ref_model_stop
Deploying trained model
-----------------------
Transcribing audio with the loaded model
----------------------------------------
.. literalinclude:: ../native_client/javascript/client.ts
:language: javascript

View File

@ -1,3 +1,5 @@
.. _python-api:
Python
======

View File

@ -15,8 +15,8 @@ Creating a model instance and loading model
:start-after: sphinx-doc: python_ref_model_start
:end-before: sphinx-doc: python_ref_model_stop
Deploying trained model
-----------------------
Transcribing audio with the loaded model
----------------------------------------
.. literalinclude:: ../native_client/python/client.py
:language: python

View File

@ -1,4 +1,4 @@
package ai.coqui.sttexampleapp
package ai.coqui.sttexampleapp;
import android.content.Context;
import android.support.test.InstrumentationRegistry;

View File

@ -1,4 +1,4 @@
package ai.coqui.sttexampleapp
package ai.coqui.sttexampleapp;
import org.junit.Test;

View File

@ -15,8 +15,8 @@ public class STTModel {
private SWIGTYPE_p_ModelState _msp;
private void evaluateErrorCode(int errorCode) {
STT_Error_Codes code = STT_Error_Codes.swigToEnum(errorCode);
if (code != STT_Error_Codes.ERR_OK) {
Error_Codes code = Error_Codes.swigToEnum(errorCode);
if (code != Error_Codes.ERR_OK) {
throw new RuntimeException("Error: " + impl.ErrorCodeToErrorMessage(errorCode) + " (0x" + Integer.toHexString(errorCode) + ").");
}
}