Play audio in active Call

Plays an audio file or speak a sentence in a phone call.

Request URL

POSThttps://api.catapult.inetwork.com/v1/users/{userId}/calls/{callId}/audio


Supported Parameters

Parameter Description Mandatory
fileUrl The location of an audio file to play (WAV and MP3 supported).

To STOP AUDIO FILE PLAYBACK send an empty string like: {"fileUrl": ""}
No
sentence The sentence to speak. MAXIMUM LENGTH 1000 CHARACTERS

To STOP SENTENCE PLAYBACK send an empty string like: {"sentence": ""}
No
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. No
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)
- t or it_IT (Italian) It will be considered only if sentence is not null/empty. The en_US will be used by default.
No
voice The voice to speak the sentence. Audio currently supports the following 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.
No
loopEnabled When value is true , the audio will keep playing in a loop. Default: false. No
tag A string that will be included in the events delivered when the audio playback starts or finishes. No

Example 1 of 4: Speak a Sentence

curl -v -X POST https://api.catapult.inetwork.com/v1/users/{userId}/calls/{callId}/audio \
    -u {token}:{secret} \
    -H "Content-type: application/json" \
    -d \
    '
    {
        "gender"   : "female",
        "sentence" : "Hello, thank you for calling.",
        "locale"   : "en_US",
        "voice"    : "julie"
    }'
//Speak sentence with options
var options = {
    sentence : "hola de Bandwidth",
    gender   : "male",
    locale   : "es",
    voice    : "Jorge"
}
//Promise
client.Call.playAudioAdvanced("callId", options).then(function (res) {});

//Callback
client.Call.playAudioAdvanced("callId", options, function (err,res) {});

//Speak sentence in a call

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

//Callback
client.Call.speakSentence("callId", "Hello From Bandwidth", function (err, res) {});
//Speak sentence with options
await client.Call.PlayAudioAsync("{callId1}", new PlayAudioData
{
    Sentence = "hola de Bandwidth",
    Gender = Genger.Male,
    Voice = "Jorge",
    Locale = "es"
});

//Speak sentence in a call
await client.Call.SpeakSentenceAsync("{callId1}", "Hello From Bandwidth");
call.play_audio({
    :sentence => "hola de Bandwidth",
    :gender => "male",
    :voice => "Jorge",
    :locale => "es"
})

Example 2 of 4: Interrupt/stop a sentence from speaking.

curl -v -X POST https://api.catapult.inetwork.com/v1/users/{userId}/calls/{callId}/audio \
    -u {token}:{secret} \
    -H "Content-type: application/json" \
    -d '{"sentence": ""}'

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

//Callback
client.Call.stopSpeaking("callId", function (err, res) {});
await client.Call.SpeakSentenceAsync("{callId1}", "");
call.play_audio({
    :sentence => ""
})

Example 3 of 4: Play an Audio File

curl -v -X POST https://api.catapult.inetwork.com/v1/users/{userId}/calls/{callId}/audio \
    -u {token}:{secret} \
    -H "Content-type: application/json" \
    -d '{"fileUrl": "http://example.com/audio.mp3"}'

//Promise
client.Call.playAudioFile("callId", "http://myurl.com/file.mp3").then(function (res) {});

//Callback
client.Call.playAudioFile("callId", "http://myurl.com/file.wav", function (err, res) {});
await client.Call.PlayAudioFileAsync("{callId1}", "http://myurl.com/file.wav");
call.play_audio({
    :file_url => "http://myurl.com/file.wav"
})

Example 4 of 4: Stop an Audio File Playing

curl -v -X POST https://api.catapult.inetwork.com/v1/users/{userId}/calls/{callId}/audio \
    -u {token}:{secret} \
    -H "Content-type: application/json" \
    -d '{"fileUrl": ""}'
//Promise
client.Call.stopAudioFilePlayback("callId").then(function (res) {});

//Callback
client.Call.stopAudioFilePlayback("callId", function (err, res) {});
await client.Call.PlayAudioFileAsync("{callId1}", "");
call.play_audio({
    :file_url => ""
})

results matching ""

    No results matching ""