Giter VIP home page Giter VIP logo

react-native-tts's Introduction

React Native TTS

React Native TTS is a text-to-speech library for React Native on iOS, Android and Windows.

Documentation

Install

npm install --save react-native-tts

Usage

Imports

import Tts from 'react-native-tts';

Windows

  1. In windows/myapp.sln add the RNTTS project to your solution:

    • Open the solution in Visual Studio 2019
    • Right-click Solution icon in Solution Explorer > Add > Existing Project
    • Select node_modules\react-native-tts\windows\RNTTS\RNTTS.vcxproj
  2. In windows/myapp/myapp.vcxproj add a reference to RNTTS to your main application project. From Visual Studio 2019:

    • Right-click main application project > Add > Reference...
    • Check RNTTS from Solution Projects.
  3. In pch.h add #include "winrt/RNTTS.h".

  4. In app.cpp add PackageProviders().Append(winrt::RNTTS::ReactPackageProvider()); before InitializeComponent();.

Speaking

Add utterance to TTS queue and start speaking. Returns promise with utteranceId.

Tts.speak('Hello, world!');

Additionally, speak() allows to pass platform-specific options.

// IOS
Tts.speak('Hello, world!', {
  iosVoiceId: 'com.apple.ttsbundle.Moira-compact',
  rate: 0.5,
});
// Android
Tts.speak('Hello, world!', {
  androidParams: {
    KEY_PARAM_PAN: -1,
    KEY_PARAM_VOLUME: 0.5,
    KEY_PARAM_STREAM: 'STREAM_MUSIC',
  },
});

For more detail on androidParams properties, please take a look at official android documentation. Please note that there are still unsupported key with this wrapper library such as KEY_PARAM_SESSION_ID. The following are brief summarization of currently implemented keys:

  • KEY_PARAM_PAN ranges from -1 to +1.

  • KEY_PARAM_VOLUME ranges from 0 to 1, where 0 means silence. Note that 1 is a default value for Android.

  • For KEY_PARAM_STREAM property, you can currently use one of STREAM_ALARM, STREAM_DTMF, STREAM_MUSIC, STREAM_NOTIFICATION, STREAM_RING, STREAM_SYSTEM, STREAM_VOICE_CALL,

The supported options for IOS are:

  • iosVoiceId which voice to use, check voices() for available values
  • rate which speech rate this line should be spoken with. Will override default rate if set for this utterance.

Stop speaking and flush the TTS queue.

Tts.stop();

Waiting for initialization

On some platforms it could take some time to initialize TTS engine, and Tts.speak() will fail to speak until the engine is ready.

To wait for successfull initialization you could use getInitStatus() call.

Tts.getInitStatus().then(() => {
  Tts.speak('Hello, world!');
});

Ducking

Enable lowering other applications output level while speaking (also referred to as "ducking").

(not supported on Windows)

Tts.setDucking(true);

List Voices

Returns list of available voices

(not supported on Android API Level < 21, returns empty list)

Tts.voices().then(voices => console.log(voices));

// Prints:
//
// [ { id: 'com.apple.ttsbundle.Moira-compact', name: 'Moira', language: 'en-IE', quality: 300 },
// ...
// { id: 'com.apple.ttsbundle.Samantha-compact', name: 'Samantha', language: 'en-US' } ]
Voice field Description
id Unique voice identifier (e.g. com.apple.ttsbundle.Moira-compact)
name Name of the voice (iOS only)
language BCP-47 language code (e.g. 'en-US')
quality Voice quality (300 = normal, 500 = enhanced/very high)
latency Expected synthesizer latency (100 = very low, 500 = very high) (Android only)
networkConnectionRequired True when the voice requires an active network connection (Android only)
notInstalled True when the voice may need to download additional data to be fully functional (Android only)

Set default Language

Tts.setDefaultLanguage('en-IE');

Set default Voice

Sets default voice, pass one of the voiceId as reported by a call to Tts.voices()

(not available on Android API Level < 21)

Tts.setDefaultVoice('com.apple.ttsbundle.Moira-compact');

Set default Speech Rate

Sets default speech rate. The rate parameter is a float where where 0.01 is a slowest rate and 0.99 is the fastest rate.

Tts.setDefaultRate(0.6);

There is a significant difference to how the rate value is interpreted by iOS, Android and Windows native TTS APIs. To provide unified cross-platform behaviour, translation is applied to the rate value. However, if you want to turn off the translation, you can provide optional skipTransform parameter to Tts.setDefaultRate() to pass rate value unmodified.

