New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@ask-utils/speech-script

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ask-utils/speech-script

Alexa Speech script (JSX)

latest
Source
npmnpm
Version
3.11.0
Version published
Weekly downloads
6
500%
Maintainers
1
Weekly downloads
 
Created
Source

JSX Speech Script

npm version License: MIT Maintainability Test Coverage Build Status logo

https://ask-utils.dev

Simple skill handler routing libs.

Getting started

$ npm i -S @ask-utils/speech-script

Basic Usage

/** @jsx ssml */
import {
    StandardSkillFactory
} from 'ask-sdk'
import {
    ssml,
    SpeechScriptJSX
} from '../dist/index'
import { LaunchRequest } from 'ask-sdk-model'

/**
 * SSML component like React
 **/
class LaunchRequestScript extends SpeechScriptJSX<LaunchRequest> {
    speech() {
        const { locale } = this.props.request
        if (/^ja/.test(locale)) {
            return (
                <speak>こんにちは!<break time="0.5s"/>お元気ですか?</speak>
            )
        }
        return (
            <speak>
                Hello! <break time="0.5s"/>How are you?
            </speak>
        )
    }
    reprompt() {
        const { locale } = this.props.request
        if (/^ja/.test(locale)) {
            return (
                <speak>
                    お元気ですか?<break time="0.5s"/>
                    <amazon-effect name="whispered">今日はいい日になるといいですね。</amazon-effect>
                </speak>
            )
        }
        return (
            <speak>
                How are you?<break time="0.5s"/>
                <amazon-effect name="whispered">I hope you to have a good day.</amazon-effect>
            </speak>
        )

    }
}

/**
 * Use the SSML component in your RequestHandler
 **/
export const handler = StandardSkillFactory.init()
.addRequestHandlers({
    canHandle(handlerInput) {
        return handlerInput.requestEnvelope.request.type === 'LaunchRequest'
    },
    handle(handlerInput) {
        const Speech = new LaunchRequestScript(handlerInput)
        const {
            speech,
            reprompt,
        } = Speech.create()
        return handlerInput.responseBuilder
            .speak(speech)
            .reprompt(reprompt)
            .getResponse()
    }
}).lambda()

[Advanced] pass optional props from handler

We can pass additional properties from handler to JSX element.

/** @jsx ssml */
import {
    StandardSkillFactory
} from 'ask-sdk'
import {
    ssml,
    SpeechScriptJSX
} from '../dist/index'
import { LaunchRequest } from 'ask-sdk-model'

/**
 * SSML component like React
 **/
class LaunchRequestScript extends SpeechScriptJSX<LaunchRequest, {name: string}> {
    speech() {
        const name = this.options ? `${this.options.name}-san` : ''
        return (
            <speak>
                Hello {name}! <break time="0.5s"/>How are you?
            </speak>
        )
    }
}

/**
 * Use the SSML component in your RequestHandler
 **/
export const handler = StandardSkillFactory.init()
.addRequestHandlers({
    canHandle(handlerInput) {
        return handlerInput.requestEnvelope.request.type === 'LaunchRequest'
    },
    handle(handlerInput) {
        const Speech = new LaunchRequestScript(handlerInput, {
            name: 'John'
        })
        return Speech.createResponse()
    }
}).lambda()

FAQs

Package last updated on 27 Jun 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts