@kanyabhatt/texttospeechpackage
v1.0.3
Published
This is a package you can utilize to convert text to speech, for features like screen reader etc
Readme
Text To Speech package
Hello Everybody, I have created this text to speech converter which internally utilizes SpeechSynthesis
It has 4 different methods you can utilize in your project:
- startSpeech
- stopSpeech
- resumeSpeech
- pauseSpeech
It currently supports the following languages:
- CATALAN
- ENGLISH
- AFRIKAANS
- ITALIAN
- GERMAN
- TURKISH
How to use it:
Disclaimer - An event listener is necessary to use this library
- Run
npm i @kanyabhatt/texttospeechpackagein your terminal - Create your script and while attaching it to the html file add type as module:
<script src = './xyz.js' type = 'module'> - Add
import { ConvertToSpeech, voiceType } from 'from "./node_modules/@kanyabhatt/texttospeechpackage/script.js";at the top of the script. - Create an event listener within which create an object of ConvertToSpeech class which takes 1 argument which is an object with following properties:
- language: you can set it using voiceType enum.
- content: which is basically the content you want as speech
const languageObject = {language: voiceType.ENGLISH, content: 'Hello world'};
let obj = new ConvertToSpeech(languageObject);- Now just call the predefined functions given:
obj.startSpeech()