Do not translate rate parameter:

Tts.setDefaultRate(0.6, true);

Set default Pitch

Sets default pitch. The pitch parameter is a float where where 1.0 is a normal pitch. On iOS min pitch is 0.5 and max pitch is 2.0. On Windows, min pitch is 0.0 and max pitch is 2.0.

Tts.setDefaultPitch(1.5);

Controls the iOS silent switch behavior

Platforms: iOS

  • "inherit" (default) - Use the default behavior
  • "ignore" - Play audio even if the silent switch is set
  • "obey" - Don't play audio if the silent switch is set
Tts.setIgnoreSilentSwitch("ignore");

Events

Subscribe to TTS events

Tts.addEventListener('tts-start', (event) => console.log("start", event));
Tts.addEventListener('tts-progress', (event) => console.log("progress", event));
Tts.addEventListener('tts-finish', (event) => console.log("finish", event));
Tts.addEventListener('tts-cancel', (event) => console.log("cancel", event));

Support for multiple TTS engines

Platforms: Android

Functions to list available TTS engines and set an engine to use.

Tts.engines().then(engines => console.log(engines));
Tts.setDefaultEngine('engineName');

Install (additional) language data

Shows the Android Activity to install additional language/voice data.

Tts.requestInstallData();

Troubleshooting

No text to speech engine installed on Android

On Android, it may happen that the Text-to-Speech engine is not (yet) installed on the phone. When this is the case, Tts.getInitStatus() returns an error with code no_engine. You can use the following code to request the installation of the default Google Text to Speech App. The app will need to be restarted afterwards before the changes take affect.

Tts.getInitStatus().then(() => {
  // ...
}, (err) => {
  if (err.code === 'no_engine') {
    Tts.requestInstallEngine();
  }
});

Example

There is an example project which shows use of react-native-tts on Android/iOS/Windows: https://github.com/themostaza/react-native-tts-example

License

The MIT License (MIT)

Copyright © 2016 Anton Krasovsky

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

react-native-tts's People

Contributors

ak1394 avatar andtos90 avatar bcye avatar brunocicciarello-tomtom avatar felipecespedes avatar fnazarios avatar fredlemieux avatar fungilation avatar guhyeon77 avatar gyran avatar ijzerenhein avatar jaimecbernardo avatar jmfirth avatar kamwong3 avatar lfkwtz avatar liviu-padurariu avatar maslianok avatar mateus-brito avatar ohtangza avatar philharton avatar phuongwd avatar re7eal avatar rraallvv avatar slycoder avatar tritao avatar walterholohan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

react-native-tts's Issues

[Android 7+] Tts.setDefaultLanguage makes my app really slow

When I navigate to a screen where Tts.setDefaultLanguage('nl-NL'); is used, it takes a few seconds to really navigate to that screen... So Tts.setDefaultLanguage('nl-NL'); makes my app really really really slow...

I have seen this on Android 7.0 and Android 7.1 (lower not seen, higher not tested). Not on Android 4.5

Error after install

Hi, the installation when Ok but when I run the app I get the red screen with the following error:

Native module TextToSpeechModule tried to override TextToSpeechModule for module name TextToSpeech. If this was your intention, return true from TextToSpeechModule#canOverrideExistingModule()

Thanks, Railton.

AVSpeechSynthesizer does not speak after using SFSpeechRecognizer

Hi,

When I use your TTS library and then use a different library with SFSpeechRecognizer that uses audioSession setCategory:AVAudioSessionCategoryRecord... and then I try to use your TTS library again... it doesn't seem to work.

It seems as though the audioSession's Category is still set to AVAudioSessionCategoryRecord.

Do you know if there is a way to reset the audioSession's category to AVAudioSessionCategoryPlayback before running your Tts.speak method or any other way to get your library to work after/before using SFSpeechRecognizer

Thanks.

Highlight text with tts

Its useful us but I need to also highlight text when speak, how should I do.

Any solution.

TTS.voices() failed error collection == null

Hi.awesome lib. I use this with Android 5.1 platform and found that when I try to invoke:

TTS.voices().then(voices=>console.log(voices));

it gives me an error that collection == null ;

How to solve this ? and BTW, is this lib support Chinese Simplified language ?

RN Version: 0.46.4

Lint errors [Android]

This support library should not use a different version (24) than the compileSdkVersion (23)

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.1"

    defaultConfig {
        minSdkVersion 16
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.android.support:support-v4:24.0.0'
    compile 'com.android.support:appcompat-v7:23.4.0'
    compile 'com.facebook.react:react-native:+'
}

Switching from English to Spanish

Using AVD which is emulating android 6.0, API 32, Intel Atom (x86_64)
"react": "15.4.2",
"react-native": "^0.38.0",
"react-native-tts": "0.4.0"

Steps to reproduce
Tts.setDefaultLanguage('en-US')
Tts.speak('text')
Tts.setDefaultLanguage('es-ES)

I get the alert: Unfortunately, Pico TTS has stopped. After the initial alert, the spanish version will play. However, if I switch back and forth a couple of times, it stops working and causes this error in the debugger:
Possible Unhandled Promise Rejection (id: 0):unable to play
Error: unable to play
at createErrorFromErrorData (http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=true&minify=false:22591:11)
at http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=true&minify=false:22554:35
at MessageQueue.__invokeCallback (http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=true&minify=false:22940:10)
at http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=true&minify=false:22792:8
at guard (http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=true&minify=false:22711:1)
at MessageQueue.invokeCallbackAndReturnFlushedQueue (http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=true&minify=false:22791:1)
at http://localhost:8081/debuggerWorker.js:71:58

TextToSpeech was walled with 1 arguments IOS

I have this error only on IOS:

TextToSpeech. was called with 1 arguments but expects 2 arguments. If you haven't changed this method yourself, this usually means that your versions of the native code and JavaScript are out of sync. Updating both should make this error go.

Otherwise in Android is working fine.

Thanks.

Undefined is not an object (evaluating 'TextToSpeech.speak')

import React from 'react';
import { StyleSheet, View, TouchableHighlight, Image } from 'react-native';
import Tts from 'react-native-tts';

export default class App extends React.Component {
  constructor(props) {
    super(props);
    this._pressConfig = this._pressConfig.bind(this);
    this._pressPlay = this._pressPlay.bind(this);
  }
  _pressConfig() {
    console.log("pressed");
  }
  _pressPlay() {
    Tts.speak("Hello world");
  }
  render() {
    return (
      <View style={styles.container}>
        <View style={styles.navigation}>
          <TouchableHighlight onPress={this._pressConfig}>
            <Image source={require('./App/img/img_hamburger.png')}
              style={{ width: 30, height: 30 }} />
          </TouchableHighlight>
        </View>
        <View style={styles.content}>
          <TouchableHighlight onPress={this._pressPlay}>
            <Image source={require('./App/img/img_play.png')}
              style={{ width: 100, height: 100 }} />
          </TouchableHighlight>
        </View>
      </View>
    );
  }
}

this is my App.js file, I tried react-native link after installing 'react-native-tts' but it seems not to work.
my package.json file:

"all": "0.0.0",
    "expo": "^20.0.0",
    "lottie-react-native": "~1.1.1",
    "module": "^1.2.5",
    "react": "16.0.0-alpha.12",
    "react-native": "^0.47.2",
    "react-native-side-menu": "^1.0.2",
    "react-native-tts": "^1.4.0"

anyone has any ideas?

Build fails with React-Native v0.35 for iOS

Hi,

Running the build with react-native v0.35.0 and the TTS library seems to fails for iOS:

$ react-native run-ios
...
The following build commands failed:
	CompileC /Users/Me/Projects/MyProject/ios/build/Build/Intermediates/TextToSpeech.build/Release-iphonesimulator/TextToSpeech.build/Objects-normal/i386/TextToSpeech.o TextToSpeech/TextToSpeech.m normal i386 objective-c com.apple.compilers.llvm.clang.1_0.compiler
	CompileC /Users/Me/Projects/MyProject/ios/build/Build/Intermediates/TextToSpeech.build/Release-iphonesimulator/TextToSpeech.build/Objects-normal/x86_64/TextToSpeech.o TextToSpeech/TextToSpeech.m normal x86_64 objective-c com.apple.compilers.llvm.clang.1_0.compiler
(2 failures)

X-Code

// React/RCTBridge.h file not found in TextToSpeech.m

#import <React/RCTBridge.h>

What are the requirements for running the TTS library for iOS?

Not able to remove event listener

I added an event listener for tts-finish event and i am removing it in componentwillunmount method but still its subscribed to the event.Is there something i need to do extra?

App crashes without errors

I'm having a strange error after installing react-native-tts. The run-android command builds up completely. However when I try to run the app (on physical android device) it crashes without any warning/errors. Neither errors on the debugger-ui. Any idea what it could be?

First call of Tts.speak() takes lots of time to fire tts-start event

Hello,

First of all, thank you very much for all that work.

On react-native 0.49.5, I'm trying to make my bot speak using your library. I first call Tts.speak("some sentence") once my components are mounted and I call it again a few times later. The first call of the function returns the promise immediately, but it doesn't fire the tts-start event and the voice only plays after 20-30 seconds. Whereas after those 30 seconds, calling Tts.speak() fires the tts-start event right away and the bot speaks just after the function call.

I'm running the react-native app on Android 7.0.

Am I missing something ?

Audio when app is in background

Thanks for this great library, works great in my app.

Is there a way to get this library to work while app is in background, so speech continues without app interactivity, when multiple paragraphs have already been queued in the TTS library? I see other audio libraries that can play in background, but those are not for TTS, only audio streaming from remote sources.

Any direction is appreciated for having queued TTS playing in background.

Dutch language on Android

Hi,
I really love your package, and it works great. My problem is that Dutch is available on iOS but not on Android, is there a way to add a new language to the android languages?
If not, any suggestions what I could do?

Android tts rate doesn't calculated properly

The speed of tts is very important for us.
That's why we made some investigation on this. And here are our results:
unnamed

As you can see, the max rate for Android is ~5. The max rate that we can currently set with help of this library is 3. It's almost twice less...

Moreover, the max rate may differ between different voices.

That's why I would ask you to remove this smart transformation from iOS to Android rate.
Or, maybe, it would be better to add the third parameter to the setDefaultRate method. Something like dontTransform or whatever...

Audio ducking support

Hi, I was wondering what your thoughts are on this. I need background audio to be ducked when text-to-speech is played, and unducked when the utterance is finished. Currently on iOS any background audio is paused and never resumed when usibng react-native-tts. I've already got ducking and audio resume working for iOS, but before I start working on the Android I was thinking what your thoughts are on this.

Should ducking be part of this library, or something that should be build externally using the events that are emitted by this library? A penny for your thoughts.

cheers,
Hein

Critical error when trying to list voices?

Hey man, awesome library. Everything was going awesome till I upgraded to RN 0.50, then suddenly my app crashes whenever I call the voices() method. I checked my logs and found the following:

Exception '-[AVSpeechSynthesisVoice identifier]: unrecognized selector sent to instance 0x7ffc1d4c3ff0' was thrown while invoking voices on target TextToSpeech with params (
	    6746,
	    6747
	)
	callstack: (
		0   CoreFoundation                      0x000000010d676f35 __exceptionPreprocess + 165
		1   libobjc.A.dylib                     0x000000010c7d2bb7 objc_exception_throw + 45
		2   CoreFoundation                      0x000000010d67e04d -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
		3   CoreFoundation                      0x000000010d5d627c ___forwarding___ + 988
		4   CoreFoundation                      0x000000010d5d5e18 _CF_forwarding_prep_0 + 120
		5   Linguistic                          0x000000010be3d61c -[TextToSpeech voices:reject:] + 476
		6   CoreFoundation                      0x000000010d56ec8c __invoking___ + 140
		7   CoreFoundation                      0x000000010d56eae2 -[NSInvocation invoke] + 290
		8   CoreFoundation                      0x000000010d5fded6 -[NSInvocation invokeWithTarget:] + 54
		9   Linguistic                          0x000000010bca4c0c -[RCTModuleMethod invokeWithBridge:module:arguments:] + 2796
		10  Linguistic                          0x000000010bd3b582 _ZN8facebook5reactL11invokeInnerEP9RCTBridgeP13RCTModuleDatajRKN5folly7dynamicE + 786
		11  Linguistic                          0x000000010bd3b0af _ZZN8facebook5react15RCTNativeModule6invokeEjON5folly7dynamicEiENK3$_0clEv + 127
		12  Linguistic                          0x000000010bd3b029 ___ZN8facebook5react15RCTNativeModule6invokeEjON5folly7dynamicEi_block_invoke + 25
		13  libdispatch.dylib                   0x000000011045aaf6 _dispatch_call_block_and_release + 12
		14  libdispatch.dylib                   0x0000000110474af4 _dispatch_client_callout + 8
		15  libdispatch.dylib                   0x000000011045f8cf _dispatch_queue_drain + 733
		16  libdispatch.dylib                   0x000000011045f494 _dispatch_queue_invoke + 217
		17  libdispatch.dylib                   0x00000001104613fa _dispatch_root_queue_drain + 479
		18  libdispatch.dylib                   0x00000001104622c9 _dispatch_worker_thread3 + 98
		19  libsystem_pthread.dylib             0x00000001107e71ca _pthread_wqthread + 1387
		20  libsystem_pthread.dylib             0x00000001107e6c4d start_wqthread + 13
	)

which, from the looks of things, is coming from this line:

[voices addObject:@{@"id": voice.identifier, @"name": voice.name, @"language": voice.language}];

It seems like it can't find identifier as a property of the voice object, despite it being listed in the official docs. I'd try to fix it myself, but seeing it deals with native code I'm not even sure where I'd begin debugging it. Any idea what might be responsible for it?

all the even listener cannot remove

componentWillMount () {
    Tts.addEventListener('tts-start', (event) => console.log("start"))
}

componentWillUnmount () {  
Tts.removeEventListener('tts-start');
}

the event listener does not remove properly~

Is talking status?

First, thanks for you library ! very usefull
I just ask, if it's possible to know if the voice currently talking or not?

Text speed

Hi, great package !

Would it be possible to change te the speed at will ?

In TextToSpeech.m, after that :

if ( voice ) {
	utterance.voice = [ AVSpeechSynthesisVoice voiceWithIdentifier: voice ];
} else if ( _defaultVoice ) {
	utterance.voice = _defaultVoice;
}

You can add

if ( rate ) {
	utterance.rate = [ rate doubleValue ];
}

And for android it’s going to be tts.setPitch(rate); as far as I understand.

:react-native-tts:compileReleaseJavaWithJavac - is not incremental (e.g. outputs have changed, no previous execution, etc.).

I get the following error while I am running "react-native run-android"

:react-native-tts:compileReleaseJavaWithJavac
:react-native-tts:compileReleaseJavaWithJavac - is not incremental (e.g. outputs have changed, no previous execution, etc.).
注: D:\ENtest\node_modules\react-native-tts\android\src\main\java\net\no_mad\tts\TextToSpeechModule.java使用或覆盖了已过时的 API。
注: 有关详细信息, 请使用 -Xlint:deprecation 重新编译。
注: D:\ENtest\node_modules\react-native-tts\android\src\main\java\net\no_mad\tts\TextToSpeechModule.java使用了未经检查或不安全的操作。
注: 有关详细信息, 请使用 -Xlint:unchecked 重新编译。

Error: TTS not ready in Android

Works on IOS emulator but get the "Error: TTS not ready" on Android (tried both simulator as well as device with same result).

I have verified that TTS works when tested under settings on emulator as well as device.

Android emulator version: 8.0.0
Device version: 7.1.2

the error in console log:

blob:http://localhost:8081/463ce249-4719-4e5f-ad7d-a2f63dc584b8:sourcemap:53509 Possible Unhandled Promise Rejection (id: 0):
Error: TTS is not ready
Error: TTS is not ready
    at createErrorFromErrorData (blob:http://localhost:8081/463ce249-4719-4e5f-ad7d-a2f63dc584b8:2023:17)
    at blob:http://localhost:8081/463ce249-4719-4e5f-ad7d-a2f63dc584b8:1975:27
    at MessageQueue.__invokeCallback (blob:http://localhost:8081/463ce249-4719-4e5f-ad7d-a2f63dc584b8:2417:18)
    at blob:http://localhost:8081/463ce249-4719-4e5f-ad7d-a2f63dc584b8:2162:18
    at MessageQueue.__guardSafe (blob:http://localhost:8081/463ce249-4719-4e5f-ad7d-a2f63dc584b8:2330:11)
    at MessageQueue.invokeCallbackAndReturnFlushedQueue (blob:http://localhost:8081/463ce249-4719-4e5f-ad7d-a2f63dc584b8:2161:14)
    at http://localhost:8081/debugger-ui/debuggerWorker.js:72:58

Audio continues after app is manually closed

Hi @ak1394 thanks for the great job with this library, I'am testing it and I can automatically stop the audio if the user leave the current View with componentWillUnmount as you can check here:

componentWillUnmount(){
    Tts.stop();
  }

However, if the user switch to another app or force to close the app, the sounds continue until the entire text is completely readed. Is there any option to avoid this behavior?

Build fails with react native 0.39

After linking the library to my xcode project, it fails to build with error:
React/RCTBridge.h file not found from TextToSpeech.m library.
and simulator shows error "Native module can't be null".

React Native version: 0.39.2

minSdkVersion incompatible with React Native 0.41.2

This package has a minSdkVersion=15 build.gradle, however React Native 0.41.2 won't work with less than 16, and the gradle will not sync, giving an AndroidManifest merge error. I tried to override the requirement but that did not work (RN possibly has GradleOverrides set).

If I change the minSdkVersion in this package to 16, gradle syncs

'Node module cannot be null' error

After adding this, I got the error 'Node module cannot be null'. Stack trace mentions Tts.NativeEventEmitter as the error source. I don't get the error if I'm not importing/using Tts anywhere. I'm on React-Native 44.2.

does not build with RN 0.40 (iOS)

Due to this : https://github.com/facebook/react-native/releases

After e1577df, Native code on iOS must refer to headers out of the react namespace. Previously the following would work:

#import "RCTUtils.h"

But now all headers have been moved:

#import <React/RCTUtils.h>

Solution here : in TextToSpeech.m, line 9, replace #import "RCTBridge.h" by #import <React/RCTBridge.h>

And the rest too :

#import <React/RCTBridge.h>
#import <React/RCTEventDispatcher.h>
#import <React/RCTLog.h>
#import <TextToSpeech/TextToSpeech.h>

I don’t PR because it would break builds on RN < 0.40.

Sending `tts-progress` with no listeners registered

Hi, first of all, awesomeness that you wrote this library 😃 😃 😃

I've just started using it and came across the following warnings. When I call tts.speak it shows the following warnings:

image

I don't have any listeners registered.

cheers,
Hein

Access to new Siri voice in iOS 11?

New iOS 11 came out with much more natural sounding Siri voice. However, even if the voice is installed in Settings app > General > Accessibility > Voices, for 'en-IE' only Samantha shows up from Tts.voices(). Is there any way to access the new Siri voice, if it is exposed natively?

For reference, from README:

Tts.voices().then(voices => console.log(voices));

// Prints:
//
// [ { id: 'com.apple.ttsbundle.Moira-compact', name: 'Moira', language: 'en-IE' },
// ...
// { id: 'com.apple.ttsbundle.Samantha-compact', name: 'Samantha', language: 'en-US' } ]

Couldn't subscribe to event listeneres

Hello!

I was trying to use the component and managed to set it up.
It does talk, but when I try to subscribe to events the call back is not being called, for example:
Tts.addEventListener('tts-start', (event) => { console.log("tts-start", event); dispatch({type: 'SPEECH_STARTED', payload: event}); });

Do you have any clue why this could happen?

[RN 0.49+] `requiresMainQueueSetup` needed for main queue setup, with constantsToExport

OS:

  • MacOS

Platform:

  • iOS

Console warning:

Module TextToSpeech requires main queue setup since it overrides constantsToExport but doesn't implement requiresMainQueueSetup. In a future release React Native will default to initializing all native modules on a background thread unless explicitly opted-out of.

screenshot 2017-10-10 22 18 15

react-native info:

Environment:
  OS:  macOS Sierra 10.12.6
  Node:  8.6.0
  Yarn:  1.2.0
  npm:  5.3.0
  Watchman:  4.9.0
  Xcode:  Xcode 9.0 Build version 9A235
  Android Studio:  Not Found

Packages: (wanted => installed)
  react: 16.0.0-beta.5 => 16.0.0-beta.5
  react-native: 0.49.3 => 0.49.3

Reference PR for fix

https://github.com/wix/react-native-navigation/pull/1983/files#diff-b8c48202d12fa78c4c377e5a3225c298

Removing listeners

I'm currently running into an issue where I need to remove the TTS event listeners I am creating. Unfortunately, it seems to be ignoring removeEventListeners, and adding additional instances of the event listeners, when I call "setup" again, which ultimately crashes the app.

setup() {
    Tts.addEventListener('tts-start', this.onTTSStart.bind(this));
    Tts.addEventListener('tts-finish', this.onTTSFinish.bind(this));
    Tts.addEventListener('tts-cancel', this.onTTSCancel.bind(this));
}

destroy() {
    Tts.removeEventListener('tts-start', this.onTTSStart.bind(this));
    Tts.removeEventListener('tts-finish', this.onTTSFinish.bind(this));
    Tts.removeEventListener('tts-cancel', this.onTTSCancel.bind(this));
}

Any way to add delay inline in text

Is there any way to add a delay in a string you send to the TTS engine?

e.g.
This is some content. [PAUSE for 3 seconds] This is more content.

Somewhere I thought I saw iOS supported inlining a command [[sinc 3000]]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.