Skip to content

Commit 8808b04

Browse files
Jonatas Baldindprothero
authored andcommitted
Add PHP and Ruby examples for SSML (TwilioDevEd#676)
1 parent 7721bb0 commit 8808b04

File tree

2 files changed

+37
-2
lines changed

2 files changed

+37
-2
lines changed

twiml/voice/say/ssml/ssml.5.x.php

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,20 @@
11
<?php
2-
/* SSML support for PHP coming soon */
2+
require_once 'vendor/autoload.php';
3+
use Twilio\TwiML\VoiceResponse;
4+
5+
$response = new VoiceResponse();
6+
$say = $response->say('Hi', ['voice' => 'Polly.Joanna']);
7+
$say->break_(['strength' => 'x-weak', 'time' => '100ms']);
8+
$say->emphasis('Words to emphasize', ['level' => 'moderate']);
9+
$say->p('Words to speak');
10+
$say->append('aaaaaa');
11+
$say->phoneme('Words to speak', ['alphabet' => 'x-sampa', 'ph' => 'pɪˈkɑːn']);
12+
$say->append('bbbbbbb');
13+
$say->prosody('Words to speak', ['pitch' => '-10%', 'rate' => '85%', 'volume' => '-6dB']);
14+
$say->s('Words to speak');
15+
$say->say_as('Words to speak', ['interpret-as' => 'spell-out', 'role' => 'yyyymmdd']);
16+
$say->sub('Words to be substituted', ['alias' => 'alias']);
17+
$say->w('Words to speak');
18+
19+
echo $response;
20+
?>

twiml/voice/say/ssml/ssml.5.x.rb

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,18 @@
1-
# SSML support for Ruby coming soon.
1+
require 'twilio-ruby'
2+
3+
response = Twilio::TwiML::VoiceResponse.new
4+
response.say(voice: 'Polly.Joanna', message: 'Hi') do |say|
5+
say.break(strength: 'x-weak', time: '100ms')
6+
say.emphasis('Words to emphasize', level: 'moderate')
7+
say.p('Words to speak')
8+
say.add_text('aaaaaa')
9+
say.phoneme('Words to speak', alphabet: 'x-sampa', ph: 'pɪˈkɑːn')
10+
say.add_text('bbbbbbb')
11+
say.prosody('Words to speak', pitch: '-10%', rate: '85%', volume: '-6dB')
12+
say.s('Words to speak')
13+
say.say_as('Words to speak', interpretAs: 'spell-out', role: 'yyyymmdd')
14+
say.sub('Words to be substituted', alias: 'alias')
15+
say.w('Words to speak')
16+
end
17+
18+
puts response

0 commit comments

Comments
 (0)