From 5723dba1804b512f892c5117fe57526d71edead0 Mon Sep 17 00:00:00 2001 From: Alexandre Lissy Date: Mon, 6 Apr 2020 11:35:13 +0200 Subject: [PATCH] Update doc for TypeScript support --- doc/NodeJS-API.rst | 2 ++ doc/NodeJS-Examples.rst | 10 +++++----- doc/USING.rst | 4 +++- native_client/javascript/README.md | 17 +++-------------- 4 files changed, 13 insertions(+), 20 deletions(-) diff --git a/doc/NodeJS-API.rst b/doc/NodeJS-API.rst index b6170b5b..7593150c 100644 --- a/doc/NodeJS-API.rst +++ b/doc/NodeJS-API.rst @@ -1,6 +1,8 @@ JavaScript (NodeJS / ElectronJS) ================================ +Support for TypeScript is :download:`provided in index.d.ts<../native_client/javascript/index.d.ts>` + Model ----- diff --git a/doc/NodeJS-Examples.rst b/doc/NodeJS-Examples.rst index 7fe4d3b4..83b37870 100644 --- a/doc/NodeJS-Examples.rst +++ b/doc/NodeJS-Examples.rst @@ -4,20 +4,20 @@ JavaScript API Usage example Creating a model instance and loading model ------------------------------------------- -.. literalinclude:: ../native_client/javascript/client.js +.. literalinclude:: ../native_client/javascript/client.ts :language: javascript :linenos: - :lines: 56,69 + :lines: 49,54 Performing inference -------------------- -.. literalinclude:: ../native_client/javascript/client.js +.. literalinclude:: ../native_client/javascript/client.ts :language: javascript :linenos: - :lines: 122 + :lines: 114,118 Full source code ---------------- -See :download:`Full source code<../native_client/javascript/client.js>`. +See :download:`Full source code<../native_client/javascript/client.ts>`. diff --git a/doc/USING.rst b/doc/USING.rst index 55631fe8..2e357af1 100644 --- a/doc/USING.rst +++ b/doc/USING.rst @@ -125,6 +125,8 @@ Please note that as of now, we support: - Node.JS versions 4 to 13. - Electron.JS versions 1.6 to 7.1 +TypeScript support is also provided. + Alternatively, if you're using Linux and have a supported NVIDIA GPU, you can install the GPU specific package as follows: .. code-block:: bash @@ -133,7 +135,7 @@ Alternatively, if you're using Linux and have a supported NVIDIA GPU, you can in See the `release notes `_ to find which GPUs are supported. Please ensure you have the required `CUDA dependency <#cuda-dependency>`_. -See :github:`client.js ` for an example of how to use the bindings. +See :github:`client.ts ` for an example of how to use the bindings. Using the Command-Line client ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/native_client/javascript/README.md b/native_client/javascript/README.md index 9c8cd861..267fbeba 100644 --- a/native_client/javascript/README.md +++ b/native_client/javascript/README.md @@ -5,7 +5,8 @@ Full project description and documentation on GitHub: [https://github.com/mozill You can generate the TypeScript type declaration file using `dts-gen`. This requires a compiled/installed version of the DeepSpeech NodeJS client. -To generate a new `index.d.ts` type declaration file, run: +Upon API change, it is required to generate a new `index.d.ts` type declaration +file, you have to run: ```sh npm install -g dts-gen @@ -14,16 +15,4 @@ dts-gen --module deepspeech --file index.d.ts ### Example usage -```javascript -/// index.ts -import DeepSpeech from "deepspeech"; - -let modelPath = '/path/to/model'; -let model = new DeepSpeech.Model(modelPath); -model.setBeamWidth(1000); - -let audioBuffer = ...; -model.sttWithMetadata(audioBuffer); - -FreeModel(model); -``` +See `client.ts`