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
impl Say
Sourcepub fn new(message: impl Into<String>) -> Self
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}Sourcepub fn voice(self, voice: impl Into<String>) -> Self
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}Sourcepub fn language(self, language: impl Into<String>) -> Self
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}pub fn loop_count(self, loop_count: u32) -> Self
Sourcepub fn add_break(self, strength: Option<String>, time: Option<String>) -> Self
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}Sourcepub fn add_emphasis(
self,
level: Option<String>,
text: impl Into<String>,
) -> Self
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}Sourcepub fn add_prosody(
self,
pitch: Option<String>,
rate: Option<String>,
volume: Option<String>,
text: impl Into<String>,
) -> Self
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}pub fn add_lang( self, xml_lang: impl Into<String>, text: impl Into<String>, ) -> Self
pub fn add_p(self, text: impl Into<String>) -> Self
pub fn add_s(self, text: impl Into<String>) -> Self
pub fn add_phoneme( self, ph: impl Into<String>, text: impl Into<String>, alphabet: Option<String>, ) -> Self
pub fn add_say_as( self, interpret_as: impl Into<String>, text: impl Into<String>, format: Option<String>, ) -> Self
pub fn add_sub(self, alias: impl Into<String>, text: impl Into<String>) -> Self
pub fn add_w(self, text: impl Into<String>, role: Option<String>) -> Self
pub fn add_amazon_effect( self, name: impl Into<String>, text: impl Into<String>, ) -> Self
pub fn add_amazon_domain( self, name: impl Into<String>, text: impl Into<String>, ) -> Self
Trait Implementations§
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more