declare type Synthesizer = 'google' | 'aws';
export interface OptionsInput {
/**
* Default: `1500`
*
* The amount of characters the script will start trying to break-up your SSML in multiple parts.
* You can tweak this number to see what works for you.
*/
softLimit?: number;
/**
* Default: `3000`
*
* The amount of characters the script should stay below for maximum size per SSML part. If any batch size goes above this, the script will error.
*/
hardLimit?: number;
/**
* Default: `,;.`
*
* Text can be split at these given characters.
*/
extraSplitChars?: string;
/**
* Default: `false`
*
* Set to `true` to allow the script to break up large paragraphs
* by removing the `
` and replacing the `
` with a ``,
* which results in the same pause. Source: https://docs.aws.amazon.com/polly/latest/dg/supportedtags.html#p-tag
*
* This allows the script to properly split large paragraph's and to send less batches to the text to speech API's.
*
* It is also recommended to set this to `true` when you work with large paragraphs and experiencing errors
* like "SSML tag appeared to be too long".
*/
breakParagraphsAboveHardLimit?: boolean;
/**
* Default: `aws`
*
* Set to which synthesizer you are using. Useful for when you use `breakParagraphsAboveHardLimit: true`,
* to set the correct break length, as that differs per service.
*/
synthesizer?: Synthesizer;
}
export interface Options {
hardLimit: number;
softLimit: number;
extraSplitChars: string;
breakParagraphsAboveHardLimit: boolean;
synthesizer: Synthesizer;
defaultParagraphBreakSSMLTag: string;
}
/**
* Creates a tree data structure from SSML text.
* @class
*/
export declare class SSMLSplit {
options: Options;
private root;
private batches;
private accumulatedSSML;
private textLength;
constructor(options?: OptionsInput);
/**
* Split SSML text by batches of ~3000 (by default) chars.
*
* @throws {NotPossibleSplitError} Text cannot be split, increase `hardLimit`.
* @throws {SSMLParseError} Argument `ssml` is not a valid SSML string.
*/
split(ssmlInput: string): string[];
private get characterCounter();
private setDefaults;
/**
* Sanitizes the input SSML by removing new lines, excessive white spaces, and empty tags.
*
* @param ssml
*/
private sanitize;
private traverseNode;
private splitTextNode;
private noChildrenNodeToText;
/**
* Pushes a SSML string into the batch array
*/
private makeSpeakBatch;
/**
* Adds a new tree node as a parentNode child.
*/
private addNode;
/**
* Creates tree data structure from SSML text.
*/
private buildTree;
}
export default SSMLSplit;