Skip to content

Commit

Permalink
Update doc for TypeScript support
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexandre Lissy committed Apr 6, 2020
1 parent 3581bdf commit 5723dba
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 20 deletions.
2 changes: 2 additions & 0 deletions doc/NodeJS-API.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
JavaScript (NodeJS / ElectronJS)
================================

Support for TypeScript is :download:`provided in index.d.ts<../native_client/javascript/index.d.ts>`

Model
-----

Expand Down
10 changes: 5 additions & 5 deletions doc/NodeJS-Examples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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>`.
4 changes: 3 additions & 1 deletion doc/USING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 :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
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
17 changes: 3 additions & 14 deletions native_client/javascript/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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`

0 comments on commit 5723dba

Please sign in to comment.