@capacitor-community/text-to-speech
Advanced tools
Comparing version 0.2.3-dev.6ffcfb9 to 0.2.3-dev.83c4370
@@ -64,37 +64,5 @@ { | ||
"tags": [], | ||
"docs": "Verifies proper installation and availability of resource files on the system.", | ||
"docs": "Verifies proper installation and availability of resource files on the system.\r\n\r\nOnly available for Android.", | ||
"complexTypes": [], | ||
"slug": "openinstall" | ||
}, | ||
{ | ||
"name": "setPitchRate", | ||
"signature": "(options: { pitchRate: number; }) => Promise<void>", | ||
"parameters": [ | ||
{ | ||
"name": "options", | ||
"docs": "", | ||
"type": "{ pitchRate: number; }" | ||
} | ||
], | ||
"returns": "Promise<void>", | ||
"tags": [], | ||
"docs": "Changes the pitch rate while the text is being played.\n\nOnly available for Android.", | ||
"complexTypes": [], | ||
"slug": "setpitchrate" | ||
}, | ||
{ | ||
"name": "setSpeechRate", | ||
"signature": "(options: { speechRate: number; }) => Promise<void>", | ||
"parameters": [ | ||
{ | ||
"name": "options", | ||
"docs": "", | ||
"type": "{ speechRate: number; }" | ||
} | ||
], | ||
"returns": "Promise<void>", | ||
"tags": [], | ||
"docs": "Changes the speech rate while the text is being played.\n\nOnly available for Android.", | ||
"complexTypes": [], | ||
"slug": "setspeechrate" | ||
} | ||
@@ -115,3 +83,3 @@ ], | ||
"tags": [], | ||
"docs": "Text to be spoken.", | ||
"docs": "The text that will be synthesised when the utterance is spoken.", | ||
"complexTypes": [], | ||
@@ -121,5 +89,5 @@ "type": "string" | ||
{ | ||
"name": "locale", | ||
"name": "lang", | ||
"tags": [], | ||
"docs": "Language spoken in.\nPossible languages can be queried using `getSupportedLanguages`.\n\nDefault: `en-US`", | ||
"docs": "The language of the utterance.\r\nPossible languages can be queried using `getSupportedLanguages`.\r\n\r\nDefault: `en-US`.", | ||
"complexTypes": [], | ||
@@ -129,5 +97,5 @@ "type": "string | undefined" | ||
{ | ||
"name": "speechRate", | ||
"name": "rate", | ||
"tags": [], | ||
"docs": "The speech rate.\n\nDefault: `1.0`", | ||
"docs": "The speed at which the utterance will be spoken at.\r\n\r\nDefault: `1.0`.", | ||
"complexTypes": [], | ||
@@ -137,5 +105,5 @@ "type": "number | undefined" | ||
{ | ||
"name": "pitchRate", | ||
"name": "pitch", | ||
"tags": [], | ||
"docs": "The pitch rate.\n\nDefault: `1.0`", | ||
"docs": "The pitch at which the utterance will be spoken at.\r\n\r\nDefault: `1.0`.", | ||
"complexTypes": [], | ||
@@ -147,3 +115,3 @@ "type": "number | undefined" | ||
"tags": [], | ||
"docs": "The volume.\n\nDefault: `1.0`", | ||
"docs": "The volume that the utterance will be spoken at.\r\n\r\nDefault: `1.0`.", | ||
"complexTypes": [], | ||
@@ -155,3 +123,3 @@ "type": "number | undefined" | ||
"tags": [], | ||
"docs": "The index of the selected voice.\nPossible voices can be queried using `getSupportedVoices`.\n\nOnly available for Web.", | ||
"docs": "The index of the selected voice that will be used to speak the utterance.\r\nPossible voices can be queried using `getSupportedVoices`.\r\n\r\nOnly available for Web.", | ||
"complexTypes": [], | ||
@@ -163,3 +131,3 @@ "type": "number | undefined" | ||
"tags": [], | ||
"docs": "Select the iOS Audio session category.\nPossible values: `ambient` and `playback`\nUse `playback` to play audio even when the app is in the background.\n\nOnly available for iOS.\n\nDefault: `ambient`", | ||
"docs": "Select the iOS Audio session category.\r\nPossible values: `ambient` and `playback`.\r\nUse `playback` to play audio even when the app is in the background.\r\n\r\nOnly available for iOS.\r\n\r\nDefault: `ambient`.", | ||
"complexTypes": [], | ||
@@ -187,3 +155,3 @@ "type": "string | undefined" | ||
"tags": [], | ||
"docs": "BCP 47 language tag indicating the language of the voice.\nExample: `en-US`", | ||
"docs": "BCP 47 language tag indicating the language of the voice.\r\nExample: `en-US`.", | ||
"complexTypes": [], | ||
@@ -202,3 +170,3 @@ "type": "string" | ||
"tags": [], | ||
"docs": "Human-readable name that represents the voice.\nExample: `Microsoft Zira Desktop - English (United States)`", | ||
"docs": "Human-readable name that represents the voice.\r\nExample: `Microsoft Zira Desktop - English (United States)`.", | ||
"complexTypes": [], | ||
@@ -210,3 +178,3 @@ "type": "string" | ||
"tags": [], | ||
"docs": "Type of URI and location of the speech synthesis service for this voice.\nExample: `urn:moz-tts:sapi:Microsoft Zira Desktop - English (United States)?en-US`", | ||
"docs": "Type of URI and location of the speech synthesis service for this voice.\r\nExample: `urn:moz-tts:sapi:Microsoft Zira Desktop - English (United States)?en-US`.", | ||
"complexTypes": [], | ||
@@ -213,0 +181,0 @@ "type": "string" |
@@ -24,53 +24,39 @@ export interface TextToSpeechPlugin { | ||
* Verifies proper installation and availability of resource files on the system. | ||
*/ | ||
openInstall(): Promise<void>; | ||
/** | ||
* Changes the pitch rate while the text is being played. | ||
* | ||
* Only available for Android. | ||
*/ | ||
setPitchRate(options: { | ||
pitchRate: number; | ||
}): Promise<void>; | ||
/** | ||
* Changes the speech rate while the text is being played. | ||
* | ||
* Only available for Android. | ||
*/ | ||
setSpeechRate(options: { | ||
speechRate: number; | ||
}): Promise<void>; | ||
openInstall(): Promise<void>; | ||
} | ||
export interface TTSOptions { | ||
/** | ||
* Text to be spoken. | ||
* The text that will be synthesised when the utterance is spoken. | ||
*/ | ||
text: string; | ||
/** | ||
* Language spoken in. | ||
* The language of the utterance. | ||
* Possible languages can be queried using `getSupportedLanguages`. | ||
* | ||
* Default: `en-US` | ||
* Default: `en-US`. | ||
*/ | ||
locale?: string; | ||
lang?: string; | ||
/** | ||
* The speech rate. | ||
* The speed at which the utterance will be spoken at. | ||
* | ||
* Default: `1.0` | ||
* Default: `1.0`. | ||
*/ | ||
speechRate?: number; | ||
rate?: number; | ||
/** | ||
* The pitch rate. | ||
* The pitch at which the utterance will be spoken at. | ||
* | ||
* Default: `1.0` | ||
* Default: `1.0`. | ||
*/ | ||
pitchRate?: number; | ||
pitch?: number; | ||
/** | ||
* The volume. | ||
* The volume that the utterance will be spoken at. | ||
* | ||
* Default: `1.0` | ||
* Default: `1.0`. | ||
*/ | ||
volume?: number; | ||
/** | ||
* The index of the selected voice. | ||
* The index of the selected voice that will be used to speak the utterance. | ||
* Possible voices can be queried using `getSupportedVoices`. | ||
@@ -83,3 +69,3 @@ * | ||
* Select the iOS Audio session category. | ||
* Possible values: `ambient` and `playback` | ||
* Possible values: `ambient` and `playback`. | ||
* Use `playback` to play audio even when the app is in the background. | ||
@@ -89,3 +75,3 @@ * | ||
* | ||
* Default: `ambient` | ||
* Default: `ambient`. | ||
*/ | ||
@@ -104,3 +90,3 @@ category?: string; | ||
* BCP 47 language tag indicating the language of the voice. | ||
* Example: `en-US` | ||
* Example: `en-US`. | ||
*/ | ||
@@ -114,3 +100,3 @@ lang: string; | ||
* Human-readable name that represents the voice. | ||
* Example: `Microsoft Zira Desktop - English (United States)` | ||
* Example: `Microsoft Zira Desktop - English (United States)`. | ||
*/ | ||
@@ -120,5 +106,5 @@ 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` | ||
* Example: `urn:moz-tts:sapi:Microsoft Zira Desktop - English (United States)?en-US`. | ||
*/ | ||
voiceURI: string; | ||
} |
@@ -5,4 +5,8 @@ import { registerPlugin } from '@capacitor/core'; | ||
}); | ||
// Warm up | ||
if ('speechSynthesis' in window) { | ||
window.speechSynthesis; | ||
} | ||
export * from './definitions'; | ||
export { TextToSpeech }; | ||
//# sourceMappingURL=index.js.map |
@@ -16,8 +16,2 @@ import { WebPlugin } from '@capacitor/core'; | ||
openInstall(): Promise<void>; | ||
setPitchRate(_options: { | ||
pitchRate: number; | ||
}): Promise<void>; | ||
setSpeechRate(_options: { | ||
speechRate: number; | ||
}): Promise<void>; | ||
private createSpeechSynthesisUtterance; | ||
@@ -24,0 +18,0 @@ private getSpeechSynthesisVoices; |
import { WebPlugin } from '@capacitor/core'; | ||
export class TextToSpeechWeb extends WebPlugin { | ||
constructor() { | ||
super({ | ||
name: 'TextToSpeech', | ||
platforms: ['web'], | ||
}); | ||
super(); | ||
this.speechSynthesis = null; | ||
@@ -49,12 +46,6 @@ if ('speechSynthesis' in window) { | ||
} | ||
async setPitchRate(_options) { | ||
this.throwUnimplementedError(); | ||
} | ||
async setSpeechRate(_options) { | ||
this.throwUnimplementedError(); | ||
} | ||
createSpeechSynthesisUtterance(options) { | ||
const voices = this.getSpeechSynthesisVoices(); | ||
const utterance = new SpeechSynthesisUtterance(); | ||
const { text, locale, speechRate, volume, voice, pitchRate } = options; | ||
const { text, lang, rate, pitch, volume, voice } = options; | ||
if (voice) { | ||
@@ -66,10 +57,10 @@ utterance.voice = voices[voice]; | ||
} | ||
if (speechRate) { | ||
utterance.rate = speechRate >= 0.1 && speechRate <= 10 ? speechRate : 1; | ||
if (rate) { | ||
utterance.rate = rate >= 0.1 && rate <= 10 ? rate : 1; | ||
} | ||
if (pitchRate) { | ||
utterance.pitch = pitchRate >= 0 && pitchRate <= 2 ? pitchRate : 2; | ||
if (pitch) { | ||
utterance.pitch = pitch >= 0 && pitch <= 2 ? pitch : 2; | ||
} | ||
if (locale) { | ||
utterance.lang = locale; | ||
if (lang) { | ||
utterance.lang = lang; | ||
} | ||
@@ -76,0 +67,0 @@ utterance.text = text; |
@@ -13,6 +13,3 @@ 'use strict'; | ||
constructor() { | ||
super({ | ||
name: 'TextToSpeech', | ||
platforms: ['web'], | ||
}); | ||
super(); | ||
this.speechSynthesis = null; | ||
@@ -59,12 +56,6 @@ if ('speechSynthesis' in window) { | ||
} | ||
async setPitchRate(_options) { | ||
this.throwUnimplementedError(); | ||
} | ||
async setSpeechRate(_options) { | ||
this.throwUnimplementedError(); | ||
} | ||
createSpeechSynthesisUtterance(options) { | ||
const voices = this.getSpeechSynthesisVoices(); | ||
const utterance = new SpeechSynthesisUtterance(); | ||
const { text, locale, speechRate, volume, voice, pitchRate } = options; | ||
const { text, lang, rate, pitch, volume, voice } = options; | ||
if (voice) { | ||
@@ -76,10 +67,10 @@ utterance.voice = voices[voice]; | ||
} | ||
if (speechRate) { | ||
utterance.rate = speechRate >= 0.1 && speechRate <= 10 ? speechRate : 1; | ||
if (rate) { | ||
utterance.rate = rate >= 0.1 && rate <= 10 ? rate : 1; | ||
} | ||
if (pitchRate) { | ||
utterance.pitch = pitchRate >= 0 && pitchRate <= 2 ? pitchRate : 2; | ||
if (pitch) { | ||
utterance.pitch = pitch >= 0 && pitch <= 2 ? pitch : 2; | ||
} | ||
if (locale) { | ||
utterance.lang = locale; | ||
if (lang) { | ||
utterance.lang = lang; | ||
} | ||
@@ -86,0 +77,0 @@ utterance.text = text; |
@@ -10,6 +10,3 @@ var capacitorTextToSpeech = (function (exports, core) { | ||
constructor() { | ||
super({ | ||
name: 'TextToSpeech', | ||
platforms: ['web'], | ||
}); | ||
super(); | ||
this.speechSynthesis = null; | ||
@@ -56,12 +53,6 @@ if ('speechSynthesis' in window) { | ||
} | ||
async setPitchRate(_options) { | ||
this.throwUnimplementedError(); | ||
} | ||
async setSpeechRate(_options) { | ||
this.throwUnimplementedError(); | ||
} | ||
createSpeechSynthesisUtterance(options) { | ||
const voices = this.getSpeechSynthesisVoices(); | ||
const utterance = new SpeechSynthesisUtterance(); | ||
const { text, locale, speechRate, volume, voice, pitchRate } = options; | ||
const { text, lang, rate, pitch, volume, voice } = options; | ||
if (voice) { | ||
@@ -73,10 +64,10 @@ utterance.voice = voices[voice]; | ||
} | ||
if (speechRate) { | ||
utterance.rate = speechRate >= 0.1 && speechRate <= 10 ? speechRate : 1; | ||
if (rate) { | ||
utterance.rate = rate >= 0.1 && rate <= 10 ? rate : 1; | ||
} | ||
if (pitchRate) { | ||
utterance.pitch = pitchRate >= 0 && pitchRate <= 2 ? pitchRate : 2; | ||
if (pitch) { | ||
utterance.pitch = pitch >= 0 && pitch <= 2 ? pitch : 2; | ||
} | ||
if (locale) { | ||
utterance.lang = locale; | ||
if (lang) { | ||
utterance.lang = lang; | ||
} | ||
@@ -83,0 +74,0 @@ utterance.text = text; |
{ | ||
"name": "@capacitor-community/text-to-speech", | ||
"version": "0.2.3-dev.6ffcfb9", | ||
"version": "0.2.3-dev.83c4370", | ||
"description": "Capacitor plugin for synthesizing speech from text.", | ||
@@ -5,0 +5,0 @@ "main": "dist/plugin.cjs.js", |
@@ -83,5 +83,5 @@ <p align="center"><br><img src="https://user-images.githubusercontent.com/236501/85893648-1c92e880-b7a8-11ea-926d-95355b8175c7.png" width="128" height="128" /></p> | ||
text: 'This is a sample text.', | ||
locale: 'en_US', | ||
speechRate: 1.0, | ||
pitchRate: 1.0, | ||
lang: 'en_US', | ||
rate: 1.0, | ||
pitch: 1.0, | ||
volume: 1.0, | ||
@@ -103,14 +103,2 @@ category: 'ambient', | ||
}; | ||
const setPitchRate = async () => { | ||
await TextToSpeech.setPitchRate({ | ||
pitchRate: 1.5, | ||
}); | ||
}; | ||
const setSpeechRate = async () => { | ||
await TextToSpeech.setSpeechRate({ | ||
speechRate: 0.5, | ||
}); | ||
}; | ||
``` | ||
@@ -127,4 +115,2 @@ | ||
* [`openInstall()`](#openinstall) | ||
* [`setPitchRate(...)`](#setpitchrate) | ||
* [`setSpeechRate(...)`](#setspeechrate) | ||
* [Interfaces](#interfaces) | ||
@@ -197,39 +183,7 @@ | ||
-------------------- | ||
### setPitchRate(...) | ||
```typescript | ||
setPitchRate(options: { pitchRate: number; }) => Promise<void> | ||
``` | ||
Changes the pitch rate while the text is being played. | ||
Only available for Android. | ||
| Param | Type | | ||
| ------------- | ----------------------------------- | | ||
| **`options`** | <code>{ pitchRate: number; }</code> | | ||
-------------------- | ||
### setSpeechRate(...) | ||
```typescript | ||
setSpeechRate(options: { speechRate: number; }) => Promise<void> | ||
``` | ||
Changes the speech rate while the text is being played. | ||
Only available for Android. | ||
| Param | Type | | ||
| ------------- | ------------------------------------ | | ||
| **`options`** | <code>{ speechRate: number; }</code> | | ||
-------------------- | ||
### Interfaces | ||
@@ -240,11 +194,11 @@ | ||
| Prop | Type | Description | | ||
| ---------------- | ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | ||
| **`text`** | <code>string</code> | Text to be spoken. | | ||
| **`locale`** | <code>string</code> | Language spoken in. Possible languages can be queried using `getSupportedLanguages`. Default: `en-US` | | ||
| **`speechRate`** | <code>number</code> | The speech rate. Default: `1.0` | | ||
| **`pitchRate`** | <code>number</code> | The pitch rate. Default: `1.0` | | ||
| **`volume`** | <code>number</code> | The volume. Default: `1.0` | | ||
| **`voice`** | <code>number</code> | The index of the selected voice. Possible voices can be queried using `getSupportedVoices`. Only available for Web. | | ||
| **`category`** | <code>string</code> | Select the iOS Audio session category. Possible values: `ambient` and `playback` Use `playback` to play audio even when the app is in the background. Only available for iOS. Default: `ambient` | | ||
| Prop | Type | Description | | ||
| -------------- | ------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | ||
| **`text`** | <code>string</code> | The text that will be synthesised when the utterance is spoken. | | ||
| **`lang`** | <code>string</code> | The language of the utterance. Possible languages can be queried using `getSupportedLanguages`. Default: `en-US`. | | ||
| **`rate`** | <code>number</code> | The speed at which the utterance will be spoken at. Default: `1.0`. | | ||
| **`pitch`** | <code>number</code> | The pitch at which the utterance will be spoken at. Default: `1.0`. | | ||
| **`volume`** | <code>number</code> | The volume that the utterance will be spoken at. Default: `1.0`. | | ||
| **`voice`** | <code>number</code> | The index of the selected voice that will be used to speak the utterance. Possible voices can be queried using `getSupportedVoices`. Only available for Web. | | ||
| **`category`** | <code>string</code> | Select the iOS Audio session category. Possible values: `ambient` and `playback`. Use `playback` to play audio even when the app is in the background. Only available for iOS. Default: `ambient`. | | ||
@@ -256,9 +210,9 @@ | ||
| Prop | Type | Description | | ||
| ------------------ | -------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | | ||
| **`default`** | <code>boolean</code> | Specifies whether the voice is the default voice for the current app (`true`) or not (`false`). | | ||
| **`lang`** | <code>string</code> | BCP 47 language tag indicating the language of the voice. Example: `en-US` | | ||
| **`localService`** | <code>boolean</code> | Specifies whether the voice is supplied by a local (`true`) or remote (`false`) speech synthesizer service. | | ||
| **`name`** | <code>string</code> | Human-readable name that represents the voice. Example: `Microsoft Zira Desktop - English (United States)` | | ||
| **`voiceURI`** | <code>string</code> | 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` | | ||
| Prop | Type | Description | | ||
| ------------------ | -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | | ||
| **`default`** | <code>boolean</code> | Specifies whether the voice is the default voice for the current app (`true`) or not (`false`). | | ||
| **`lang`** | <code>string</code> | BCP 47 language tag indicating the language of the voice. Example: `en-US`. | | ||
| **`localService`** | <code>boolean</code> | Specifies whether the voice is supplied by a local (`true`) or remote (`false`) speech synthesizer service. | | ||
| **`name`** | <code>string</code> | Human-readable name that represents the voice. Example: `Microsoft Zira Desktop - English (United States)`. | | ||
| **`voiceURI`** | <code>string</code> | 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`. | | ||
@@ -265,0 +219,0 @@ </docgen-api> |
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
70675
823
222