Skip to content

Commit 2757021

Browse files
Merge pull request #63 from Bandwidth/SWI-2565
SWI-2565 Updated for detectLanguage
2 parents 2c44088 + d15302a commit 2757021

File tree

5 files changed

+47
-3
lines changed

5 files changed

+47
-3
lines changed

src/Voice/Bxml/Record.php

+17
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,15 @@ public function fileFormat($fileFormat) {
105105
$this->fileFormat = $fileFormat;
106106
}
107107

108+
/**
109+
* Sets the detectLanguage attribute for Record
110+
*
111+
* @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.
112+
*/
113+
public function detectLanguage($detectLanguage) {
114+
$this->detectLanguage= $detectLanguage;
115+
}
116+
108117
/**
109118
* Sets the transcribe attribute for Record
110119
*
@@ -220,6 +229,14 @@ public function toBxml($doc) {
220229
$element->setattribute("fileFormat", $this->fileFormat);
221230
}
222231

232+
if(isset($this->detectLanguage)) {
233+
if ($this->detectLanguage) {
234+
$element->setattribute("detectLanguage", "true");
235+
} else {
236+
$element->setattribute("detectLanguage", "false");
237+
}
238+
}
239+
223240
if(isset($this->transcribe)) {
224241
if ($this->transcribe) {
225242
$element->setattribute("transcribe", "true");

src/Voice/Bxml/StartRecording.php

+18
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,16 @@ public function fileFormat($fileFormat) {
6868
$this->fileFormat = $fileFormat;
6969
}
7070

71+
/**
72+
* Sets the detectLanguage attribute for Record
73+
*
74+
* @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.
75+
*/
76+
public function detectLanguage($detectLanguage) {
77+
$this->detectLanguage= $detectLanguage;
78+
}
79+
80+
7181
/**
7282
* Sets the multiChannel attribute for StartRecording
7383
*
@@ -131,6 +141,14 @@ public function toBxml($doc) {
131141
$element->setattribute("fileFormat", $this->fileFormat);
132142
}
133143

144+
if(isset($this->detectLanguage)) {
145+
if ($this->detectLanguage) {
146+
$element->setattribute("detectLanguage", "true");
147+
} else {
148+
$element->setattribute("detectLanguage", "false");
149+
}
150+
}
151+
134152
if(isset($this->multiChannel)) {
135153
if ($this->multiChannel) {
136154
$element->setattribute("multiChannel", "true");

src/Voice/Models/TranscribeRecordingRequest.php

+8
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@ class TranscribeRecordingRequest implements \JsonSerializable
4848
*/
4949
public $callbackTimeout;
5050

51+
/**
52+
* @todo Write general description for this property
53+
* @var boolean|null $detectLanguage public property
54+
*/
55+
public $detectLanguage;
56+
5157
/**
5258
* Constructor to set initial or default values of member properties
5359
*/
@@ -60,6 +66,7 @@ public function __construct()
6066
$this->password = func_get_arg(3);
6167
$this->tag = func_get_arg(4);
6268
$this->callbackTimeout = func_get_arg(5);
69+
$this->detectLanguage = func_get_arg(6);
6370
}
6471
}
6572

@@ -75,6 +82,7 @@ public function jsonSerialize()
7582
$json['password'] = $this->password;
7683
$json['tag'] = $this->tag;
7784
$json['callbackTimeout'] = $this->callbackTimeout;
85+
$json['detectLanguage'] = $this->detectlanguage;
7886

7987
return array_filter($json);
8088
}

tests/ApiTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public function testCreateCallAndGetCallState() {
8888
$this->assertTrue(strlen($callId) > 0);
8989
$this->assertTrue(is_a($response->getResult()->enqueuedTime, 'DateTime'));
9090

91-
sleep(1);
91+
sleep(25);
9292

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

123-
sleep(1);
123+
sleep(25);
124124

125125
//get phone call information
126126
$response = $this->bandwidthClient->getVoice()->getClient()->getCall(getenv("BW_ACCOUNT_ID"), $callId);

tests/BxmlTest.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -397,11 +397,12 @@ public function testRecord() {
397397
$record->recordCompleteFallbackMethod("GET");
398398
$record->fallbackUsername("fuser");
399399
$record->fallbackPassword("fpass");
400+
$record->detectlanguage("true");
400401

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

404-
$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>';
405+
$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>';
405406
$responseXml = $response->toBxml();
406407
$this->assertEquals($expectedXml, $responseXml);
407408
}

0 commit comments

Comments
 (0)