1'use strict';
2
3const EventEmitter = require('events');
4
5module.exports = new class TTSSystem extends EventEmitter {
6    constructor(){
7        super();
8        this._onState();
9    }
10
11    play(content, encode) {
12        if (!content) {
13            throw new Error('invalid params');
14        }
15        return __native.TTS.play(content, encode);
16    };
17
18    stop() {
19        return __native.TTS.stop();
20    };
21
22    getState() {
23        return __native.TTS.getState();
24    };
25
26    _onState() {
27        __native.TTS.onState(function(state) {
28            this.emit('state', state);
29        }.bind(this));
30    };
31
32    setPitch(type) {
33        if (!type) {
34            throw new Error('invalid params');
35        }
36        return __native.TTS.setPitch(type);
37    };
38
39    setSpeed(speed) {
40        if (!speed) {
41            throw new Error('invalid params');
42        }
43        return __native.TTS.setSpeed(speed);
44    };
45
46    getSpeed() {
47        return __native.TTS.getSpeed();
48    };
49
50    setVolume(volume) {
51        if (!volume) {
52            throw new Error('invalid params');
53        }
54        return __native.TTS.setVolume(volume);
55    };
56
57    getVolume() {
58        return __native.TTS.getVolume();
59    };
60}
61