Skip to content

Commit

Permalink
Merge pull request #92 from Bandwidth/SWI-2187
Browse files Browse the repository at this point in the history
SWI-2187 Add support for Transcription Language Detection
  • Loading branch information
brianluisgomez authored Mar 30, 2023
2 parents 54ad45d + aedb1ef commit 4297481
Show file tree
Hide file tree
Showing 5 changed files with 618 additions and 447 deletions.
112 changes: 73 additions & 39 deletions src/main/java/com/bandwidth/voice/bxml/verbs/Record.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ public class Record implements Verb {
public static final String TYPE_NAME = "Record";

/**
* <i>(optional)</i> A boolean value. If true, the recording will be submitted for transcription upon completion. Defaults to false.
* <i>(optional)</i> A boolean value. If true, the recording will be submitted
* for transcription upon completion. Defaults to false.
*/
@XmlAttribute
private boolean transcribe;
Expand All @@ -37,37 +38,43 @@ public class Record implements Verb {
private URI transcriptionAvailableUrl;

/**
* <i>(optional)</i> The HTTP method to use for the request to transcriptionAvailableUrl. GET or POST. Default Value is POST.
* <i>(optional)</i> The HTTP method to use for the request to
* transcriptionAvailableUrl. GET or POST. Default Value is POST.
*/
@XmlAttribute
private Method transcriptionAvailableMethod;

/**
* <i>(optional)</i> URL to send the Record Complete event to once it has ended. Accepts BXML.
* <i>(optional)</i> URL to send the Record Complete event to once it has ended.
* Accepts BXML.
*/
@XmlAttribute
private URI recordCompleteUrl;

/**
* <i>(optional)</i> The HTTP method to use for the request to recordCompleteUrl. GET or POST. Default Value is POST.
* <i>(optional)</i> The HTTP method to use for the request to
* recordCompleteUrl. GET or POST. Default Value is POST.
*/
@XmlAttribute
private Method recordCompleteMethod;

/**
* <i>(optional)</i> URL to send the Record Complete event to once it has ended. Accepts BXML.
* <i>(optional)</i> URL to send the Record Complete event to once it has ended.
* Accepts BXML.
*/
@XmlAttribute
private URI recordingAvailableUrl;

/**
* <i>(optional)</i> The HTTP method to use for the request to recordingAvailableUrl. GET or POST. Default Value is POST.
* <i>(optional)</i> The HTTP method to use for the request to
* recordingAvailableUrl. GET or POST. Default Value is POST.
*/
@XmlAttribute
private Method recordingAvailableMethod;

/**
* <i>(optional)</i> A custom string that will be sent with this and all future callbacks unless overwritten by a future tag attribute or cleared.
* <i>(optional)</i> A custom string that will be sent with this and all future
* callbacks unless overwritten by a future tag attribute or cleared.
* <br/>
* May be cleared by setting tag=""
* <br/>
Expand All @@ -77,36 +84,42 @@ public class Record implements Verb {
private String tag;

/**
* <i>(optional)</i> The username to send in the HTTP request to recordCompleteUrl or recordingAvailableUrl. If specified, the URLs must be TLS-encrypted (i.e., https).
* <i>(optional)</i> The username to send in the HTTP request to
* recordCompleteUrl or recordingAvailableUrl. If specified, the URLs must be
* TLS-encrypted (i.e., https).
*/
@XmlAttribute
protected String username;

/**
* <i>(optional)</i> The password to send in the HTTP request to recordCompleteUrl or recordingAvailableUrl. If specified, the URLs must be TLS-encrypted (i.e., https).
* <i>(optional)</i> The password to send in the HTTP request to
* recordCompleteUrl or recordingAvailableUrl. If specified, the URLs must be
* TLS-encrypted (i.e., https).
*/
@XmlAttribute
protected String password;

/**
* <i>(optional)</i> When pressed, this digit will terminate the recording. Default value is “#”.
* <i>(optional)</i> When pressed, this digit will terminate the recording.
* Default value is “#”.
*/
@XmlAttribute
protected String terminatingDigits;

/**
* <i>(optional)</i> Maximum length of recording (in seconds). Max 10800 (3 hours). Default value is 60.
* <i>(optional)</i> Maximum length of recording (in seconds). Max 10800 (3
* hours). Default value is 60.
*/
@XmlAttribute
protected Integer maxDuration;

/**
* <i>(optional)</i> The audio format that the recording will be saved as: mp3 or wav. Default value is wav.
* <i>(optional)</i> The audio format that the recording will be saved as: mp3
* or wav. Default value is wav.
*/
@XmlAttribute
protected String fileFormat;


@XmlAttribute
protected String fallbackUsername;

Expand All @@ -119,114 +132,135 @@ public class Record implements Verb {
@XmlAttribute
protected Method recordCompleteFallbackMethod;

/**
* <i>(optional)</i> A boolean value to indicate 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.
*/
@XmlAttribute
protected Boolean detectLanguage;

public static class RecordBuilder {

/**
* <b>(required)</b> URL to send the transcriptionAvailable event to.
*/
public RecordBuilder transcriptionAvailableUrl(URI uri ){
public RecordBuilder transcriptionAvailableUrl(URI uri) {
this.transcriptionAvailableUrl = uri;
return this;
}

/**
* <b>(required)</b> URL to send the transcriptionAvailable event to.
*/
public RecordBuilder transcriptionAvailableUrl(String uri){
public RecordBuilder transcriptionAvailableUrl(String uri) {
return transcriptionAvailableUrl(URI.create(uri));
}

public RecordBuilder recordCompleteFallbackUrl(URI uri ){
public RecordBuilder recordCompleteFallbackUrl(URI uri) {
this.recordCompleteFallbackUrl = uri;
return this;
}

public RecordBuilder recordCompleteFallbackUrl(String uri){
public RecordBuilder recordCompleteFallbackUrl(String uri) {
return recordCompleteFallbackUrl(URI.create(uri));
}

/**
* <i>(optional)</i> The HTTP method to use for the request to transcriptionAvailableUrl. GET or POST. Default Value is POST.
* <i>(optional)</i> The HTTP method to use for the request to
* transcriptionAvailableUrl. GET or POST. Default Value is POST.
*/
public RecordBuilder transcriptionAvailableMethod(Method method){
public RecordBuilder transcriptionAvailableMethod(Method method) {
this.transcriptionAvailableMethod = method;
return this;
}

/**
* <i>(optional)</i> The HTTP method to use for the request to transcriptionAvailableUrl. GET or POST. Default Value is POST. Converts String to Method using Method.fromValue(method)
* <i>(optional)</i> The HTTP method to use for the request to
* transcriptionAvailableUrl. GET or POST. Default Value is POST. Converts
* String to Method using Method.fromValue(method)
*/
public RecordBuilder transcriptionAvailableMethod(String method){
public RecordBuilder transcriptionAvailableMethod(String method) {
return transcriptionAvailableMethod(Method.fromValue(method));
}

public RecordBuilder recordCompleteFallbackMethod(Method method){
public RecordBuilder recordCompleteFallbackMethod(Method method) {
this.recordCompleteFallbackMethod = method;
return this;
}

public RecordBuilder recordCompleteFallbackMethod(String method){
public RecordBuilder recordCompleteFallbackMethod(String method) {
return recordCompleteFallbackMethod(Method.fromValue(method));
}

/**
* <b>(required)</b> URL to send the Record Complete event to once it has ended. Accepts BXML.
* <b>(required)</b> URL to send the Record Complete event to once it has ended.
* Accepts BXML.
*/
public RecordBuilder recordCompleteUrl(URI uri ){
public RecordBuilder recordCompleteUrl(URI uri) {
this.recordCompleteUrl = uri;
return this;
}

/**
* <b>(required)</b> URL to request new BXML from. A Record event will be sent to this endpoint. Converts to URI using URI.create(url)
* <b>(required)</b> URL to request new BXML from. A Record event will be sent
* to this endpoint. Converts to URI using URI.create(url)
*/
public RecordBuilder recordCompleteUrl(String uri){
public RecordBuilder recordCompleteUrl(String uri) {
return recordCompleteUrl(URI.create(uri));
}

/**
* <i>(optional)</i> The HTTP method to use for the request to recordCompleteUrl. GET or POST. Default Value is POST.
* <i>(optional)</i> The HTTP method to use for the request to
* recordCompleteUrl. GET or POST. Default Value is POST.
*/
public RecordBuilder recordCompleteMethod(Method method){
public RecordBuilder recordCompleteMethod(Method method) {
this.recordCompleteMethod = method;
return this;
}

/**
* <i>(optional)</i> The HTTP method to use for the request to recordCompleteUrl. GET or POST. Default Value is POST. Converts String to Method using Method.fromValue(method)
* <i>(optional)</i> The HTTP method to use for the request to
* recordCompleteUrl. GET or POST. Default Value is POST. Converts String to
* Method using Method.fromValue(method)
*/
public RecordBuilder recordCompleteMethod(String method){
public RecordBuilder recordCompleteMethod(String method) {
return recordCompleteMethod(Method.fromValue(method));
}

/**
* <b>(required)</b> URL to send the Recording Available event to once it has been processed. Does not accept BXML.
* <b>(required)</b> URL to send the Recording Available event to once it has
* been processed. Does not accept BXML.
*/
public RecordBuilder recordingAvailableUrl(URI uri ){
public RecordBuilder recordingAvailableUrl(URI uri) {
this.recordingAvailableUrl = uri;
return this;
}

/**
* <b>(required)</b> URL to send the Recording Available event to once it has been processed. Does not accept BXML.
* <b>(required)</b> URL to send the Recording Available event to once it has
* been processed. Does not accept BXML.
*/
public RecordBuilder recordingAvailableUrl(String uri){
public RecordBuilder recordingAvailableUrl(String uri) {
return recordingAvailableUrl(URI.create(uri));
}

/**
* <i>(optional)</i> The HTTP method to use for the request to recordingAvailableUrl. GET or POST. Default Value is POST.
* <i>(optional)</i> The HTTP method to use for the request to
* recordingAvailableUrl. GET or POST. Default Value is POST.
*/
public RecordBuilder recordingAvailableMethod(Method method){
public RecordBuilder recordingAvailableMethod(Method method) {
this.recordingAvailableMethod = method;
return this;
}

/**
* <i>(optional)</i> The HTTP method to use for the request to recordingAvailableUrl. GET or POST. Default Value is POST. Converts String to Method using Method.fromValue(method)
* <i>(optional)</i> The HTTP method to use for the request to
* recordingAvailableUrl. GET or POST. Default Value is POST. Converts String to
* Method using Method.fromValue(method)
*/
public RecordBuilder recordingAvailableMethod(String method){
public RecordBuilder recordingAvailableMethod(String method) {
return recordingAvailableMethod(Method.fromValue(method));
}
}
Expand Down
Loading

0 comments on commit 4297481

Please sign in to comment.