@capacitor-community/text-to-speech
Advanced tools
Comparing version 0.2.1-dev.7a0918b to 0.2.1-dev.abde773
import { WebPlugin } from '@capacitor/core'; | ||
import { TextToSpeechPlugin, SpeechSynthesisVoice, TTSOptions } from './definitions'; | ||
export declare class TextToSpeechWeb extends WebPlugin implements TextToSpeechPlugin { | ||
private speechSynthesis; | ||
private currentlyActive; | ||
@@ -23,7 +24,6 @@ constructor(); | ||
private getSpeechSynthesisVoices; | ||
private getSpeechSynthesis; | ||
private throwUnsupportedError; | ||
private throwNotImplementedError; | ||
private throwUnimplementedError; | ||
} | ||
declare const TextToSpeech: TextToSpeechWeb; | ||
export { TextToSpeech }; |
@@ -17,7 +17,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
}); | ||
this.speechSynthesis = null; | ||
this.currentlyActive = false; | ||
if ('speechSynthesis' in window) { | ||
this.speechSynthesis = window.speechSynthesis; | ||
} | ||
} | ||
speak(options) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const speechSynthesis = this.getSpeechSynthesis(); | ||
if (!this.speechSynthesis) { | ||
this.throwUnsupportedError(); | ||
} | ||
const speechSynthesis = this.speechSynthesis; | ||
if (this.currentlyActive) { | ||
@@ -43,4 +50,6 @@ return; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const speechSynthesis = this.getSpeechSynthesis(); | ||
speechSynthesis.cancel(); | ||
if (!this.speechSynthesis) { | ||
this.throwUnsupportedError(); | ||
} | ||
this.speechSynthesis.cancel(); | ||
}); | ||
@@ -52,3 +61,4 @@ } | ||
const languages = voices.map(voice => voice.lang); | ||
return { languages }; | ||
const filteredLanguages = languages.filter((v, i, a) => a.indexOf(v) == i); | ||
return { languages: filteredLanguages }; | ||
}); | ||
@@ -64,3 +74,3 @@ } | ||
return __awaiter(this, void 0, void 0, function* () { | ||
this.throwNotImplementedError(); | ||
this.throwUnimplementedError(); | ||
}); | ||
@@ -70,3 +80,3 @@ } | ||
return __awaiter(this, void 0, void 0, function* () { | ||
this.throwNotImplementedError(); | ||
this.throwUnimplementedError(); | ||
}); | ||
@@ -76,3 +86,3 @@ } | ||
return __awaiter(this, void 0, void 0, function* () { | ||
this.throwNotImplementedError(); | ||
this.throwUnimplementedError(); | ||
}); | ||
@@ -82,4 +92,4 @@ } | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const voices = this.getSpeechSynthesisVoices(); | ||
const utterance = new SpeechSynthesisUtterance(); | ||
const voices = this.getSpeechSynthesisVoices(); | ||
const { text, locale, speechRate, volume, voice, pitchRate } = options; | ||
@@ -106,10 +116,6 @@ if (voice) { | ||
getSpeechSynthesisVoices() { | ||
const speechSynthesis = this.getSpeechSynthesis(); | ||
return speechSynthesis.getVoices(); | ||
} | ||
getSpeechSynthesis() { | ||
if ('speechSynthesis' in window) { | ||
return window.speechSynthesis; | ||
if (!this.speechSynthesis) { | ||
this.throwUnsupportedError(); | ||
} | ||
this.throwUnsupportedError(); | ||
return this.speechSynthesis.getVoices(); | ||
} | ||
@@ -119,3 +125,3 @@ throwUnsupportedError() { | ||
} | ||
throwNotImplementedError() { | ||
throwUnimplementedError() { | ||
throw new Error('Not implemented on web.'); | ||
@@ -122,0 +128,0 @@ } |
@@ -22,7 +22,14 @@ 'use strict'; | ||
}); | ||
this.speechSynthesis = null; | ||
this.currentlyActive = false; | ||
if ('speechSynthesis' in window) { | ||
this.speechSynthesis = window.speechSynthesis; | ||
} | ||
} | ||
speak(options) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const speechSynthesis = this.getSpeechSynthesis(); | ||
if (!this.speechSynthesis) { | ||
this.throwUnsupportedError(); | ||
} | ||
const speechSynthesis = this.speechSynthesis; | ||
if (this.currentlyActive) { | ||
@@ -48,4 +55,6 @@ return; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const speechSynthesis = this.getSpeechSynthesis(); | ||
speechSynthesis.cancel(); | ||
if (!this.speechSynthesis) { | ||
this.throwUnsupportedError(); | ||
} | ||
this.speechSynthesis.cancel(); | ||
}); | ||
@@ -57,3 +66,4 @@ } | ||
const languages = voices.map(voice => voice.lang); | ||
return { languages }; | ||
const filteredLanguages = languages.filter((v, i, a) => a.indexOf(v) == i); | ||
return { languages: filteredLanguages }; | ||
}); | ||
@@ -69,3 +79,3 @@ } | ||
return __awaiter(this, void 0, void 0, function* () { | ||
this.throwNotImplementedError(); | ||
this.throwUnimplementedError(); | ||
}); | ||
@@ -75,3 +85,3 @@ } | ||
return __awaiter(this, void 0, void 0, function* () { | ||
this.throwNotImplementedError(); | ||
this.throwUnimplementedError(); | ||
}); | ||
@@ -81,3 +91,3 @@ } | ||
return __awaiter(this, void 0, void 0, function* () { | ||
this.throwNotImplementedError(); | ||
this.throwUnimplementedError(); | ||
}); | ||
@@ -87,4 +97,4 @@ } | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const voices = this.getSpeechSynthesisVoices(); | ||
const utterance = new SpeechSynthesisUtterance(); | ||
const voices = this.getSpeechSynthesisVoices(); | ||
const { text, locale, speechRate, volume, voice, pitchRate } = options; | ||
@@ -111,10 +121,6 @@ if (voice) { | ||
getSpeechSynthesisVoices() { | ||
const speechSynthesis = this.getSpeechSynthesis(); | ||
return speechSynthesis.getVoices(); | ||
} | ||
getSpeechSynthesis() { | ||
if ('speechSynthesis' in window) { | ||
return window.speechSynthesis; | ||
if (!this.speechSynthesis) { | ||
this.throwUnsupportedError(); | ||
} | ||
this.throwUnsupportedError(); | ||
return this.speechSynthesis.getVoices(); | ||
} | ||
@@ -124,3 +130,3 @@ throwUnsupportedError() { | ||
} | ||
throwNotImplementedError() { | ||
throwUnimplementedError() { | ||
throw new Error('Not implemented on web.'); | ||
@@ -127,0 +133,0 @@ } |
@@ -19,7 +19,14 @@ var capacitorTextToSpeech = (function (exports, core) { | ||
}); | ||
this.speechSynthesis = null; | ||
this.currentlyActive = false; | ||
if ('speechSynthesis' in window) { | ||
this.speechSynthesis = window.speechSynthesis; | ||
} | ||
} | ||
speak(options) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const speechSynthesis = this.getSpeechSynthesis(); | ||
if (!this.speechSynthesis) { | ||
this.throwUnsupportedError(); | ||
} | ||
const speechSynthesis = this.speechSynthesis; | ||
if (this.currentlyActive) { | ||
@@ -45,4 +52,6 @@ return; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const speechSynthesis = this.getSpeechSynthesis(); | ||
speechSynthesis.cancel(); | ||
if (!this.speechSynthesis) { | ||
this.throwUnsupportedError(); | ||
} | ||
this.speechSynthesis.cancel(); | ||
}); | ||
@@ -54,3 +63,4 @@ } | ||
const languages = voices.map(voice => voice.lang); | ||
return { languages }; | ||
const filteredLanguages = languages.filter((v, i, a) => a.indexOf(v) == i); | ||
return { languages: filteredLanguages }; | ||
}); | ||
@@ -66,3 +76,3 @@ } | ||
return __awaiter(this, void 0, void 0, function* () { | ||
this.throwNotImplementedError(); | ||
this.throwUnimplementedError(); | ||
}); | ||
@@ -72,3 +82,3 @@ } | ||
return __awaiter(this, void 0, void 0, function* () { | ||
this.throwNotImplementedError(); | ||
this.throwUnimplementedError(); | ||
}); | ||
@@ -78,3 +88,3 @@ } | ||
return __awaiter(this, void 0, void 0, function* () { | ||
this.throwNotImplementedError(); | ||
this.throwUnimplementedError(); | ||
}); | ||
@@ -84,4 +94,4 @@ } | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const voices = this.getSpeechSynthesisVoices(); | ||
const utterance = new SpeechSynthesisUtterance(); | ||
const voices = this.getSpeechSynthesisVoices(); | ||
const { text, locale, speechRate, volume, voice, pitchRate } = options; | ||
@@ -108,10 +118,6 @@ if (voice) { | ||
getSpeechSynthesisVoices() { | ||
const speechSynthesis = this.getSpeechSynthesis(); | ||
return speechSynthesis.getVoices(); | ||
} | ||
getSpeechSynthesis() { | ||
if ('speechSynthesis' in window) { | ||
return window.speechSynthesis; | ||
if (!this.speechSynthesis) { | ||
this.throwUnsupportedError(); | ||
} | ||
this.throwUnsupportedError(); | ||
return this.speechSynthesis.getVoices(); | ||
} | ||
@@ -121,3 +127,3 @@ throwUnsupportedError() { | ||
} | ||
throwNotImplementedError() { | ||
throwUnimplementedError() { | ||
throw new Error('Not implemented on web.'); | ||
@@ -124,0 +130,0 @@ } |
{ | ||
"name": "@capacitor-community/text-to-speech", | ||
"version": "0.2.1-dev.7a0918b", | ||
"version": "0.2.1-dev.abde773", | ||
"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/", |
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
71223
470
+ Added@capacitor/core@2.5.0(transitive)
+ Addedtslib@1.14.1(transitive)
- Removed@capacitor/core@latest
- Removed@capacitor/core@6.2.0(transitive)
- Removedtslib@2.8.1(transitive)