export function listToSpeechReadyString()

in sdk/typescript/libraries/bot-solutions/src/responses/speechUtility.ts [30:55]


    export function listToSpeechReadyString(
        toProcess: PromptOptions|Activity,
        locale: string,
        readOrder: ReadPreference = ReadPreference.Enumeration,
        maxSize: number = 4
    ): string {

        let speakStrings: string[] = [];
        let parent = '';

        if ((toProcess as PromptOptions).choices !== undefined) {
            const selectOption: PromptOptions = toProcess as PromptOptions;
            const choices: (string|Choice)[] = selectOption.choices || [];
            speakStrings = choices.map((value: string|Choice): string => typeof(value) === 'string' ? value : value.value);
            parent = typeof(selectOption.prompt) === 'string'
                ? (selectOption.prompt || '')
                : (selectOption.prompt ? (selectOption.prompt.text || '') : '');
        } else {
            const activity: Activity = toProcess as Activity;
            const attachments: Attachment[] = activity.attachments || [];
            speakStrings = attachments.map((value: Attachment): string => value.content.speak as string);
            parent = activity.speak || '';
        }

        return listToSpeech(parent, speakStrings, readOrder, maxSize, locale);
    }