How to Speak Sentence on a Call

About

Speak a sentence on an active phone call. For more information about speak sentence, visit the full documentation.

Assumptions

Steps

  1. Create call with callback URL -or- Recieve Incoming Call
  2. Check if call is answered
  3. Speak sentence on call

Before Speaking

  1. Create call with callback URL -or- Receive Incoming Call
  2. Make sure call is answered and active

Speak Sentence options

Bandwidth supports many voice options. You may specify the gender, accent, and voice. Click herefor a full list of the speaker options.

Click here to learn more about creating an outbound call.

Create Call Parameters

Property Description
from A Bandwidth phone number on your account the call should come from (must be in E.164 format, like +19195551212).
to The number to call (must be either an E.164 formatted number, like +19195551212, or a valid SIP URI, like sip:someone@somewhere.com).
callbackUrl The full server URL where the call events related to the Call will be sent to.

Example of creating a call with callbackUrl

This sends these call backs

POST https://api.catapult.inetwork.com/v1/users/{userId}/calls HTTP/1.1
Content-Type: application/json; charset=utf-8
Authorization: {apiToken:apiSecret}

{
    "to"          : "{toNumber}",
    "from"        : "{fromNumber}",
    "callbackUrl" : "{callbackUrl}"
}

Speak Sentence to call

client.Call.speakSentence("callId", "Hello From Bandwidth").then(function (res) {});

Speak Sentence to bridge

client.Bridge.speakSentence("bridgeID", "Hello From Bandwidth").then(function (res) {});

Speak Sentence to entire conference

client.Conference.speakSentence("conferenceID", "Hello From Bandwidth", function (err, res) {});

Speak Sentence to specific conference member

client.Conference.speakSentenceToMember("conferenceID", "memberID", "Hello From Bandwidth")
 .then(function (res) {});

Stop Speaking Sentence to call

client.Call.stopSpeaking("callId").then(function (res) {});

Stop Speaking Sentence to bridge

client.Bridge.stopSpeaking("bridgeID").then(function (res) {});

Stop Speaking Sentence to entire conference

client.Conference.stopSpeaking("conferenceID").then(function (res) {});

Stop Speaking Sentence to specific conference member

//This assumes you have already input your credentials.
client.Call.create({
    from: "{toNumber}",
    to: "{fromNumber}",
    callbackUrl: "{callbackUrl}"
})
.then(function (id) {
    console.log(id);
})

Speak Sentence to call

await client.Call.SpeakSentenceAsync("{callId1}", "Hello From Bandwidth");

Speak Sentence to bridge

await client.Bridge.SpeakSentenceAsync("{bridgeId}", "Hello From Bandwidth");

Speak Sentence to entire conference

//This assumes you have already input your credentials.
var call = await client.Call.CreateAsync(new CreateCallData{
    From = "{fromNumber}",
    To = "{toNumber}"
    CallbackUrl = "{callbackUrl}"
});
Console.WriteLine($"Created call with id {call.Id}");
## This assumes you have already input your credentials.
call = Bandwidth::Call.create({
   :from => "{fromNumber}",
   :to => "{toNumber}",
   :callbackUrl => "{requestUrl}"})

puts call.id

Speak Sentence to specific conference member

await client.Conference.SpeakSentenceToMemberAsync("{conferenceId1}", "{memberId1}", "Hello From Bandwidth");

Stop Speaking Sentence to call

await client.Call.SpeakSentenceAsync("{callId1}", "");

Stop Speaking Sentence to bridge

await client.Bridge.SpeakSentenceAsync("{bridgeId}", "");

Stop Speaking Sentence to entire conference

await client.Conference.SpeakSentenceAsync("{conferenceId1}", "");

Stop Speaking Sentence to specific conference member

await client.Conference.SpeakSentenceToMemberAsync("{conferenceId1}", "{memberId1}", "");

In order to speak a sentence on a call, the call must be answered. When the call is answered, Bandwidth will notify the callbackUrl with an eventType = "answer". Once we recieve this callback, we can procede with speak sentence.

