From a3d934900af99ae6e666a214620ed639cf95918c Mon Sep 17 00:00:00 2001 From: Brian Date: Wed, 17 May 2023 12:25:08 -0400 Subject: [PATCH 1/4] SWI-2565 Updated for detectLanguage --- src/Voice/Bxml/Record.php | 17 +++++++++++++++++ src/Voice/Bxml/StartRecording.php | 18 ++++++++++++++++++ .../Models/TranscribeRecordingRequest.php | 8 ++++++++ tests/ApiTest.php | 4 ++-- tests/BxmlTest.php | 3 ++- 5 files changed, 47 insertions(+), 3 deletions(-) diff --git a/src/Voice/Bxml/Record.php b/src/Voice/Bxml/Record.php index c4bb3b1..f97ed34 100644 --- a/src/Voice/Bxml/Record.php +++ b/src/Voice/Bxml/Record.php @@ -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 * @@ -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"); diff --git a/src/Voice/Bxml/StartRecording.php b/src/Voice/Bxml/StartRecording.php index 1253c89..7057188 100644 --- a/src/Voice/Bxml/StartRecording.php +++ b/src/Voice/Bxml/StartRecording.php @@ -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 * @@ -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"); diff --git a/src/Voice/Models/TranscribeRecordingRequest.php b/src/Voice/Models/TranscribeRecordingRequest.php index b2a2ac2..63bd77c 100644 --- a/src/Voice/Models/TranscribeRecordingRequest.php +++ b/src/Voice/Models/TranscribeRecordingRequest.php @@ -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 */ @@ -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); } } @@ -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); } diff --git a/tests/ApiTest.php b/tests/ApiTest.php index 87e317b..2a5244a 100644 --- a/tests/ApiTest.php +++ b/tests/ApiTest.php @@ -88,7 +88,7 @@ public function testCreateCallAndGetCallState() { $this->assertTrue(strlen($callId) > 0); $this->assertTrue(is_a($response->getResult()->enqueuedTime, 'DateTime')); - sleep(1); + sleep(15); //get phone call information $response = $this->bandwidthClient->getVoice()->getClient()->getCall(getenv("BW_ACCOUNT_ID"), $callId); @@ -120,7 +120,7 @@ public function testCreateCallWithAmdAndGetCallState() { $callId = $response->getResult()->callId; $this->assertTrue(strlen($callId) > 0); - sleep(1); + sleep(15); //get phone call information $response = $this->bandwidthClient->getVoice()->getClient()->getCall(getenv("BW_ACCOUNT_ID"), $callId); diff --git a/tests/BxmlTest.php b/tests/BxmlTest.php index d7d15f1..d964095 100644 --- a/tests/BxmlTest.php +++ b/tests/BxmlTest.php @@ -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 = ''; + $expectedXml = ''; $responseXml = $response->toBxml(); $this->assertEquals($expectedXml, $responseXml); } From e5123ccf61020fd131e9aba4ad145fb503b24b75 Mon Sep 17 00:00:00 2001 From: Brian Date: Wed, 17 May 2023 12:29:50 -0400 Subject: [PATCH 2/4] Fixed typo --- src/Voice/Bxml/StartRecording.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Voice/Bxml/StartRecording.php b/src/Voice/Bxml/StartRecording.php index 7057188..76c176e 100644 --- a/src/Voice/Bxml/StartRecording.php +++ b/src/Voice/Bxml/StartRecording.php @@ -141,7 +141,7 @@ public function toBxml($doc) { $element->setattribute("fileFormat", $this->fileFormat); } - if(isset($this->detectLanguage)) } + if(isset($this->detectLanguage)) { if ($this->detectLanguage) { $element->setattribute("detectLanguage", "true"); } else { From e2b7c2f03823714edc825cf9aad17181ea652ef6 Mon Sep 17 00:00:00 2001 From: Brian Date: Wed, 17 May 2023 12:34:39 -0400 Subject: [PATCH 3/4] Raised the sleep time a bit more --- src/Voice/Bxml/Record.php | 2 +- tests/ApiTest.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Voice/Bxml/Record.php b/src/Voice/Bxml/Record.php index f97ed34..3ce965a 100644 --- a/src/Voice/Bxml/Record.php +++ b/src/Voice/Bxml/Record.php @@ -229,7 +229,7 @@ public function toBxml($doc) { $element->setattribute("fileFormat", $this->fileFormat); } - if(isset($this->detectLanguage)) } + if(isset($this->detectLanguage)) { if ($this->detectLanguage) { $element->setattribute("detectLanguage", "true"); } else { diff --git a/tests/ApiTest.php b/tests/ApiTest.php index 2a5244a..d8e476e 100644 --- a/tests/ApiTest.php +++ b/tests/ApiTest.php @@ -88,7 +88,7 @@ public function testCreateCallAndGetCallState() { $this->assertTrue(strlen($callId) > 0); $this->assertTrue(is_a($response->getResult()->enqueuedTime, 'DateTime')); - sleep(15); + sleep(25); //get phone call information $response = $this->bandwidthClient->getVoice()->getClient()->getCall(getenv("BW_ACCOUNT_ID"), $callId); @@ -120,7 +120,7 @@ public function testCreateCallWithAmdAndGetCallState() { $callId = $response->getResult()->callId; $this->assertTrue(strlen($callId) > 0); - sleep(15); + sleep(25); //get phone call information $response = $this->bandwidthClient->getVoice()->getClient()->getCall(getenv("BW_ACCOUNT_ID"), $callId); From d15302a2486ffe2e5178bf50755664fdcbc329e6 Mon Sep 17 00:00:00 2001 From: Brian Date: Wed, 17 May 2023 12:42:36 -0400 Subject: [PATCH 4/4] Fixed expected BXML string --- tests/BxmlTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/BxmlTest.php b/tests/BxmlTest.php index d964095..3e030a8 100644 --- a/tests/BxmlTest.php +++ b/tests/BxmlTest.php @@ -402,7 +402,7 @@ public function testRecord() { $response = new BandwidthLib\Voice\Bxml\Response(); $response->addVerb($record); - $expectedXml = ''; + $expectedXml = ''; $responseXml = $response->toBxml(); $this->assertEquals($expectedXml, $responseXml); }