New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

react-native-tts

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-tts - npm Package Compare versions

Comparing version 3.3.0 to 4.0.0

windows/README.md

153

index.d.ts

@@ -1,82 +0,117 @@

import * as RN from 'react-native'
import * as RN from "react-native";
type SimpleEvents = 'tts-start' | 'tts-finish' | 'tts-error' | 'tts-cancel'
type SimpleEvents = "tts-start" | "tts-finish" | "tts-error" | "tts-cancel";
type SimpleEvent = {
utteranceId: string | number
}
utteranceId: string | number;
};
type ProgressEventName = 'tts-progress'
type ProgressEventName = "tts-progress";
type ProgressEvent = {
utteranceId: string | number
location: number
length: number
}
utteranceId: string | number;
location: number;
length: number;
};
export type TtsEvents = SimpleEvents | ProgressEventName
export type TtsEvent<T extends TtsEvents = TtsEvents> = T extends ProgressEventName ? ProgressEvent : SimpleEvent
export type TtsEventHandler<T extends TtsEvents= TtsEvents> = (event: TtsEvent<T>) => any
export type TtsEvents = SimpleEvents | ProgressEventName;
export type TtsEvent<
T extends TtsEvents = TtsEvents
> = T extends ProgressEventName ? ProgressEvent : SimpleEvent;
export type TtsEventHandler<T extends TtsEvents = TtsEvents> = (
event: TtsEvent<T>
) => any;
export type TtsError = {
code: 'no_engine' | 'error' | 'not_ready' | 'invalid_request' | 'network_error' | 'network_timeout' | 'not_installed_yet' | 'output_error'
| 'service_error' | 'synthesis_error' | 'lang_missing_data' | 'lang_not_supported' | 'Android AudioManager error' | 'not_available' | 'not_found'
| 'bad_rate'
message: string
}
code:
| "no_engine"
| "error"
| "not_ready"
| "invalid_request"
| "network_error"
| "network_timeout"
| "not_installed_yet"
| "output_error"
| "service_error"
| "synthesis_error"
| "lang_missing_data"
| "lang_not_supported"
| "Android AudioManager error"
| "not_available"
| "not_found"
| "bad_rate";
message: string;
};
export type Voice = {
id: string
name: string
language: string
quality: number
latency: number
networkConnectionRequired: boolean
notInstalled: boolean
}
id: string;
name: string;
language: string;
quality: number;
latency: number;
networkConnectionRequired: boolean;
notInstalled: boolean;
};
export type Engine = {
name: string
label: string
default: boolean
icon: number
}
name: string;
label: string;
default: boolean;
icon: number;
};
export type AndroidOptions = {
/** Parameter key to specify the audio stream type to be used when speaking text or playing back a file */
KEY_PARAM_STREAM: 'STREAM_VOICE_CALL' | 'STREAM_SYSTEM' | 'STREAM_RING' | 'STREAM_MUSIC' | 'STREAM_MUSIC' | 'STREAM_ALARM' | 'STREAM_NOTIFICATION' | 'STREAM_DTMF' | 'STREAM_ACCESSIBILITY'
KEY_PARAM_STREAM:
| "STREAM_VOICE_CALL"
| "STREAM_SYSTEM"
| "STREAM_RING"
| "STREAM_MUSIC"
| "STREAM_MUSIC"
| "STREAM_ALARM"
| "STREAM_NOTIFICATION"
| "STREAM_DTMF"
| "STREAM_ACCESSIBILITY";
/** Parameter key to specify the speech volume relative to the current stream type volume used when speaking text. Volume is specified as a float ranging from 0 to 1 where 0 is silence, and 1 is the maximum volume (the default behavior). */
KEY_PARAM_VOLUME: number
KEY_PARAM_VOLUME: number;
/** Parameter key to specify how the speech is panned from left to right when speaking text. Pan is specified as a float ranging from -1 to +1 where -1 maps to a hard-left pan, 0 to center (the default behavior), and +1 to hard-right. */
KEY_PARAM_PAN: number
}
KEY_PARAM_PAN: number;
};
export type Options = string | {
iosVoiceId: string
rate: number
androidParams: AndroidOptions
}
export type Options =
| string
| {
iosVoiceId: string;
rate: number;
androidParams: AndroidOptions;
};
export class ReactNativeTts extends RN.NativeEventEmitter {
getInitStatus: () => Promise<'success'>
requestInstallEngine: () => Promise<'success'>
requestInstallData: () => Promise<'success'>
setDucking: (enabled: boolean) => Promise<'success'>
setDefaultEngine: (engineName: string) => Promise<boolean>
setDefaultVoice: (voiceId: string) => Promise<'success'>
setDefaultRate: (rate: number, skipTransform?: boolean) => Promise<'success'>
setDefaultPitch: (pitch: number) => Promise<'success'>
setDefaultLanguage: (language: string) => Promise<'success'>
setIgnoreSilentSwitch: (ignoreSilentSwitch: boolean) => Promise<boolean>
voices: () => Voice[]
engines: () => Promise<Engine[]>
getInitStatus: () => Promise<"success">;
requestInstallEngine: () => Promise<"success">;
requestInstallData: () => Promise<"success">;
setDucking: (enabled: boolean) => Promise<"success">;
setDefaultEngine: (engineName: string) => Promise<boolean>;
setDefaultVoice: (voiceId: string) => Promise<"success">;
setDefaultRate: (rate: number, skipTransform?: boolean) => Promise<"success">;
setDefaultPitch: (pitch: number) => Promise<"success">;
setDefaultLanguage: (language: string) => Promise<"success">;
setIgnoreSilentSwitch: (ignoreSilentSwitch: boolean) => Promise<boolean>;
voices: () => Promise<Voice[]>;
engines: () => Promise<Engine[]>;
/** Read the sentence and return an id for the task. */
speak: (utterance: string, options?: Options) => string | number
stop: (onWordBoundary?: boolean) => Promise<boolean>
pause: (onWordBoundary?: boolean) => Promise<boolean>
resume: () => Promise<boolean>
addEventListener: <T extends TtsEvents>(type: T, handler: TtsEventHandler<T>) => void
removeEventListener: <T extends TtsEvents>(type: T, handler: TtsEventHandler<T>) => void
speak: (utterance: string, options?: Options) => string | number;
stop: (onWordBoundary?: boolean) => Promise<boolean>;
pause: (onWordBoundary?: boolean) => Promise<boolean>;
resume: () => Promise<boolean>;
addEventListener: <T extends TtsEvents>(
type: T,
handler: TtsEventHandler<T>
) => void;
removeEventListener: <T extends TtsEvents>(
type: T,
handler: TtsEventHandler<T>
) => void;
}
declare const Tts = new ReactNativeTts();
declare const Tts: ReactNativeTts;
export default Tts
export default Tts;

