https://github.com/kosich/rxjs-tts
RxJS wrapper for Text-to-Speech Web API
https://github.com/kosich/rxjs-tts
javascript rxjs speech-synthesis text-to-speech typescript
Last synced: over 1 year ago
JSON representation
RxJS wrapper for Text-to-Speech Web API
- Host: GitHub
- URL: https://github.com/kosich/rxjs-tts
- Owner: kosich
- License: mit
- Created: 2020-07-02T16:10:19.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2023-01-07T19:43:56.000Z (over 3 years ago)
- Last Synced: 2025-03-24T20:38:43.108Z (over 1 year ago)
- Topics: javascript, rxjs, speech-synthesis, text-to-speech, typescript
- Language: TypeScript
- Homepage:
- Size: 563 KB
- Stars: 8
- Watchers: 2
- Forks: 3
- Open Issues: 10
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
This is a RxJS wrapper around browser native [SpeechSynthesis](https://developer.mozilla.org/en-US/docs/Web/API/SpeechSynthesis).
It provides handy interface for chaining and aborting TTS.
Try it [**online**](https://stackblitz.com/edit/rxjs-tts?file=index.ts)
## Install
```
npm i rxjs-tts
```
## Usage
```js
import { speak } from 'rxjs-tts';
speak('Hello!').subscribe();
```
## Chained
```js
import { speak } from 'rxjs-tts';
concat(
speak('Hello, mom!'),
speak('How are you?'),
speak('I miss you.'),
).subscribe();
```
## Advanced usage
```js
import { of, merge, concat, timer } from 'rxjs';
import { map, takeUntil } from 'rxjs/operators';
import { speak, SpeechSynthesisUtteranceConfig } from 'rxjs-tts';
const a: string = 'Hello, mom!';
const b: SpeechSynthesisUtteranceConfig = {
text: 'How are you?',
lang: 'en-UK',
pitch: 1,
rate: 1,
volume: 1,
};
const c = new SpeechSynthesisUtterance('I miss you');
c.rate = 1;
c.lang = 'en-US';
c.pitch = 1;
c.rate = 1;
c.volume = 1;
concat(speak(a), speak(b), speak(c)).subscribe((e: SpeechSynthesisEvent) => {
console.log(e.name);
console.log(e.type);
});
```
## Enjoy 🙂