Latest Legacy

Play text during a call

This endpoint lets you 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.

voice string

The voice in which the text should be spoken.

Allowed values: MAN, WOMAN.
Defaults to WOMAN.

language string

The language used to speak the text. The default language is US English (en-US). You can see the list of supported languages below.

legs string

The call leg in which the text is to be spoken.

Allowed values: aleg (first leg of the call), bleg (second leg of the call), or both
Defaults to aleg.

loop boolean

If set to true, the text will be spoken repeatedly unless stopped.

Defaults to false.

mix boolean

This flag determines the behavior of current call audio when the file is being played. If set to false, then call participants cannot hear anyone speaking in the call until play is stopped. If set to true, both call audio and played audio are mixed and played.

Defaults to true.

List of languages supported

Arabicarb

Only WOMAN voice

Chinese Mandarincmn-CN

Only WOMAN voice

Danish (Denmark)da-DK

Both WOMAN and MAN voices

Dutch (Netherlands)nl-NL

Both WOMAN and MAN voices

English (Australia)en-AU

Both WOMAN and MAN voices

English (India)en-IN

Only WOMAN voice

English (UK)en-GB

Both WOMAN and MAN voices

English (US)en-US

Both WOMAN and MAN voices

English (Welsh)en-GB-WLS

only MAN voice

French (Canada)fr-CA

Only WOMAN voice

French (France)fr-FR

Both WOMAN and MAN voices

German (Germany)de-DE

Both WOMAN and MAN voices

Hindi (India)hi-IN

Only WOMAN voice

Icelandic (Iceland)is-IS

Both WOMAN and MAN voices

Italian (Italy)it-IT

Both WOMAN and MAN voices

Japanese (Japan)ja-JP

Both WOMAN and MAN voices

Korean (South Korea)ko-KR

Only WOMAN voice

Norwegian (Norway)nb-NO

Only WOMAN voice

Polish (Poland)pl-PL

Both WOMAN and MAN voices

Portuguese (Brazil)pt-BR

Both WOMAN and MAN voices

Portuguese (Portugal)pt-PT

Both WOMAN and MAN voices

Romanian (Romania)ro-RO

Only WOMAN voice

Russian (Russia)ru-RU

Both WOMAN and MAN voices

Spanish (Mexico)es-MX

Only WOMAN voice

Spanish (Spain)es-ES

Both WOMAN and MAN voices

Spanish (US)es-US

Both WOMAN and MAN voices

Swedish (Sweden)sv-SE

Only WOMAN voice

Turkish (Turkey)tr-TR

Only WOMAN voice

Welsh (Wales)cy-GB

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('<auth_id>','<auth_token>')
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("<auth_id>","<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';
    
   // If auth id and auth token are not specified, Plivo will fetch them from the environment variables.
    var client = new plivo.Client("<auth_id>","<auth_token>");
    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("<auth_id>","<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("<auth_id>","<auth_token>");
        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("<auth_id>","<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
23
24
25
26
27
// Example for Call Speak create
package main

import (
	"fmt"

	"github.com/plivo/plivo-go/v7"
)

func main() {
	client, err := plivo.NewClient("<auth_id>", "<auth_token>", &plivo.ClientOptions{})
	if err != nil {
		fmt.Print("Error", err.Error())
		return
	}
	response, err := client.Calls.Speak(
		"eba53b9e-8fbd-45c1-9444-696d2172fbc8",
		plivo.CallSpeakParams{
			Text: "Hello World",
		},
	)
	if err != nil {
		fmt.Print("Error", err.Error())
		return
	}
	fmt.Printf("Response: %#v\n", response)
}