Example of callback answer event

json response

POST /your_url HTTP/1.1
Content-Type: application/json; charset=utf-8
User-Agent: BandwidthAPI/v1

{
    "eventType" : "answer",
    "from"      : "{toNumber}",
    "to"        : "{fromNumber}",
    "callId"    : "{callId}",
    "callUri"   : "{callUri}",
    "callState" : "active",
    "time"      : "date"
}

Bandwidth supports many voice options. You may specify the gender, accent, and voice. Click herefor a full list of the speaker options.

Speak sentence options

Speak Sentence to call

call.play_audio({:sentence => "Hello from Bandwidth"})

Speak Sentence to bridge

bridge.play_audio({:sentence => "Hello from Bandwidth"})

Speak Sentence to entire conference

conference.play_audio({:sentence => "Hello from Bandwidth"})

Stop Speaking Sentence to call

call.play_audio({:sentence => ""})

Stop Speaking Sentence to bridge

bridge.play_audio({:sentence => ""})

Stop Speaking Sentence to entire conference

conference.play_audio({:sentence => ""})
Property Description
sentence The sentence to speak. MAXIMUM LENGTH 1000 CHARACTERS. To STOP SENTENCE PLAYBACK send an empty string like: {"sentence": ""}
gender The gender of the voice used to synthesize the sentence. It will be considered only if sentence is not null. The female gender will be used by default.
locale The locale used to get the accent of the voice used to synthesize the sentence. Currently audio supports: en_US or en_UK (English), es or es_MX (Spanish), fr or fr_FR (French), de or de_DE (German), and t or it_IT (Italian) It will be considered only if sentence is not null/empty. The en_US will be used by default.
voice The voice to speak the sentence. Audio currently supports these voices: English US: Kate, Susan, Julie, Dave, Paul; English UK: Bridget; Spanish: Esperanza, Violeta, Jorge; French: Jolie, Bernard; German: Katrin, Stefan; Italian: Paola, Luca It will be considered only if sentence is not null/empty. Susan’s voice will be used by default.

Example of speak sentence

POST https://api.catapult.inetwork.com/v1/users/{userId}/calls/{callId}/audio HTTP/1.1
Content-Type: application/json; charset=utf-8
Authorization: {apiToken:apiSecret}

{
    "sentence" : "hola de Bandwidth",
    "gender"   : "male",
    "locale"   : "es",
    "voice"    : "Jorge"
}
var options = {
    sentence : "hola de Bandwidth",
    gender   : "male",
    locale   : "es",
    voice    : "Jorge"
}
//Promise
client.Call.playAudioAdvanced("callId", options).then(function (res) {});

Speak Sentence to call

api.speak_sentence_to_call('callId', 'Hello from Bandwidth')

Speak Sentence to bridge

api.speak_sentence_to_bridge('bridgeId', 'Hello from Bandwidth')

Speak Sentence to entire conference

api.speak_sentence_to_conference('conferenceId', 'Hello from Bandwidth')

Speak Sentence to specific conference member

api.speak_sentence_to_conference_member('conferenceId', 'memberId', 'Hello from Bandwidth')

Stop Speaking Sentence to call

api.speak_sentence_to_call('callId', '')

Stop Speaking Sentence to bridge

api.speak_sentence_to_bridge('bridgeId', '')

Stop Speaking Sentence to entire conference

api.speak_sentence_to_conference('conferenceId', '')

Stop Speaking Sentence to specific conference member

api.speak_sentence_to_conference_member('conferenceId', 'memberId', '')
await client.Call.PlayAudioAsync("{callId1}", new PlayAudioData
{
    Sentence = "hola de Bandwidth",
    Gender = Gender.Male,
    Voice = "Jorge",
    Locale = "es"
});
call.play_audio({
    :sentence => "hola de Bandwidth",
    :gender => "male",
    :voice => "Jorge",
    :locale => "es"
})

results matching ""

    No results matching ""