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.voice; 017 018import com.fasterxml.jackson.annotation.JsonProperty; 019import com.vonage.client.JsonableBaseObject; 020import java.net.URI; 021import java.util.List; 022 023/** 024 * Represents the speech recognition results in {@link EventWebhook#getSpeech()}. 025 * 026 * @since 8.2.0 027 */ 028public class SpeechResults extends JsonableBaseObject { 029 private SpeechTimeoutReason timeoutReason; 030 private List<SpeechTranscript> results; 031 private String error; 032 private URI recordingUrl; 033 034 /** 035 * Speech recording URL. Included if the {@code saveAudio} flag is set to {@code true} in 036 * the input action. Requires JWT authorization for downloading see <a 037 * href=https://developer.vonage.com/en/voice/voice-api/code-snippets/recording-calls/download-a-recording> 038 * Download a Recording</a> documentation for details. 039 * 040 * @return The recording URL, or {@code null} if absent. 041 * 042 * @since 8.2.0 043 */ 044 @JsonProperty("recording_url") 045 public URI getRecordingUrl() { 046 return recordingUrl; 047 } 048 049 /** 050 * Error message. 051 * 052 * @return The error message, or {@code null} if absent / not applicable. 053 */ 054 @JsonProperty("error") 055 public String getError() { 056 return error; 057 } 058 059 /** 060 * Indicates if the input ended when user stopped speaking, by max duration timeout 061 * or if the user didn't say anything. 062 * 063 * @return Reason for the timeout as an enum. 064 */ 065 @JsonProperty("timeout_reason") 066 public SpeechTimeoutReason getTimeoutReason() { 067 return timeoutReason; 068 } 069 070 /** 071 * The recognised text objects. 072 * 073 * @return The list of transcript texts, or {@code null} if there are none. 074 */ 075 @JsonProperty("results") 076 public List<SpeechTranscript> getResults() { 077 return results; 078 } 079}