The string value to validate
true
if the value is a valid break strength, false
otherwise
// Valid strength
if (isValidBreakStrength('medium')) {
// TypeScript now knows this is a BreakStrength
const strength: BreakStrength = 'medium';
}
// Invalid strength
console.log(isValidBreakStrength('very-strong')); // false
// Use in validation
function setBreakStrength(value: string) {
if (!isValidBreakStrength(value)) {
throw new Error(`Invalid break strength: ${value}`);
}
// Safe to use as BreakStrength
}
https://docs.microsoft.com/azure/cognitive-services/speech-service/speech-synthesis-markup#add-a-break Break Element Documentation
Type guard to check if a string is a valid break strength value.
Validates that the provided string is one of the allowed break strength values according to the SSML specification. This function acts as a TypeScript type guard, narrowing the type to
BreakStrength
when it returns true.Valid values:
x-weak
: 250ms pauseweak
: 500ms pausemedium
: 750ms pause (default)strong
: 1000ms pausex-strong
: 1250ms pause