@@ -11,3 +11,3 @@ import { NativeModules, NativeEventEmitter, Platform } from 'react-native';

getInitStatus() {
if (Platform.OS === 'ios') {
if (Platform.OS === 'ios' || Platform.OS === 'windows') {
return Promise.resolve(true);

@@ -19,3 +19,3 @@ }

requestInstallEngine() {
if (Platform.OS === 'ios') {
if (Platform.OS === 'ios' || Platform.OS === 'windows') {
return Promise.resolve(true);

@@ -27,3 +27,3 @@ }

requestInstallData() {
if (Platform.OS === 'ios') {
if (Platform.OS === 'ios' || Platform.OS === 'windows') {
return Promise.resolve(true);

@@ -35,2 +35,5 @@ }

setDucking(enabled) {
if (Platform.OS === 'windows') {
return Promise.resolve(true);
}
return TextToSpeech.setDucking(enabled);

@@ -40,3 +43,3 @@ }

setDefaultEngine(engineName) {
if (Platform.OS === 'ios') {
if (Platform.OS === 'ios' || Platform.OS === 'windows') {
return Promise.resolve(true);

@@ -64,3 +67,3 @@ }

setIgnoreSilentSwitch(ignoreSilentSwitch) {
if (Platform.OS === 'ios') {
if (Platform.OS === 'ios' || Platform.OS === 'windows') {
return TextToSpeech.setIgnoreSilentSwitch(ignoreSilentSwitch);

@@ -76,3 +79,3 @@ }

engines() {
if (Platform.OS === 'ios') {
if (Platform.OS === 'ios' || Platform.OS === 'windows') {
return Promise.resolve([]);

@@ -92,3 +95,3 @@ }

} else {
if (Platform.OS === 'ios') {
if (Platform.OS === 'ios' || Platform.OS === 'windows') {
return TextToSpeech.speak(utterance, options);

@@ -95,0 +98,0 @@ } else {

{
"name": "react-native-tts",
"version": "3.3.0",
"version": "4.0.0",
"description": "React Native Text-To-Speech module for Android and iOS",

@@ -25,3 +25,6 @@ "main": "index.js",

},
"homepage": "https://github.com/ak1394/react-native-tts#readme"
"homepage": "https://github.com/ak1394/react-native-tts#readme",
"peerDependencies": {
"react-native-windows": ">=0.62"
}
}
# React Native TTS
React Native TTS is a text-to-speech library for [React Native](https://facebook.github.io/react-native/) on iOS and Android.
React Native TTS is a text-to-speech library for [React Native](https://facebook.github.io/react-native/) on iOS, Android and Windows.

@@ -27,2 +27,19 @@ ## Documentation

#### 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

@@ -89,2 +106,4 @@

*(not supported on Windows)*
```js

@@ -145,3 +164,3 @@ Tts.setDucking(true);

There is a significant difference to how the rate value is interpreted by iOS and Android 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.
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.

@@ -156,3 +175,3 @@ Do not translate rate parameter:

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
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.

@@ -225,3 +244,3 @@ ```js

There is an example project which shows use of react-native-tts on Android/iOS: https://github.com/themostaza/react-native-tts-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

@@ -228,0 +247,0 @@ ## License

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc