diff --git a/README.md b/README.md index 4bb2a9f..0f520eb 100644 --- a/README.md +++ b/README.md @@ -84,6 +84,7 @@ const isLanguageSupported = async (lang: string) => { * [`openInstall()`](#openinstall) * [`addListener('onRangeStart', ...)`](#addlisteneronrangestart) * [Interfaces](#interfaces) +* [Enums](#enums) @@ -202,7 +203,7 @@ addListener(eventName: 'onRangeStart', listenerFunc: (info: { start: number; end | **`volume`** | number | The volume that the utterance will be spoken at. | 1.0 | | **`voice`** | number | The index of the selected voice that will be used to speak the utterance. Possible voices can be queried using `getSupportedVoices`. | | | **`category`** | string | 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. | "ambient" | -| **`queueStrategy`** | number | Select the strategy to adopt when several requests to speak overlap. Possible values: `0` and `1`. Use `0` to stop the current request when a new request is sent. Use `1` to buffer the speech request. The request will be executed when all previous requests have been completed. | 0 | +| **`queueStrategy`** | QueueStrategy | Select the strategy to adopt when several requests to speak overlap. | QueueStrategy.Flush | 5.1.0 | #### SpeechSynthesisVoice @@ -224,6 +225,17 @@ The SpeechSynthesisVoice interface represent | ------------ | ----------------------------------------- | | **`remove`** | () => Promise<void> | + +### Enums + + +#### QueueStrategy + +| Members | Value | Description | +| ----------- | -------------- | ---------------------------------------------------------------------------------------------------------------------- | +| **`Add`** | 0 | Use `Add` to stop the current request when a new request is sent. | +| **`Flush`** | 1 | Use `Flush` to buffer the speech request. The request will be executed when all previous requests have been completed. | + ## Changelog diff --git a/src/definitions.ts b/src/definitions.ts index a703f4e..1323fe6 100644 --- a/src/definitions.ts +++ b/src/definitions.ts @@ -40,6 +40,17 @@ export interface TextToSpeechPlugin { ): Promise; } +export enum QueueStrategy { + /** + * Use `Add` to stop the current request when a new request is sent. + */ + Add = 0, + /** + * Use `Flush` to buffer the speech request. The request will be executed when all previous requests have been completed. + */ + Flush = 1 +} + export interface TTSOptions { /** * The text that will be synthesised when the utterance is spoken. @@ -89,13 +100,11 @@ export interface TTSOptions { category?: string; /** * Select the strategy to adopt when several requests to speak overlap. - * Possible values: `0` and `1`. - * Use `0` to stop the current request when a new request is sent. - * Use `1` to buffer the speech request. The request will be executed when all previous requests have been completed. * - * @default 0 + * @since 5.1.0 + * @default QueueStrategy.Flush */ - queueStrategy?: number; + queueStrategy?: QueueStrategy; } /**