Skip to content

Commit

Permalink
Merge pull request #18 from Psychopoulet/features/TSSupport
Browse files Browse the repository at this point in the history
 add ts support
  • Loading branch information
Psychopoulet committed Apr 24, 2018
2 parents a195372 + f5d8884 commit 9c2fe9a
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 9 deletions.
41 changes: 36 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ http://espeak.sourceforge.net/download.html

### Methods

* ``` getTTSSystem(void): string ("sapi"|"espeak") ```
* ``` getTTSSystem(void): "sapi" | "espeak" ```
* ``` getVoices(void): Promise<resolve<Array<Voice>>|reject<Error>> ```
* ``` isReading(void): boolean ```
* ``` read(Options|string): Promise<resolve<Options>|reject<Error>> ```
Expand All @@ -48,7 +48,7 @@ http://espeak.sourceforge.net/download.html
```javascript
interface Voice {
name: string,
gender: string ("male"|"female")
gender: "female" | "male"
}

interface Options {
Expand All @@ -62,7 +62,7 @@ interface Options {
## Examples

```javascript
const SimpleTTS = require('simpletts');
const SimpleTTS = require("simpletts");
const tts = new SimpleTTS();

tts.getVoices().then((voices) => {
Expand All @@ -75,18 +75,49 @@ tts.getVoices().then((voices) => {
});

tts.read({ "text": "this is a test", "volume": 75, "speed": 60 }).then(() => {
console.log('Ok');
console.log("Ok");
}).catch((err) => {
console.log(err);
});

tts.read("this is a test").then(() => { // is equal to { "text": "this is a test", "voice": voices[0], "volume": 100, "speed": 50 }
console.log('Ok');
console.log("Ok");
}).catch((err) => {
console.log(err);
});
```

```typescript
import SimpleTTS = require("simpletts");

interface Voice {
name: string;
gender: "female" | "male";
}

interface Options {
text: string;
volume?: number;
speed?: number;
voice?: Voice | string;
}

const tts = new SimpleTTS();

tts.getVoices().then((voices: Array<Voice>) => {

return tts.read({
"text": "test",
"voice": voices[0]
});

}).then((options: Options) => {
console.log(options);
}).catch((err: Error) => {
console.log(err);
});
```

## Tests

```bash
Expand Down
44 changes: 44 additions & 0 deletions lib/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/// <reference types="node" />

declare module "simpletts" {

import { ChildProcess } from "child_process";

namespace SimpleTTS {

interface Voice {
name: string;
gender: "female" | "male";
}

interface Options {
text: string;
volume?: number;
speed?: number;
voice?: Voice | string;
}

class SimpleTTS {

protected _forceStop: boolean;
protected _readPromise: null | Promise<Options>;

public defaultVoice: null | Voice;
public forceEspeak: boolean;
public reader: null | ChildProcess;

constructor();

public getTTSSystem(): "SAPI" | "espeak";
public getVoices(): Promise<Array<Voice>>;
public isReading(): boolean;
public read(options: Options | string): Promise<Options>;
public stopReading(): Promise<void>;

}

}

export = SimpleTTS.SimpleTTS;

}
14 changes: 10 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{
"name": "simpletts",
"version": "2.1.0",
"version": "2.2.0",
"description": "A basic TTS manager",
"main": "lib/main.js",
"typings": "lib/index.d.ts",
"scripts": {
"tests": "gulp tests"
},
Expand All @@ -21,18 +22,23 @@
"text-to-speech"
],
"author": "Sébastien VIDAL",
"contributors": [
"taffeldt",
"JDBar"
],
"license": "ISC",
"bugs": {
"url": "https://github.com/Psychopoulet/simpletts/issues"
},
"dependencies": {},
"devDependencies": {
"@types/node": "9.6.6",
"gulp": "3.9.1",
"gulp-plumber": "1.1.0",
"gulp-coveralls": "0.1.4",
"gulp-eslint": "4.0.0",
"gulp-mocha": "3.0.1",
"gulp-istanbul": "1.1.2",
"gulp-coveralls": "0.1.4",
"gulp-mocha": "3.0.1",
"gulp-plumber": "1.1.0",
"pre-commit": "1.2.2"
},
"homepage": "https://github.com/Psychopoulet/simpletts#readme",
Expand Down

0 comments on commit 9c2fe9a

Please sign in to comment.