001/* 002 * Copyright 2024 Vonage 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package com.vonage.client.incoming; 017 018import com.fasterxml.jackson.annotation.JsonProperty; 019import com.fasterxml.jackson.annotation.JsonValue; 020import java.net.URI; 021import java.util.Collection; 022 023/** 024 * @deprecated Use {@link com.vonage.client.voice.SpeechResults}. 025 */ 026@Deprecated 027public class SpeechResults { 028 private TimeoutReason timeoutReason; 029 private Collection<Result> results; 030 private String error; 031 private URI recordingUrl; 032 033 /** 034 * Speech recording URL. Included if the {@code saveAudio} flag is set to {@code true} in 035 * the input action. Requires JWT authorization for downloading see <a 036 * href=https://developer.vonage.com/en/voice/voice-api/code-snippets/recording-calls/download-a-recording> 037 * Download a Recording</a> documentation for details. 038 * 039 * @return The recording URL, or {@code null} if absent. 040 * 041 * @since 8.2.0 042 */ 043 @JsonProperty("recording_url") 044 public URI getRecordingUrl() { 045 return recordingUrl; 046 } 047 048 /** 049 * Error message. 050 * 051 * @return The error message, or {@code null} if absent / not applicable. 052 */ 053 @JsonProperty("error") 054 public String getError() { 055 return error; 056 } 057 058 /** 059 * Indicates if the input ended when user stopped speaking, by max duration timeout 060 * or if the user didn't say anything. 061 * 062 * @return Reason for the timeout as an enum. 063 */ 064 @JsonProperty("timeout_reason") 065 public TimeoutReason getTimeoutReason() { 066 return timeoutReason; 067 } 068 069 /** 070 * @param timeoutReason Indicates whether the input ended when the user stopped speaking, by the max duration 071 * timeout, or if the user didn't say anything. 072 * 073 * @deprecated This setter will be removed in a future release. 074 */ 075 @Deprecated 076 public void setTimeoutReason(TimeoutReason timeoutReason) { 077 this.timeoutReason = timeoutReason; 078 } 079 080 /** 081 * The recognised text objects. 082 * 083 * @return The collection of transcript texts, or {@code null} if there are none. 084 */ 085 @JsonProperty("results") 086 public Collection<Result> getResults() { 087 return results; 088 } 089 090 /** 091 * @param results list of speech recognition results that displays the words(s) that the user spoke and the 092 * likelihood that the recognized word(s) in the list where the actual word(s) that the user spoke. 093 * 094 * @deprecated This setter will be removed in a future release. 095 */ 096 @Deprecated 097 public void setResults(Collection<Result> results) { 098 this.results = results; 099 } 100 101 /** 102 * Represents the timeout reason in {@linkplain #getTimeoutReason()}. 103 */ 104 public enum TimeoutReason { 105 END_ON_SILENCE_TIMEOUT, 106 MAX_DURATION, 107 START_TIMEOUT; 108 109 @JsonValue 110 @Override 111 public String toString() { 112 return name().toLowerCase(); 113 } 114 } 115}