Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@capacitor-community/text-to-speech

Package Overview
Dependencies
Maintainers
27
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@capacitor-community/text-to-speech - npm Package Compare versions

Comparing version 0.2.1-dev.7a0918b to 0.2.1-dev.d33dceb

0

CHANGELOG.md

@@ -0,0 +0,0 @@ ## [0.2.0](https://github.com/capacitor-community/text-to-speech/compare/v0.1.3...v0.2.0) (2020-06-30)

29

dist/esm/definitions.d.ts

@@ -10,3 +10,3 @@ declare module '@capacitor/core' {

getSupportedLanguages(): Promise<{
languages: string[];
languages: any;
}>;

@@ -33,29 +33,8 @@ getSupportedVoices(): Promise<{

}
/**
* The SpeechSynthesisVoice interface represents a voice that the system supports.
*/
export interface SpeechSynthesisVoice {
/**
* Specifies whether the voice is the default voice for the current app (`true`) or not (`false`).
*/
default: boolean;
/**
* BCP 47 language tag indicating the language of the voice.
* Example: `en-US`
*/
voiceURI: string;
name: string;
lang: string;
/**
* Specifies whether the voice is supplied by a local (`true`) or remote (`false`) speech synthesizer service.
*/
localService: boolean;
/**
* Human-readable name that represents the voice.
* Example: `Microsoft Zira Desktop - English (United States)`
*/
name: string;
/**
* Type of URI and location of the speech synthesis service for this voice.
* Example: `urn:moz-tts:sapi:Microsoft Zira Desktop - English (United States)?en-US`
*/
voiceURI: string;
default: boolean;
}
export * from './definitions';
export * from './web';
export * from './definitions';
export * from './web';
//# sourceMappingURL=index.js.map

14

dist/esm/web.d.ts
import { WebPlugin } from '@capacitor/core';
import { TextToSpeechPlugin, SpeechSynthesisVoice, TTSOptions } from './definitions';
import { TextToSpeechPlugin, TTSOptions, SpeechSynthesisVoice } from './definitions';
export declare class TextToSpeechWeb extends WebPlugin implements TextToSpeechPlugin {
private currentlyActive;
private speechSynthesizer;
private activeUtterance;
private notSupportedMessage;
private supportedVoices;
constructor();

@@ -9,3 +12,3 @@ speak(options: TTSOptions): Promise<void>;

getSupportedLanguages(): Promise<{
languages: string[];
languages: any;
}>;

@@ -22,9 +25,4 @@ getSupportedVoices(): Promise<{

}): Promise<void>;
private createSpeechSynthesisUtterance;
private getSpeechSynthesisVoices;
private getSpeechSynthesis;
private throwUnsupportedError;
private throwNotImplementedError;
}
declare const TextToSpeech: TextToSpeechWeb;
export { TextToSpeech };

@@ -1,10 +0,1 @@

var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
import { WebPlugin } from '@capacitor/core';

