Skip to content

Commit

Permalink
Merge branch 'main' into SWI-2615
Browse files Browse the repository at this point in the history
  • Loading branch information
ajrice6713 authored May 24, 2023
2 parents 9d89bc8 + 2757021 commit fa2400b
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 1 deletion.
17 changes: 17 additions & 0 deletions src/Voice/Bxml/Record.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,15 @@ public function fileFormat(string $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 @@ -294,6 +303,14 @@ public function toBxml(DOMDocument $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 @@ -110,6 +110,16 @@ public function fileFormat(string $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 @@ -173,6 +183,14 @@ public function toBxml(DOMDocument $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(): array
$json['password'] = $this->password;
$json['tag'] = $this->tag;
$json['callbackTimeout'] = $this->callbackTimeout;
$json['detectLanguage'] = $this->detectlanguage;

return array_filter($json);
}
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 fa2400b

Please sign in to comment.