Text to Speech Plugin Tutorial


#1

Repo: https://github.com/bradmartin/egghead-text-to-speech


#2

if i have 2 text to speech engine how to set it to google. so user dont need to change it manually


#3

what do you mean by ‘set to google’?


#4

sorry for late reply. i meant i change this code

TNSTextToSpeech.prototype.init = function () {
        var _this = this;
        return new Promise(function (resolve, reject) {
            if (!_this._tts || !_this._initialized) {
                _this._tts = new android.speech.tts.TextToSpeech(_this._getContext(), new android.speech.tts.TextToSpeech.OnInitListener({
                    onInit: function (status) {
                        // if the TextToSpeech was successful initializing
                        if (status === android.speech.tts.TextToSpeech.SUCCESS) {
                            _this._initialized = true;
                            _this._tts.setOnUtteranceProgressListener(new _this._utteranceProgressListener());
                            resolve();
                        }
                        else {
                            reject(status);
                        }
                    }
                }));
            }
            else {
                resolve();
            }
        });
    };

into

TNSTextToSpeech.prototype.init = function () {
        var _this = this;
        return new Promise(function (resolve, reject) {
            if (!_this._tts || !_this._initialized) {
                _this._tts = new android.speech.tts.TextToSpeech(_this._getContext(), new android.speech.tts.TextToSpeech.OnInitListener({
                    onInit: function (status) {
                        // if the TextToSpeech was successful initializing
                        if (status === android.speech.tts.TextToSpeech.SUCCESS) {
                            _this._initialized = true;
                            _this._tts.setOnUtteranceProgressListener(new _this._utteranceProgressListener());
                            resolve();
                        }
                        else {
                            reject(status);
                        }
                    }
                }),'com.google.android.tts');
            }
            else {
                resolve();
            }
        });
    };

so by default this plugin will use google text to speech. Thanks.