Skip to content

Commit

Permalink
Merge pull request #63 from Bandwidth/SWI-2565
Browse files Browse the repository at this point in the history
SWI-2565 Updated for detectLanguage
  • Loading branch information
brianluisgomez authored May 18, 2023
2 parents 2c44088 + d15302a commit 2757021
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 3 deletions.
17 changes: 17 additions & 0 deletions src/Voice/Bxml/Record.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,15 @@ public function fileFormat($fileFormat) {
$this->fileFormat = $fileFormat;
}

/**
* Sets the detectLanguage attribute for Record
*
* @param boolean $detectLanguage Indicates that the recording may not be in English, and the transcription service will need to detect the dominant language the recording is in and transcribe accordingly. Current supported languages are English, French, and Spanish.
*/
public function detectLanguage($detectLanguage) {
$this->detectLanguage= $detectLanguage;
}

/**
* Sets the transcribe attribute for Record
*
Expand Down Expand Up @@ -220,6 +229,14 @@ public function toBxml($doc) {
$element->setattribute("fileFormat", $this->fileFormat);
}

if(isset($this->detectLanguage)) {
if ($this->detectLanguage) {
$element->setattribute("detectLanguage", "true");
} else {
$element->setattribute("detectLanguage", "false");
}
}

if(isset($this->transcribe)) {
if ($this->transcribe) {
$element->setattribute("transcribe", "true");
Expand Down
18 changes: 18 additions & 0 deletions src/Voice/Bxml/StartRecording.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,16 @@ public function fileFormat($fileFormat) {
$this->fileFormat = $fileFormat;
}

/**
* Sets the detectLanguage attribute for Record
*
* @param boolean $detectLanguage Indicates that the recording may not be in English, and the transcription service will need to detect the dominant language the recording is in and transcribe accordingly. Current supported languages are English, French, and Spanish.
*/
public function detectLanguage($detectLanguage) {
$this->detectLanguage= $detectLanguage;
}


/**
* Sets the multiChannel attribute for StartRecording
*
Expand Down Expand Up @@ -131,6 +141,14 @@ public function toBxml($doc) {
$element->setattribute("fileFormat", $this->fileFormat);
}

if(isset($this->detectLanguage)) {
if ($this->detectLanguage) {
$element->setattribute("detectLanguage", "true");
} else {
$element->setattribute("detectLanguage", "false");
}
}

if(isset($this->multiChannel)) {
if ($this->multiChannel) {
$element->setattribute("multiChannel", "true");
Expand Down
8 changes: 8 additions & 0 deletions src/Voice/Models/TranscribeRecordingRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ class TranscribeRecordingRequest implements \JsonSerializable
*/
public $callbackTimeout;

/**
* @todo Write general description for this property
* @var boolean|null $detectLanguage public property
*/
public $detectLanguage;

/**
* Constructor to set initial or default values of member properties
*/
Expand All @@ -60,6 +66,7 @@ public function __construct()
$this->password = func_get_arg(3);
$this->tag = func_get_arg(4);
$this->callbackTimeout = func_get_arg(5);
$this->detectLanguage = func_get_arg(6);
}
}

Expand All @@ -75,6 +82,7 @@ public function jsonSerialize()
$json['password'] = $this->password;
$json['tag'] = $this->tag;
$json['callbackTimeout'] = $this->callbackTimeout;
$json['detectLanguage'] = $this->detectlanguage;

return array_filter($json);
}
Expand Down
4 changes: 2 additions & 2 deletions tests/ApiTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public function testCreateCallAndGetCallState() {
$this->assertTrue(strlen($callId) > 0);
$this->assertTrue(is_a($response->getResult()->enqueuedTime, 'DateTime'));

sleep(1);
sleep(25);

//get phone call information
$response = $this->bandwidthClient->getVoice()->getClient()->getCall(getenv("BW_ACCOUNT_ID"), $callId);
Expand Down Expand Up @@ -120,7 +120,7 @@ public function testCreateCallWithAmdAndGetCallState() {
$callId = $response->getResult()->callId;
$this->assertTrue(strlen($callId) > 0);

sleep(1);
sleep(25);

//get phone call information
$response = $this->bandwidthClient->getVoice()->getClient()->getCall(getenv("BW_ACCOUNT_ID"), $callId);
Expand Down
3 changes: 2 additions & 1 deletion tests/BxmlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -397,11 +397,12 @@ public function testRecord() {
$record->recordCompleteFallbackMethod("GET");
$record->fallbackUsername("fuser");
$record->fallbackPassword("fpass");
$record->detectlanguage("true");

$response = new BandwidthLib\Voice\Bxml\Response();
$response->addVerb($record);

$expectedXml = '<?xml version="1.0" encoding="UTF-8"?><Response><Record recordCompleteUrl="https://myapp.com/nextBXML" maxDuration="10" recordCompleteFallbackUrl="https://test.com" recordCompleteFallbackMethod="GET" fallbackUsername="fuser" fallbackPassword="fpass"/></Response>';
$expectedXml = '<?xml version="1.0" encoding="UTF-8"?><Response><Record recordCompleteUrl="https://myapp.com/nextBXML" maxDuration="10" detectLanguage="true" recordCompleteFallbackUrl="https://test.com" recordCompleteFallbackMethod="GET" fallbackUsername="fuser" fallbackPassword="fpass"/></Response>';
$responseXml = $response->toBxml();
$this->assertEquals($expectedXml, $responseXml);
}
Expand Down

0 comments on commit 2757021

Please sign in to comment.