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

@capacitor-community/text-to-speech

Package Overview
Dependencies
Maintainers
29
Versions
43
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.d33dceb to 0.2.1-dev.eb70d2f

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: any;
languages: string[];
}>;

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

}
/**
* The SpeechSynthesisVoice interface represents a voice that the system supports.
*/
export interface SpeechSynthesisVoice {
voiceURI: string;
name: string;
/**
* 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`
*/
lang: string;
/**
* Specifies whether the voice is supplied by a local (`true`) or remote (`false`) speech synthesizer service.
*/
localService: boolean;
default: 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;
}
export * from './definitions';
export * from './web';
export * from './definitions';
export * from './web';
//# sourceMappingURL=index.js.map

13

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

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

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

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

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

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

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';

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

});
this.notSupportedMessage = 'Speech Synthesizer is not yet initialized or supported.';
this.supportedVoices = [];
if (!this.speechSynthesizer && window && window.speechSynthesis) {
this.speechSynthesizer = window.speechSynthesis;
this.speechSynthesis = null;
if ('speechSynthesis' in window) {
this.speechSynthesis = window.speechSynthesis;
}
}
speak(options) {
return new Promise((resolve, reject) => {
if (!this.speechSynthesizer) {
reject(this.notSupportedMessage);
return;
return __awaiter(this, void 0, void 0, function* () {
if (!this.speechSynthesis) {
this.throwUnsupportedError();
}
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;
yield this.stop();
const speechSynthesis = this.speechSynthesis;
const utterance = this.createSpeechSynthesisUtterance(options);
return new Promise((resolve, reject) => {
utterance.onend = () => {
resolve();
};
this.activeUtterance.onerror = (ev) => {
reject(ev);
this.activeUtterance = undefined;
utterance.onerror = (event) => {
reject(event);
};
this.speechSynthesizer.speak(this.activeUtterance);
}
speechSynthesis.speak(utterance);
});
});
}
stop() {
return new Promise((resolve, reject) => {
if (!this.speechSynthesizer) {
reject(this.notSupportedMessage);
return;
return __awaiter(this, void 0, void 0, function* () {
if (!this.speechSynthesis) {
this.throwUnsupportedError();
}
this.speechSynthesizer.cancel();
resolve();
this.speechSynthesis.cancel();
});
}
getSupportedLanguages() {
return new Promise((resolve, reject) => {
if (!this.speechSynthesizer) {
reject(this.notSupportedMessage);
return;
}
resolve();
return __awaiter(this, void 0, void 0, function* () {
const voices = this.getSpeechSynthesisVoices();
const languages = voices.map(voice => voice.lang);
const filteredLanguages = languages.filter((v, i, a) => a.indexOf(v) == i);
return { languages: filteredLanguages };
});
}
getSupportedVoices() {
return new Promise((resolve, reject) => {
if (!this.speechSynthesizer) {
reject(this.notSupportedMessage);
return;
}
this.supportedVoices = window.speechSynthesis.getVoices();
resolve({
voices: this.supportedVoices,
});
return __awaiter(this, void 0, void 0, function* () {
const voices = this.getSpeechSynthesisVoices();
return { voices };
});
}
openInstall() {
throw new Error('Method not implemented.');
return __awaiter(this, void 0, void 0, function* () {
this.throwUnimplementedError();
});
}
setPitchRate(_options) {
// Pitch rate cannot be set while engine is active
throw new Error('Method not implemented.');
return __awaiter(this, void 0, void 0, function* () {
this.throwUnimplementedError();
});
}
setSpeechRate(_options) {
// Speech rate cannot be set while engine is active
throw new Error('Method not implemented.');
return __awaiter(this, void 0, void 0, function* () {
this.throwUnimplementedError();
});
}
createSpeechSynthesisUtterance(options) {
const voices = this.getSpeechSynthesisVoices();
const utterance = new SpeechSynthesisUtterance();
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() {
if (!this.speechSynthesis) {
this.throwUnsupportedError();
}
return this.speechSynthesis.getVoices();
}
throwUnsupportedError() {
throw new Error('Not supported on this device.');
}
throwUnimplementedError() {
throw new Error('Not implemented on web.');
}
}

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

@@ -7,2 +7,11 @@ '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 {

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

});
this.notSupportedMessage = 'Speech Synthesizer is not yet initialized or supported.';
this.supportedVoices = [];
if (!this.speechSynthesizer && window && window.speechSynthesis) {
this.speechSynthesizer = window.speechSynthesis;
this.speechSynthesis = null;
if ('speechSynthesis' in window) {
this.speechSynthesis = window.speechSynthesis;
}
}
speak(options) {
return new Promise((resolve, reject) => {
if (!this.speechSynthesizer) {
reject(this.notSupportedMessage);
return;
return __awaiter(this, void 0, void 0, function* () {
if (!this.speechSynthesis) {
this.throwUnsupportedError();
}
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;
yield this.stop();
const speechSynthesis = this.speechSynthesis;
const utterance = this.createSpeechSynthesisUtterance(options);
return new Promise((resolve, reject) => {
utterance.onend = () => {
resolve();
};
this.activeUtterance.onerror = (ev) => {
reject(ev);
this.activeUtterance = undefined;
utterance.onerror = (event) => {
reject(event);
};
this.speechSynthesizer.speak(this.activeUtterance);
}
speechSynthesis.speak(utterance);
});
});
}
stop() {
return new Promise((resolve, reject) => {
if (!this.speechSynthesizer) {
reject(this.notSupportedMessage);
return;
return __awaiter(this, void 0, void 0, function* () {
if (!this.speechSynthesis) {
this.throwUnsupportedError();
}
this.speechSynthesizer.cancel();
resolve();
this.speechSynthesis.cancel();
});
}
getSupportedLanguages() {
return new Promise((resolve, reject) => {
if (!this.speechSynthesizer) {
reject(this.notSupportedMessage);
return;
}
resolve();
return __awaiter(this, void 0, void 0, function* () {
const voices = this.getSpeechSynthesisVoices();
const languages = voices.map(voice => voice.lang);
const filteredLanguages = languages.filter((v, i, a) => a.indexOf(v) == i);
return { languages: filteredLanguages };
});
}
getSupportedVoices() {
return new Promise((resolve, reject) => {
if (!this.speechSynthesizer) {
reject(this.notSupportedMessage);
return;
}
this.supportedVoices = window.speechSynthesis.getVoices();
resolve({
voices: this.supportedVoices,
});
return __awaiter(this, void 0, void 0, function* () {
const voices = this.getSpeechSynthesisVoices();
return { voices };
});
}
openInstall() {
throw new Error('Method not implemented.');
return __awaiter(this, void 0, void 0, function* () {
this.throwUnimplementedError();
});
}
setPitchRate(_options) {
// Pitch rate cannot be set while engine is active
throw new Error('Method not implemented.');
return __awaiter(this, void 0, void 0, function* () {
this.throwUnimplementedError();
});
}
setSpeechRate(_options) {
// Speech rate cannot be set while engine is active
throw new Error('Method not implemented.');
return __awaiter(this, void 0, void 0, function* () {
this.throwUnimplementedError();
});
}
createSpeechSynthesisUtterance(options) {
const voices = this.getSpeechSynthesisVoices();
const utterance = new SpeechSynthesisUtterance();
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() {
if (!this.speechSynthesis) {
this.throwUnsupportedError();
}
return this.speechSynthesis.getVoices();
}
throwUnsupportedError() {
throw new Error('Not supported on this device.');
}
throwUnimplementedError() {
throw new Error('Not implemented on web.');
}
}

@@ -105,0 +120,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 {

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

});
this.notSupportedMessage = 'Speech Synthesizer is not yet initialized or supported.';
this.supportedVoices = [];
if (!this.speechSynthesizer && window && window.speechSynthesis) {
this.speechSynthesizer = window.speechSynthesis;
this.speechSynthesis = null;
if ('speechSynthesis' in window) {
this.speechSynthesis = window.speechSynthesis;
}
}
speak(options) {
return new Promise((resolve, reject) => {
if (!this.speechSynthesizer) {
reject(this.notSupportedMessage);
return;
return __awaiter(this, void 0, void 0, function* () {
if (!this.speechSynthesis) {
this.throwUnsupportedError();
}
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;
yield this.stop();
const speechSynthesis = this.speechSynthesis;
const utterance = this.createSpeechSynthesisUtterance(options);
return new Promise((resolve, reject) => {
utterance.onend = () => {
resolve();
};
this.activeUtterance.onerror = (ev) => {
reject(ev);
this.activeUtterance = undefined;
utterance.onerror = (event) => {
reject(event);
};
this.speechSynthesizer.speak(this.activeUtterance);
}
speechSynthesis.speak(utterance);
});
});
}
stop() {
return new Promise((resolve, reject) => {
if (!this.speechSynthesizer) {
reject(this.notSupportedMessage);
return;
return __awaiter(this, void 0, void 0, function* () {
if (!this.speechSynthesis) {
this.throwUnsupportedError();
}
this.speechSynthesizer.cancel();
resolve();
this.speechSynthesis.cancel();
});
}
getSupportedLanguages() {
return new Promise((resolve, reject) => {
if (!this.speechSynthesizer) {
reject(this.notSupportedMessage);
return;
}
resolve();
return __awaiter(this, void 0, void 0, function* () {
const voices = this.getSpeechSynthesisVoices();
const languages = voices.map(voice => voice.lang);
const filteredLanguages = languages.filter((v, i, a) => a.indexOf(v) == i);
return { languages: filteredLanguages };
});
}
getSupportedVoices() {
return new Promise((resolve, reject) => {
if (!this.speechSynthesizer) {
reject(this.notSupportedMessage);
return;
}
this.supportedVoices = window.speechSynthesis.getVoices();
resolve({
voices: this.supportedVoices,
});
return __awaiter(this, void 0, void 0, function* () {
const voices = this.getSpeechSynthesisVoices();
return { voices };
});
}
openInstall() {
throw new Error('Method not implemented.');
return __awaiter(this, void 0, void 0, function* () {
this.throwUnimplementedError();
});
}
setPitchRate(_options) {
// Pitch rate cannot be set while engine is active
throw new Error('Method not implemented.');
return __awaiter(this, void 0, void 0, function* () {
this.throwUnimplementedError();
});
}
setSpeechRate(_options) {
// Speech rate cannot be set while engine is active
throw new Error('Method not implemented.');
return __awaiter(this, void 0, void 0, function* () {
this.throwUnimplementedError();
});
}
createSpeechSynthesisUtterance(options) {
const voices = this.getSpeechSynthesisVoices();
const utterance = new SpeechSynthesisUtterance();
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() {
if (!this.speechSynthesis) {
this.throwUnsupportedError();
}
return this.speechSynthesis.getVoices();
}
throwUnsupportedError() {
throw new Error('Not supported on this device.');
}
throwUnimplementedError() {
throw new Error('Not implemented on web.');
}
}

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

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

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

"license": "MIT",
"dependencies": {
"@capacitor/core": "latest"
},
"devDependencies": {

@@ -41,2 +38,5 @@ "@capacitor/android": "2.4.7",

},
"peerDependencies": {
"@capacitor/core": "^2.4.6"
},
"files": [

@@ -43,0 +43,0 @@ "android/src/main/",

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