Say

Struct Say 

Source
pub struct Say {
    pub attributes: SayAttributes,
    pub message: String,
    pub ssml_elements: Vec<SsmlElement>,
}

Fields§

§attributes: SayAttributes§message: String§ssml_elements: Vec<SsmlElement>

Implementations§

Source§

impl Say

Source

pub fn new(message: impl Into<String>) -> Self

Examples found in repository?
examples/voice_call.rs (lines 55-57)
48fn ivr_menu() {
49    let gather = Gather::new()
50        .input(vec!["dtmf".to_string(), "speech".to_string()])
51        .action("https://example.com/handle-input")
52        .method("POST")
53        .timeout(10)
54        .num_digits(1)
55        .add_say(Say::new(
56            "Press 1 for sales, 2 for support, or 3 for billing. You can also say the department name.",
57        ));
58
59    let response = VoiceResponse::new()
60        .say("Welcome to our automated phone system.")
61        .gather(gather)
62        .say("We didn't receive any input.")
63        .redirect("https://example.com/main-menu");
64
65    println!("{}", response.to_xml());
66}
67
68/// Call forwarding to a phone number
69fn call_forwarding() {
70    let dial = Dial::new()
71        .timeout(30)
72        .add_number(DialNumber::new("+15559876543").send_digits("wwww1234"));
73
74    let response = VoiceResponse::new()
75        .say("Please wait while we connect your call.")
76        .dial_with(dial)
77        .say("The call could not be completed. Please try again later.")
78        .hangup();
79
80    println!("{}", response.to_xml());
81}
82
83/// Voicemail recording system
84fn voicemail() {
85    let record = Record::new()
86        .action("https://example.com/handle-recording")
87        .method("POST")
88        .max_length(120)
89        .finish_on_key("#")
90        .transcribe(true)
91        .transcribe_callback("https://example.com/transcription");
92
93    let response = VoiceResponse::new()
94        .say("Please leave a message after the beep. Press the pound key when finished.")
95        .record(record)
96        .say("Thank you for your message. Goodbye!")
97        .hangup();
98
99    println!("{}", response.to_xml());
100}
101
102/// Advanced SSML features
103fn advanced_ssml() {
104    let say = Say::new("Welcome to our service")
105        .voice("Polly.Joanna")
106        .language("en-US")
107        .add_break(Some("medium".to_string()), None)
108        .add_emphasis(Some("strong".to_string()), "Please listen carefully")
109        .add_break(None, Some("1s".to_string()))
110        .add_prosody(
111            Some("high".to_string()),
112            Some("slow".to_string()),
113            None,
114            "This is important information",
115        );
116
117    let response = VoiceResponse::new()
118        .say_with(say)
119        .play("https://example.com/music.mp3")
120        .hangup();
121
122    println!("{}", response.to_xml());
123}
Source

pub fn voice(self, voice: impl Into<String>) -> Self

Examples found in repository?
examples/voice_call.rs (line 105)
103fn advanced_ssml() {
104    let say = Say::new("Welcome to our service")
105        .voice("Polly.Joanna")
106        .language("en-US")
107        .add_break(Some("medium".to_string()), None)
108        .add_emphasis(Some("strong".to_string()), "Please listen carefully")
109        .add_break(None, Some("1s".to_string()))
110        .add_prosody(
111            Some("high".to_string()),
112            Some("slow".to_string()),
113            None,
114            "This is important information",
115        );
116
117    let response = VoiceResponse::new()
118        .say_with(say)
119        .play("https://example.com/music.mp3")
120        .hangup();
121
122    println!("{}", response.to_xml());
123}
Source

pub fn language(self, language: impl Into<String>) -> Self

Examples found in repository?
examples/voice_call.rs (line 106)
103fn advanced_ssml() {
104    let say = Say::new("Welcome to our service")
105        .voice("Polly.Joanna")
106        .language("en-US")
107        .add_break(Some("medium".to_string()), None)
108        .add_emphasis(Some("strong".to_string()), "Please listen carefully")
109        .add_break(None, Some("1s".to_string()))
110        .add_prosody(
111            Some("high".to_string()),
112            Some("slow".to_string()),
113            None,
114            "This is important information",
115        );
116
117    let response = VoiceResponse::new()
118        .say_with(say)
119        .play("https://example.com/music.mp3")
120        .hangup();
121
122    println!("{}", response.to_xml());
123}
Source