@@ -17,99 +8,91 @@ export class TextToSpeechWeb extends WebPlugin {

});
this.currentlyActive = false;
this.notSupportedMessage = 'Speech Synthesizer is not yet initialized or supported.';
this.supportedVoices = [];
if (!this.speechSynthesizer && window && window.speechSynthesis) {
this.speechSynthesizer = window.speechSynthesis;
}
}
speak(options) {
return __awaiter(this, void 0, void 0, function* () {
const speechSynthesis = this.getSpeechSynthesis();
if (this.currentlyActive) {
return new Promise((resolve, reject) => {
if (!this.speechSynthesizer) {
reject(this.notSupportedMessage);
return;
}
this.currentlyActive = true;
const utterance = yield this.createSpeechSynthesisUtterance(options);
return new Promise((resolve, reject) => {
utterance.onend = () => {
this.currentlyActive = false;
resolve();
if (!options) {
reject('No options were provided.');
return;
}
if (!options.text) {
reject('Text option was not provided');
return;
}
const { text, locale, speechRate, volume, voice, pitchRate } = options;
if (!this.activeUtterance) {
this.activeUtterance = new SpeechSynthesisUtterance();
this.supportedVoices = window.speechSynthesis.getVoices();
this.activeUtterance.voice = this.supportedVoices[voice];
this.activeUtterance.rate =
speechRate >= 0.1 && speechRate <= 10 ? speechRate : 1;
this.activeUtterance.volume = volume >= 0 && volume <= 1 ? volume : 1;
this.activeUtterance.text = text;
this.activeUtterance.lang = locale;
this.activeUtterance.pitch =
pitchRate >= 0 && pitchRate <= 2 ? pitchRate : 2;
if (voice) {
this.activeUtterance.voice = voice;
}
this.activeUtterance.onend = (ev) => {
resolve(ev);
this.activeUtterance = undefined;
};
utterance.onerror = (event) => {
this.currentlyActive = false;
reject(event);
this.activeUtterance.onerror = (ev) => {
reject(ev);
this.activeUtterance = undefined;
};
speechSynthesis.speak(utterance);
});
this.speechSynthesizer.speak(this.activeUtterance);
}
});
}
stop() {
return __awaiter(this, void 0, void 0, function* () {
const speechSynthesis = this.getSpeechSynthesis();
speechSynthesis.cancel();
return new Promise((resolve, reject) => {
if (!this.speechSynthesizer) {
reject(this.notSupportedMessage);
return;
}
this.speechSynthesizer.cancel();
resolve();
});
}
getSupportedLanguages() {
return __awaiter(this, void 0, void 0, function* () {
const voices = this.getSpeechSynthesisVoices();
const languages = voices.map(voice => voice.lang);
return { languages };
return new Promise((resolve, reject) => {
if (!this.speechSynthesizer) {
reject(this.notSupportedMessage);
return;
}
resolve();
});
}
getSupportedVoices() {
return __awaiter(this, void 0, void 0, function* () {
const voices = this.getSpeechSynthesisVoices();
return { voices };
return new Promise((resolve, reject) => {
if (!this.speechSynthesizer) {
reject(this.notSupportedMessage);
return;
}
this.supportedVoices = window.speechSynthesis.getVoices();
resolve({
voices: this.supportedVoices,
});
});
}
openInstall() {
return __awaiter(this, void 0, void 0, function* () {
this.throwNotImplementedError();
});
throw new Error('Method not implemented.');
}
setPitchRate(_options) {
return __awaiter(this, void 0, void 0, function* () {
this.throwNotImplementedError();
});
// Pitch rate cannot be set while engine is active
throw new Error('Method not implemented.');
}
setSpeechRate(_options) {
return __awaiter(this, void 0, void 0, function* () {
this.throwNotImplementedError();
});
// Speech rate cannot be set while engine is active
throw new Error('Method not implemented.');
}
createSpeechSynthesisUtterance(options) {
return __awaiter(this, void 0, void 0, function* () {
const utterance = new SpeechSynthesisUtterance();
const voices = this.getSpeechSynthesisVoices();
const { text, locale, speechRate, volume, voice, pitchRate } = options;
if (voice) {
utterance.voice = voices[voice];
}
if (volume) {
utterance.volume = volume >= 0 && volume <= 1 ? volume : 1;
}
if (speechRate) {
utterance.rate = speechRate >= 0.1 && speechRate <= 10 ? speechRate : 1;
}
if (pitchRate) {
utterance.pitch = pitchRate >= 0 && pitchRate <= 2 ? pitchRate : 2;
}
if (locale) {
utterance.lang = locale;
}
utterance.text = text;
return utterance;
});
}
getSpeechSynthesisVoices() {
const speechSynthesis = this.getSpeechSynthesis();
return speechSynthesis.getVoices();
}
getSpeechSynthesis() {
if ('speechSynthesis' in window) {
return window.speechSynthesis;
}
this.throwUnsupportedError();
}
throwUnsupportedError() {
throw new Error('Not supported on this device.');
}
throwNotImplementedError() {
throw new Error('Not implemented on web.');
}
}

@@ -116,0 +99,0 @@ const TextToSpeech = new TextToSpeechWeb();

@@ -7,11 +7,2 @@ 'use strict';

var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
class TextToSpeechWeb extends core.WebPlugin {

@@ -23,99 +14,91 @@ constructor() {

});
this.currentlyActive = false;
this.notSupportedMessage = 'Speech Synthesizer is not yet initialized or supported.';
this.supportedVoices = [];
if (!this.speechSynthesizer && window && window.speechSynthesis) {
this.speechSynthesizer = window.speechSynthesis;
}
}
speak(options) {
return __awaiter(this, void 0, void 0, function* () {
const speechSynthesis = this.getSpeechSynthesis();
if (this.currentlyActive) {
return new Promise((resolve, reject) => {
if (!this.speechSynthesizer) {
reject(this.notSupportedMessage);
return;
}
this.currentlyActive = true;
const utterance = yield this.createSpeechSynthesisUtterance(options);
return new Promise((resolve, reject) => {
utterance.onend = () => {
this.currentlyActive = false;
resolve();
if (!options) {
reject('No options were provided.');
return;
}
if (!options.text) {
reject('Text option was not provided');
return;
}
const { text, locale, speechRate, volume, voice, pitchRate } = options;
if (!this.activeUtterance) {
this.activeUtterance = new SpeechSynthesisUtterance();
this.supportedVoices = window.speechSynthesis.getVoices();
this.activeUtterance.voice = this.supportedVoices[voice];
this.activeUtterance.rate =
speechRate >= 0.1 && speechRate <= 10 ? speechRate : 1;
this.activeUtterance.volume = volume >= 0 && volume <= 1 ? volume : 1;
this.activeUtterance.text = text;
this.activeUtterance.lang = locale;
this.activeUtterance.pitch =
pitchRate >= 0 && pitchRate <= 2 ? pitchRate : 2;
if (voice) {
this.activeUtterance.voice = voice;
}
this.activeUtterance.onend = (ev) => {
resolve(ev);
this.activeUtterance = undefined;
};
utterance.onerror = (event) => {
this.currentlyActive = false;
reject(event);
this.activeUtterance.onerror = (ev) => {
reject(ev);
this.activeUtterance = undefined;
};
speechSynthesis.speak(utterance);
});
this.speechSynthesizer.speak(this.activeUtterance);
}
});
}
stop() {
return __awaiter(this, void 0, void 0, function* () {
const speechSynthesis = this.getSpeechSynthesis();
speechSynthesis.cancel();
return new Promise((resolve, reject) => {
if (!this.speechSynthesizer) {
reject(this.notSupportedMessage);
return;
}
this.speechSynthesizer.cancel();
resolve();
});
}
getSupportedLanguages() {
return __awaiter(this, void 0, void 0, function* () {
const voices = this.getSpeechSynthesisVoices();
const languages = voices.map(voice => voice.lang);
return { languages };
return new Promise((resolve, reject) => {
if (!this.speechSynthesizer) {
reject(this.notSupportedMessage);
return;
}
resolve();
});
}
getSupportedVoices() {
return __awaiter(this, void 0, void 0, function* () {
const voices = this.getSpeechSynthesisVoices();
return { voices };
return new Promise((resolve, reject) => {
if (!this.speechSynthesizer) {
reject(this.notSupportedMessage);
return;
}
this.supportedVoices = window.speechSynthesis.getVoices();
resolve({
voices: this.supportedVoices,
});
});
}
openInstall() {
return __awaiter(this, void 0, void 0, function* () {
this.throwNotImplementedError();
});
throw new Error('Method not implemented.');
}
setPitchRate(_options) {
return __awaiter(this, void 0, void 0, function* () {
this.throwNotImplementedError();
});
// Pitch rate cannot be set while engine is active
throw new Error('Method not implemented.');
}
setSpeechRate(_options) {
return __awaiter(this, void 0, void 0, function* () {
this.throwNotImplementedError();
});
// Speech rate cannot be set while engine is active
throw new Error('Method not implemented.');
}
createSpeechSynthesisUtterance(options) {
return __awaiter(this, void 0, void 0, function* () {
const utterance = new SpeechSynthesisUtterance();
const voices = this.getSpeechSynthesisVoices();
const { text, locale, speechRate, volume, voice, pitchRate } = options;
if (voice) {
utterance.voice = voices[voice];
}
if (volume) {
utterance.volume = volume >= 0 && volume <= 1 ? volume : 1;
}
if (speechRate) {
utterance.rate = speechRate >= 0.1 && speechRate <= 10 ? speechRate : 1;
}
if (pitchRate) {
utterance.pitch = pitchRate >= 0 && pitchRate <= 2 ? pitchRate : 2;
}
if (locale) {
utterance.lang = locale;
}
utterance.text = text;
return utterance;
});
}
getSpeechSynthesisVoices() {
const speechSynthesis = this.getSpeechSynthesis();
return speechSynthesis.getVoices();
}
getSpeechSynthesis() {
if ('speechSynthesis' in window) {
return window.speechSynthesis;
}
this.throwUnsupportedError();
}
throwUnsupportedError() {
throw new Error('Not supported on this device.');
}
throwNotImplementedError() {
throw new Error('Not implemented on web.');
}
}

@@ -122,0 +105,0 @@ const TextToSpeech = new TextToSpeechWeb();

var capacitorTextToSpeech = (function (exports, core) {
'use strict';
var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
class TextToSpeechWeb extends core.WebPlugin {

@@ -19,99 +10,91 @@ constructor() {

});
this.currentlyActive = false;
this.notSupportedMessage = 'Speech Synthesizer is not yet initialized or supported.';
this.supportedVoices = [];
if (!this.speechSynthesizer && window && window.speechSynthesis) {
this.speechSynthesizer = window.speechSynthesis;
}
}
speak(options) {
return __awaiter(this, void 0, void 0, function* () {
const speechSynthesis = this.getSpeechSynthesis();
if (this.currentlyActive) {
return new Promise((resolve, reject) => {
if (!this.speechSynthesizer) {
reject(this.notSupportedMessage);
return;
}
this.currentlyActive = true;
const utterance = yield this.createSpeechSynthesisUtterance(options);
return new Promise((resolve, reject) => {
utterance.onend = () => {
this.currentlyActive = false;
resolve();
if (!options) {
reject('No options were provided.');
return;
}
if (!options.text) {
reject('Text option was not provided');
return;
}
const { text, locale, speechRate, volume, voice, pitchRate } = options;
if (!this.activeUtterance) {
this.activeUtterance = new SpeechSynthesisUtterance();
this.supportedVoices = window.speechSynthesis.getVoices();
this.activeUtterance.voice = this.supportedVoices[voice];
this.activeUtterance.rate =
speechRate >= 0.1 && speechRate <= 10 ? speechRate : 1;
this.activeUtterance.volume = volume >= 0 && volume <= 1 ? volume : 1;
this.activeUtterance.text = text;
this.activeUtterance.lang = locale;
this.activeUtterance.pitch =
pitchRate >= 0 && pitchRate <= 2 ? pitchRate : 2;
if (voice) {
this.activeUtterance.voice = voice;
}
this.activeUtterance.onend = (ev) => {
resolve(ev);
this.activeUtterance = undefined;
};
utterance.onerror = (event) => {
this.currentlyActive = false;
reject(event);
this.activeUtterance.onerror = (ev) => {
reject(ev);
this.activeUtterance = undefined;
};
speechSynthesis.speak(utterance);
});
this.speechSynthesizer.speak(this.activeUtterance);
}
});
}
stop() {
return __awaiter(this, void 0, void 0, function* () {
const speechSynthesis = this.getSpeechSynthesis();
speechSynthesis.cancel();
return new Promise((resolve, reject) => {
if (!this.speechSynthesizer) {
reject(this.notSupportedMessage);
return;
}
this.speechSynthesizer.cancel();
resolve();
});
}
getSupportedLanguages() {
return __awaiter(this, void 0, void 0, function* () {
const voices = this.getSpeechSynthesisVoices();
const languages = voices.map(voice => voice.lang);
return { languages };
return new Promise((resolve, reject) => {
if (!this.speechSynthesizer) {
reject(this.notSupportedMessage);
return;
}
resolve();
});
}
getSupportedVoices() {
return __awaiter(this, void 0, void 0, function* () {
const voices = this.getSpeechSynthesisVoices();
return { voices };
return new Promise((resolve, reject) => {
if (!this.speechSynthesizer) {
reject(this.notSupportedMessage);
return;
}
this.supportedVoices = window.speechSynthesis.getVoices();
resolve({
voices: this.supportedVoices,
});
});
}
openInstall() {
return __awaiter(this, void 0, void 0, function* () {
this.throwNotImplementedError();
});
throw new Error('Method not implemented.');
}
setPitchRate(_options) {
return __awaiter(this, void 0, void 0, function* () {
this.throwNotImplementedError();
});
// Pitch rate cannot be set while engine is active
throw new Error('Method not implemented.');
}
setSpeechRate(_options) {
return __awaiter(this, void 0, void 0, function* () {
this.throwNotImplementedError();
});
// Speech rate cannot be set while engine is active
throw new Error('Method not implemented.');
}
createSpeechSynthesisUtterance(options) {
return __awaiter(this, void 0, void 0, function* () {
const utterance = new SpeechSynthesisUtterance();
const voices = this.getSpeechSynthesisVoices();
const { text, locale, speechRate, volume, voice, pitchRate } = options;
if (voice) {
utterance.voice = voices[voice];
}
if (volume) {
utterance.volume = volume >= 0 && volume <= 1 ? volume : 1;
}
if (speechRate) {
utterance.rate = speechRate >= 0.1 && speechRate <= 10 ? speechRate : 1;
}
if (pitchRate) {
utterance.pitch = pitchRate >= 0 && pitchRate <= 2 ? pitchRate : 2;
}
if (locale) {
utterance.lang = locale;
}
utterance.text = text;
return utterance;
});
}
getSpeechSynthesisVoices() {
const speechSynthesis = this.getSpeechSynthesis();
return speechSynthesis.getVoices();
}
getSpeechSynthesis() {
if ('speechSynthesis' in window) {
return window.speechSynthesis;
}
this.throwUnsupportedError();
}
throwUnsupportedError() {
throw new Error('Not supported on this device.');
}
throwNotImplementedError() {
throw new Error('Not implemented on web.');
}
}

@@ -118,0 +101,0 @@ const TextToSpeech = new TextToSpeechWeb();

{
"name": "@capacitor-community/text-to-speech",
"version": "0.2.1-dev.7a0918b",
"version": "0.2.1-dev.d33dceb",
"description": "Capacitor plugin for synthesizing speech from text.",

@@ -5,0 +5,0 @@ "main": "dist/plugin.js",

@@ -0,0 +0,0 @@ <p align="center"><br><img src="https://user-images.githubusercontent.com/236501/85893648-1c92e880-b7a8-11ea-926d-95355b8175c7.png" width="128" height="128" /></p>

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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