Update doc for TypeScript support

This commit is contained in:
Alexandre Lissy 2020-04-06 11:35:13 +02:00
parent 3581bdf9fe
commit 5723dba180
4 changed files with 13 additions and 20 deletions

View File

@ -1,6 +1,8 @@
JavaScript (NodeJS / ElectronJS) JavaScript (NodeJS / ElectronJS)
================================ ================================
Support for TypeScript is :download:`provided in index.d.ts<../native_client/javascript/index.d.ts>`
Model Model
----- -----

View File

@ -4,20 +4,20 @@ JavaScript API Usage example
Creating a model instance and loading model Creating a model instance and loading model
------------------------------------------- -------------------------------------------
.. literalinclude:: ../native_client/javascript/client.js .. literalinclude:: ../native_client/javascript/client.ts
:language: javascript :language: javascript
:linenos: :linenos:
:lines: 56,69 :lines: 49,54
Performing inference Performing inference
-------------------- --------------------
.. literalinclude:: ../native_client/javascript/client.js .. literalinclude:: ../native_client/javascript/client.ts
:language: javascript :language: javascript
:linenos: :linenos:
:lines: 122 :lines: 114,118
Full source code Full source code
---------------- ----------------
See :download:`Full source code<../native_client/javascript/client.js>`. See :download:`Full source code<../native_client/javascript/client.ts>`.

View File

@ -125,6 +125,8 @@ Please note that as of now, we support:
- Node.JS versions 4 to 13. - Node.JS versions 4 to 13.
- Electron.JS versions 1.6 to 7.1 - 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: Alternatively, if you're using Linux and have a supported NVIDIA GPU, you can install the GPU specific package as follows:
.. code-block:: bash .. 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 <https://github.com/mozilla/DeepSpeech/releases>`_ to find which GPUs are supported. Please ensure you have the required `CUDA dependency <#cuda-dependency>`_. See the `release notes <https://github.com/mozilla/DeepSpeech/releases>`_ to find which GPUs are supported. Please ensure you have the required `CUDA dependency <#cuda-dependency>`_.
See :github:`client.js <native_client/javascript/client.js>` for an example of how to use the bindings. See :github:`client.ts <native_client/javascript/client.ts>` for an example of how to use the bindings.
Using the Command-Line client Using the Command-Line client
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

View File

@ -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`. You can generate the TypeScript type declaration file using `dts-gen`.
This requires a compiled/installed version of the DeepSpeech NodeJS client. 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 ```sh
npm install -g dts-gen npm install -g dts-gen
@ -14,16 +15,4 @@ dts-gen --module deepspeech --file index.d.ts
### Example usage ### Example usage
```javascript See `client.ts`
/// 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);
```