pub fn loop_count(self, loop_count: u32) -> Self

Source

pub fn add_break(self, strength: Option<String>, time: Option<String>) -> Self

Examples found in repository?
examples/voice_call.rs (line 107)
103fn advanced_ssml() {
104    let say = Say::new("Welcome to our service")
105        .voice("Polly.Joanna")
106        .language("en-US")
107        .add_break(Some("medium".to_string()), None)
108        .add_emphasis(Some("strong".to_string()), "Please listen carefully")
109        .add_break(None, Some("1s".to_string()))
110        .add_prosody(
111            Some("high".to_string()),
112            Some("slow".to_string()),
113            None,
114            "This is important information",
115        );
116
117    let response = VoiceResponse::new()
118        .say_with(say)
119        .play("https://example.com/music.mp3")
120        .hangup();
121
122    println!("{}", response.to_xml());
123}
Source

pub fn add_emphasis( self, level: Option<String>, text: impl Into<String>, ) -> Self

Examples found in repository?
examples/voice_call.rs (line 108)
103fn advanced_ssml() {
104    let say = Say::new("Welcome to our service")
105        .voice("Polly.Joanna")
106        .language("en-US")
107        .add_break(Some("medium".to_string()), None)
108        .add_emphasis(Some("strong".to_string()), "Please listen carefully")
109        .add_break(None, Some("1s".to_string()))
110        .add_prosody(
111            Some("high".to_string()),
112            Some("slow".to_string()),
113            None,
114            "This is important information",
115        );
116
117    let response = VoiceResponse::new()
118        .say_with(say)
119        .play("https://example.com/music.mp3")
120        .hangup();
121
122    println!("{}", response.to_xml());
123}
Source

pub fn add_prosody( self, pitch: Option<String>, rate: Option<String>, volume: Option<String>, text: impl Into<String>, ) -> Self

Examples found in repository?
examples/voice_call.rs (lines 110-115)
103fn advanced_ssml() {
104    let say = Say::new("Welcome to our service")
105        .voice("Polly.Joanna")
106        .language("en-US")
107        .add_break(Some("medium".to_string()), None)
108        .add_emphasis(Some("strong".to_string()), "Please listen carefully")
109        .add_break(None, Some("1s".to_string()))
110        .add_prosody(
111            Some("high".to_string()),
112            Some("slow".to_string()),
113            None,
114            "This is important information",
115        );
116
117    let response = VoiceResponse::new()
118        .say_with(say)
119        .play("https://example.com/music.mp3")
120        .hangup();
121
122    println!("{}", response.to_xml());
123}
Source

pub fn add_lang( self, xml_lang: impl Into<String>, text: impl Into<String>, ) -> Self

Source

pub fn add_p(self, text: impl Into<String>) -> Self

Source

pub fn add_s(self, text: impl Into<String>) -> Self

Source

pub fn add_phoneme( self, ph: impl Into<String>, text: impl Into<String>, alphabet: Option<String>, ) -> Self

Source

pub fn add_say_as( self, interpret_as: impl Into<String>, text: impl Into<String>, format: Option<String>, ) -> Self

Source

pub fn add_sub(self, alias: impl Into<String>, text: impl Into<String>) -> Self

Source

pub fn add_w(self, text: impl Into<String>, role: Option<String>) -> Self

Source

pub fn add_amazon_effect( self, name: impl Into<String>, text: impl Into<String>, ) -> Self

Source

pub fn add_amazon_domain( self, name: impl Into<String>, text: impl Into<String>, ) -> Self

Trait Implementations§

Source§

impl Clone for Say

Source§

fn clone(&self) -> Say

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Say

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Say

§

impl RefUnwindSafe for Say

§

impl Send for Say

§

impl Sync for Say

§

impl Unpin for Say

§

impl UnwindSafe for Say

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.