react-native-tts
Advanced tools
Comparing version 3.1.1 to 3.2.0
15
index.js
@@ -59,5 +59,6 @@ import { NativeModules, NativeEventEmitter, Platform } from 'react-native'; | ||
setIgnoreSilentSwitch(ignoreSilentSwitch) { | ||
if (Platform.OS === 'ios' && ignoreSilentSwitch) { | ||
if (Platform.OS === 'ios') { | ||
return TextToSpeech.setIgnoreSilentSwitch(ignoreSilentSwitch); | ||
} | ||
return Promise.resolve(true); | ||
} | ||
@@ -71,3 +72,3 @@ | ||
if (Platform.OS === 'ios') { | ||
return Promise.resolve(true); | ||
return Promise.resolve([]); | ||
} | ||
@@ -81,3 +82,3 @@ return TextToSpeech.engines(); | ||
if (Platform.OS === 'ios') { | ||
return TextToSpeech.speak(utterance, options); | ||
return TextToSpeech.speak(utterance, { iosVoiceId: options }); | ||
} else { | ||
@@ -88,3 +89,3 @@ return TextToSpeech.speak(utterance, {}); | ||
if (Platform.OS === 'ios') { | ||
return TextToSpeech.speak(utterance, options.iosVoiceId); | ||
return TextToSpeech.speak(utterance, options); | ||
} else { | ||
@@ -108,3 +109,3 @@ return TextToSpeech.speak(utterance, options.androidParams || {}); | ||
} | ||
return null; | ||
return Promise.resolve(false); | ||
} | ||
@@ -116,7 +117,7 @@ | ||
} | ||
return null; | ||
return Promise.resolve(false); | ||
} | ||
addEventListener(type, handler) { | ||
this.addListener(type, handler); | ||
return this.addListener(type, handler); | ||
} | ||
@@ -123,0 +124,0 @@ |
{ | ||
"name": "react-native-tts", | ||
"version": "3.1.1", | ||
"version": "3.2.0", | ||
"description": "React Native Text-To-Speech module for Android and iOS", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -35,7 +35,18 @@ # React Native TTS | ||
Additionally, speak() allows to pass platform-specific options 'voiceId' on IOS and 'params' on Android to underlying platform API: | ||
Additionally, speak() allows to pass platform-specific options. | ||
```js | ||
Tts.speak('Hello, world!', { iosVoiceId: 'com.apple.ttsbundle.Moira-compact' }); | ||
Tts.speak('Hello, world!', { androidParams: { KEY_PARAM_PAN: -1, KEY_PARAM_VOLUME: 0.5, KEY_PARAM_STREAM: 'STREAM_MUSIC' } }); | ||
// 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', | ||
}, | ||
}); | ||
``` | ||
@@ -51,2 +62,7 @@ | ||
The supported options for IOS are: | ||
- `iosVoiceId` which voice to use, check [voices()](#list-voices) for available values | ||
- `rate` which speech rate this line should be spoken with. Will override [default rate](#set-default-speech-rate) if set for this utterance. | ||
Stop speaking and flush the TTS queue. | ||
@@ -53,0 +69,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
97447
576
250