Play Text During a Call
This endpoint allows you to speak text in an active call.
API Endpoint
POST
https://api.plivo.com/v1/Account/{auth_id}/Call/{call_uuid}/Speak/
Arguments
text Required | The text that needs to be spoken in the ongoing call |
voice string | The voice in which the text should be spoken. The two allowed values are MAN and WOMAN. The default voice used is WOMAN |
language string | The language that needs to be used to speak the text. The default language is US English (en-US). The complete list of supported languages can be found in List of Languages Supported section. |
legs string | The call leg in which the text has to be spoken. This can take three values aleg (first leg of the call), bleg(second leg of the call) or both. The default value is aleg. |
loop boolean | If set to true, the text will be spoken repeatedly unless stopped. The default value is set to false. |
mix boolean | This flag is used to determine the behaviour of current call audio when the file is being played. If this is set to ‘false’ then participants of the call would not be able to hear anyone speaking in the call until the Play is stopped. If set to ‘true’ both call audio and the Play audio will be mixed and played. Defaults to true. |
List of Languages Supported
Danish da-DK | Only WOMAN voice |
Dutch nl-NL | Both WOMAN and MAN voices |
English - Australian en-AU | Both WOMAN and MAN voices |
English - British en-GB | Both WOMAN and MAN voices |
English - USA en-US | Both WOMAN and MAN voices |
French fr-FR | Both WOMAN and MAN voices |
French - Canadian fr-CA | Only WOMAN voice |
German de-DE | Both WOMAN and MAN voices |
Italian it-IT | Both WOMAN and MAN voices |
Polish pl-PL | Both WOMAN and MAN voices |
Portugese pt-PT | Only MAN voice |
Portugese - Brazilian pt-BR | Both WOMAN and MAN voices |
Russian ru-RU | Only WOMAN voice |
Spanish es-ES | Both WOMAN and MAN voices |
Spanish - USA es-US | Both WOMAN and MAN voices |
Swedish sv-SE | Only WOMAN voice |
Returns
If successful this endpoint returns an acknowledgement that the written text is being spoken in the call
Response
HTTP Status Code: 202
{
"message": "speak started",
"api_id": "07abfd94-58c0-11e1-86da-adf28403fe48"
}
Example Request
1
2
3
4
5
6
7
import plivo
client = plivo.RestClient()
response = client.calls.speak(
call_uuid='3a2e4c90-dcee-4931-8a59-f123ab507e60',
text='Hello World', )
print(response)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#
# Example for Call Speak Create
#
require 'rubygems'
require 'plivo'
include Plivo
include Plivo::Exceptions
api = RestClient.new("YOUR_AUTH_ID", "YOUR_AUTH_TOKEN")
begin
response = api.calls.speak(
'eba53b9e-8fbd-45c1-9444-696d2172fbc8',
'Hello World'
)
puts response
rescue PlivoRESTError => e
puts 'Exception: ' + e.message
end
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// Example for Call Speak create
var plivo = require('plivo');
(function main() {
'use strict';
// As the auth_id and auth_token are unspecified, Plivo will fetch them from the PLIVO_AUTH_ID and PLIVO_AUTH_TOKEN environment variables.
var client = new plivo.Client();
client.calls.speakText(
"eba53b9e-8fbd-45c1-9444-696d2172fbc8", // call uuid
"Hello World", // text
).then(function (response) {
console.log(response);
}, function (err) {
console.error(err);
});
})();
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<?php
/**
* Example for Call Speak create
*/
require 'vendor/autoload.php';
use Plivo\RestClient;
use Plivo\Exceptions\PlivoRestException;
$client = new RestClient("YOUR_AUTH_ID", "YOUR_AUTH_TOKEN");
try {
$response = $client->calls->startSpeaking(
'eba53b9e-8fbd-45c1-9444-696d2172fbc8',
'Hello World'
);
print_r($response);
}
catch (PlivoRestException $ex) {
print_r($ex);
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
package com.plivo.api.samples.call.speak;
import java.io.IOException;
import com.plivo.api.Plivo;
import com.plivo.api.exceptions.PlivoRestException;
import com.plivo.api.models.call.Call;
import com.plivo.api.models.call.actions.CallSpeakCreateResponse;
/**
* Example for Call Speak create
*/
class SpeakCreate {
public static void main(String [] args) {
Plivo.init();
try {
CallSpeakCreateResponse response = Call.speaker("eba53b9e-8fbd-45c1-9444-696d2172fbc8", "Hello World")
.speak();
System.out.println(response);
} catch (PlivoRestException | IOException e) {
e.printStackTrace();
}
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/**
* Example for Call Speak Create
*/
using System;
using System.Collections.Generic;
using Plivo;
using Plivo.Exception;
namespace PlivoExamples
{
internal class Program
{
public static void Main(string[] args)
{
var api = new PlivoApi("YOUR_AUTH_ID", "YOUR_AUTH_TOKEN");
try
{
var response = api.Call.StartSpeaking(
callUuid:"93b35e56-5b28-47fc-95aa-8536625d3ac1",
text:"Hello World"
);
Console.WriteLine(response);
}
catch (PlivoRestException e)
{
Console.WriteLine("Exception: " + e.Message);
}
}
}
}
1
2
3
4
curl -i --user AUTH_ID:AUTH_TOKEN \
-H "Content-Type: application/json" \
-d '{"text":"Hey, How aryou?"}' \
https://api.plivo.com/v1/Account/{auth_id}/Call/{call_uuid}/Speak/
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// Example for Call Speak create
package main
import "fmt"
import "github.com/plivo/plivo-go"
func main() {
client, err := plivo.NewClient("", "", &plivo.ClientOptions{})
if err != nil {
panic(err)
}
response, err := client.Calls.Speak(
"eba53b9e-8fbd-45c1-9444-696d2172fbc8",
plivo.CallSpeakParams{
Text: "Hello World",
},
)
if err != nil {
panic(err)
}
fmt.Printf("Response: %#v\n", response)
}