All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.twilio.twiml.voice.SsmlProsody Maven / Gradle / Ivy

There is a newer version: 10.1.5
Show newest version
/**
 * This code was generated by
 * \ / _    _  _|   _  _
 *  | (_)\/(_)(_|\/| |(/_  v1.0.0
 *       /       /
 */

package com.twilio.twiml.voice;

import com.twilio.twiml.TwiML;

import java.util.HashMap;
import java.util.Map;

/**
 * TwiML wrapper for {@code }
 */
public class SsmlProsody extends TwiML {
    private final String volume;
    private final String rate;
    private final String pitch;
    private final String words;

    /**
     * For XML Serialization/Deserialization
     */
    private SsmlProsody() {
        this(new Builder((String) null));
    }

    /**
     * Create a new {@code } element
     */
    private SsmlProsody(Builder b) {
        super("prosody", b);
        this.volume = b.volume;
        this.rate = b.rate;
        this.pitch = b.pitch;
        this.words = b.words;
    }

    /**
     * The body of the TwiML element
     *
     * @return Element body as a string if present else null
     */
    protected String getElementBody() {
        return this.getWords() == null ? null : this.getWords();
    }

    /**
     * Attributes to set on the generated XML element
     *
     * @return A Map of attribute keys to values
     */
    protected Map getElementAttributes() {
        // Preserve order of attributes
        Map attrs = new HashMap<>();

        if (this.getVolume() != null) {
            attrs.put("volume", this.getVolume());
        }
        if (this.getRate() != null) {
            attrs.put("rate", this.getRate());
        }
        if (this.getPitch() != null) {
            attrs.put("pitch", this.getPitch());
        }

        return attrs;
    }

    /**
     * Specify the volume, available values: default, silent, x-soft, soft, medium,
     * loud, x-loud, +ndB, -ndB
     *
     * @return Specify the volume, available values: default, silent, x-soft, soft,
     *         medium, loud, x-loud, +ndB, -ndB
     */
    public String getVolume() {
        return volume;
    }

    /**
     * Specify the rate, available values: x-slow, slow, medium, fast, x-fast, n%
     *
     * @return Specify the rate, available values: x-slow, slow, medium, fast,
     *         x-fast, n%
     */
    public String getRate() {
        return rate;
    }

    /**
     * Specify the pitch, available values: default, x-low, low, medium, high,
     * x-high, +n%, -n%
     *
     * @return Specify the pitch, available values: default, x-low, low, medium,
     *         high, x-high, +n%, -n%
     */
    public String getPitch() {
        return pitch;
    }

    /**
     * Words to speak
     *
     * @return Words to speak
     */
    public String getWords() {
        return words;
    }

    /**
     * Create a new {@code } element
     */
    public static class Builder extends TwiML.Builder {
        private String volume;
        private String rate;
        private String pitch;
        private String words;

        /**
         * Create a {@code } with words
         */
        public Builder(String words) {
            this.words = words;
        }

        /**
         * Specify the volume, available values: default, silent, x-soft, soft, medium,
         * loud, x-loud, +ndB, -ndB
         */
        public Builder volume(String volume) {
            this.volume = volume;
            return this;
        }

        /**
         * Specify the rate, available values: x-slow, slow, medium, fast, x-fast, n%
         */
        public Builder rate(String rate) {
            this.rate = rate;
            return this;
        }

        /**
         * Specify the pitch, available values: default, x-low, low, medium, high,
         * x-high, +n%, -n%
         */
        public Builder pitch(String pitch) {
            this.pitch = pitch;
            return this;
        }

        /**
         * Create and return resulting {@code } element
         */
        public SsmlProsody build() {
            return new SsmlProsody(this);
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy