@capacitor-community/text-to-speech
Advanced tools
Comparing version 0.2.1-dev.754cf30 to 0.2.1-dev.7a0918b
@@ -7,11 +7,19 @@ declare module '@capacitor/core' { | ||
export interface TextToSpeechPlugin { | ||
speak(options: TTSSpeakOptions): Promise<void>; | ||
speak(options: TTSOptions): Promise<void>; | ||
stop(): Promise<void>; | ||
getSupportedLanguages(): Promise<TTSLanguages>; | ||
getSupportedVoices(): Promise<TTSVoices>; | ||
getSupportedLanguages(): Promise<{ | ||
languages: string[]; | ||
}>; | ||
getSupportedVoices(): Promise<{ | ||
voices: SpeechSynthesisVoice[]; | ||
}>; | ||
openInstall(): Promise<void>; | ||
setPitch(options: TTSPitchOptions): Promise<void>; | ||
setRate(options: TTSRateOptions): Promise<void>; | ||
setPitchRate(options: { | ||
pitchRate: number; | ||
}): Promise<void>; | ||
setSpeechRate(options: { | ||
speechRate: number; | ||
}): Promise<void>; | ||
} | ||
export interface TTSSpeakOptions { | ||
export interface TTSOptions { | ||
text: string; | ||
@@ -25,14 +33,2 @@ locale?: string; | ||
} | ||
export interface TTSPitchOptions { | ||
pitch: number; | ||
} | ||
export interface TTSRateOptions { | ||
rate: number; | ||
} | ||
export interface TTSVoices { | ||
voices: SpeechSynthesisVoice[]; | ||
} | ||
export interface TTSLanguages { | ||
languages: any; | ||
} | ||
/** | ||
@@ -39,0 +35,0 @@ * The SpeechSynthesisVoice interface represents a voice that the system supports. |
import { WebPlugin } from '@capacitor/core'; | ||
import { TextToSpeechPlugin, TTSSpeakOptions, TTSPitchOptions, TTSRateOptions, TTSVoices, TTSLanguages } from './definitions'; | ||
import { TextToSpeechPlugin, SpeechSynthesisVoice, TTSOptions } from './definitions'; | ||
export declare class TextToSpeechWeb extends WebPlugin implements TextToSpeechPlugin { | ||
private speechSynthesis; | ||
private currentlyActive; | ||
constructor(); | ||
speak(options: TTSSpeakOptions): Promise<void>; | ||
speak(options: TTSOptions): Promise<void>; | ||
stop(): Promise<void>; | ||
getSupportedLanguages(): Promise<TTSLanguages>; | ||
getSupportedVoices(): Promise<TTSVoices>; | ||
getSupportedLanguages(): Promise<{ | ||
languages: string[]; | ||
}>; | ||
getSupportedVoices(): Promise<{ | ||
voices: SpeechSynthesisVoice[]; | ||
}>; | ||
openInstall(): Promise<void>; | ||
setPitch(_options: TTSPitchOptions): Promise<void>; | ||
setRate(_options: TTSRateOptions): Promise<void>; | ||
setPitchRate(_options: { | ||
pitchRate: number; | ||
}): Promise<void>; | ||
setSpeechRate(_options: { | ||
speechRate: number; | ||
}): Promise<void>; | ||
private createSpeechSynthesisUtterance; | ||
private getSpeechSynthesisVoices; | ||
private getSpeechSynthesis; | ||
private throwUnsupportedError; | ||
private getSpeechSynthesis; | ||
private getSpeechSynthesisVoices; | ||
private createSpeechSynthesisUtterance; | ||
private throwNotImplementedError; | ||
} | ||
declare const TextToSpeech: TextToSpeechWeb; | ||
export { TextToSpeech }; |
@@ -18,10 +18,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
this.currentlyActive = false; | ||
this.speechSynthesis = this.getSpeechSynthesis(); | ||
} | ||
speak(options) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const speechSynthesis = this.speechSynthesis; | ||
if (!speechSynthesis) { | ||
this.throwUnsupportedError(); | ||
} | ||
const speechSynthesis = this.getSpeechSynthesis(); | ||
if (this.currentlyActive) { | ||
@@ -47,6 +43,4 @@ return; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
if (!this.speechSynthesis) { | ||
this.throwUnsupportedError(); | ||
} | ||
this.speechSynthesis.cancel(); | ||
const speechSynthesis = this.getSpeechSynthesis(); | ||
speechSynthesis.cancel(); | ||
}); | ||
@@ -69,30 +63,15 @@ } | ||
return __awaiter(this, void 0, void 0, function* () { | ||
throw new Error('Not implemented on web.'); | ||
this.throwNotImplementedError(); | ||
}); | ||
} | ||
setPitch(_options) { | ||
setPitchRate(_options) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
throw new Error('Not implemented on web.'); | ||
this.throwNotImplementedError(); | ||
}); | ||
} | ||
setRate(_options) { | ||
setSpeechRate(_options) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
throw new Error('Not implemented on web.'); | ||
this.throwNotImplementedError(); | ||
}); | ||
} | ||
throwUnsupportedError() { | ||
throw new Error('Not supported on this device.'); | ||
} | ||
getSpeechSynthesis() { | ||
if ('speechSynthesis' in window) { | ||
return window.speechSynthesis; | ||
} | ||
return null; | ||
} | ||
getSpeechSynthesisVoices() { | ||
if (!this.speechSynthesis) { | ||
this.throwUnsupportedError(); | ||
} | ||
return this.speechSynthesis.getVoices(); | ||
} | ||
createSpeechSynthesisUtterance(options) { | ||
@@ -122,2 +101,18 @@ return __awaiter(this, void 0, void 0, function* () { | ||
} | ||
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.'); | ||
} | ||
} | ||
@@ -124,0 +119,0 @@ const TextToSpeech = new TextToSpeechWeb(); |
@@ -23,10 +23,6 @@ 'use strict'; | ||
this.currentlyActive = false; | ||
this.speechSynthesis = this.getSpeechSynthesis(); | ||
} | ||
speak(options) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const speechSynthesis = this.speechSynthesis; | ||
if (!speechSynthesis) { | ||
this.throwUnsupportedError(); | ||
} | ||
const speechSynthesis = this.getSpeechSynthesis(); | ||
if (this.currentlyActive) { | ||
@@ -52,6 +48,4 @@ return; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
if (!this.speechSynthesis) { | ||
this.throwUnsupportedError(); | ||
} | ||
this.speechSynthesis.cancel(); | ||
const speechSynthesis = this.getSpeechSynthesis(); | ||
speechSynthesis.cancel(); | ||
}); | ||
@@ -74,30 +68,15 @@ } | ||
return __awaiter(this, void 0, void 0, function* () { | ||
throw new Error('Not implemented on web.'); | ||
this.throwNotImplementedError(); | ||
}); | ||
} | ||
setPitch(_options) { | ||
setPitchRate(_options) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
throw new Error('Not implemented on web.'); | ||
this.throwNotImplementedError(); | ||
}); | ||
} | ||
setRate(_options) { | ||
setSpeechRate(_options) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
throw new Error('Not implemented on web.'); | ||
this.throwNotImplementedError(); | ||
}); | ||
} | ||
throwUnsupportedError() { | ||
throw new Error('Not supported on this device.'); | ||
} | ||
getSpeechSynthesis() { | ||
if ('speechSynthesis' in window) { | ||
return window.speechSynthesis; | ||
} | ||
return null; | ||
} | ||
getSpeechSynthesisVoices() { | ||
if (!this.speechSynthesis) { | ||
this.throwUnsupportedError(); | ||
} | ||
return this.speechSynthesis.getVoices(); | ||
} | ||
createSpeechSynthesisUtterance(options) { | ||
@@ -127,2 +106,18 @@ return __awaiter(this, void 0, void 0, function* () { | ||
} | ||
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.'); | ||
} | ||
} | ||
@@ -129,0 +124,0 @@ const TextToSpeech = new TextToSpeechWeb(); |
@@ -20,10 +20,6 @@ var capacitorTextToSpeech = (function (exports, core) { | ||
this.currentlyActive = false; | ||
this.speechSynthesis = this.getSpeechSynthesis(); | ||
} | ||
speak(options) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const speechSynthesis = this.speechSynthesis; | ||
if (!speechSynthesis) { | ||
this.throwUnsupportedError(); | ||
} | ||
const speechSynthesis = this.getSpeechSynthesis(); | ||
if (this.currentlyActive) { | ||
@@ -49,6 +45,4 @@ return; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
if (!this.speechSynthesis) { | ||
this.throwUnsupportedError(); | ||
} | ||
this.speechSynthesis.cancel(); | ||
const speechSynthesis = this.getSpeechSynthesis(); | ||
speechSynthesis.cancel(); | ||
}); | ||
@@ -71,30 +65,15 @@ } | ||
return __awaiter(this, void 0, void 0, function* () { | ||
throw new Error('Not implemented on web.'); | ||
this.throwNotImplementedError(); | ||
}); | ||
} | ||
setPitch(_options) { | ||
setPitchRate(_options) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
throw new Error('Not implemented on web.'); | ||
this.throwNotImplementedError(); | ||
}); | ||
} | ||
setRate(_options) { | ||
setSpeechRate(_options) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
throw new Error('Not implemented on web.'); | ||
this.throwNotImplementedError(); | ||
}); | ||
} | ||
throwUnsupportedError() { | ||
throw new Error('Not supported on this device.'); | ||
} | ||
getSpeechSynthesis() { | ||
if ('speechSynthesis' in window) { | ||
return window.speechSynthesis; | ||
} | ||
return null; | ||
} | ||
getSpeechSynthesisVoices() { | ||
if (!this.speechSynthesis) { | ||
this.throwUnsupportedError(); | ||
} | ||
return this.speechSynthesis.getVoices(); | ||
} | ||
createSpeechSynthesisUtterance(options) { | ||
@@ -124,2 +103,18 @@ return __awaiter(this, void 0, void 0, function* () { | ||
} | ||
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.'); | ||
} | ||
} | ||
@@ -126,0 +121,0 @@ const TextToSpeech = new TextToSpeechWeb(); |
{ | ||
"name": "@capacitor-community/text-to-speech", | ||
"version": "0.2.1-dev.754cf30", | ||
"version": "0.2.1-dev.7a0918b", | ||
"description": "Capacitor plugin for synthesizing speech from text.", | ||
@@ -5,0 +5,0 @@ "main": "dist/plugin.js", |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
0
68955
452