|
39 | 39 | import java.io.FileInputStream; |
40 | 40 | import java.io.IOException; |
41 | 41 |
|
42 | | -public class DetectIntentStream { |
| 42 | +public abstract class DetectIntentStream { |
43 | 43 |
|
44 | 44 | // DialogFlow API Detect Intent sample with audio files processes as an audio stream. |
45 | 45 | public static void detectIntentStream( |
46 | 46 | String projectId, String locationId, String agentId, String sessionId, String audioFilePath) |
47 | 47 | throws ApiException, IOException { |
48 | 48 | SessionsSettings.Builder sessionsSettingsBuilder = SessionsSettings.newBuilder(); |
49 | | - if (locationId.equals("global")) { |
| 49 | + if ("global".equals(locationId)) { |
50 | 50 | sessionsSettingsBuilder.setEndpoint("dialogflow.googleapis.com:443"); |
51 | 51 | } else { |
52 | 52 | sessionsSettingsBuilder.setEndpoint(locationId + "-dialogflow.googleapis.com:443"); |
@@ -90,7 +90,7 @@ public static void detectIntentStream( |
90 | 90 | VoiceSelectionParams voiceSelection = |
91 | 91 | // Voices that are available https://cloud.google.com/text-to-speech/docs/voices |
92 | 92 | VoiceSelectionParams.newBuilder() |
93 | | - .setName("en-GB-Standard-A") |
| 93 | + .setName("en-US-Standard-F") |
94 | 94 | .setSsmlGender(SsmlVoiceGender.SSML_VOICE_GENDER_FEMALE) |
95 | 95 | .build(); |
96 | 96 |
|
@@ -143,7 +143,8 @@ public static void detectIntentStream( |
143 | 143 | System.out.format("Query Text: '%s'\n", queryResult.getTranscript()); |
144 | 144 | System.out.format( |
145 | 145 | "Detected Intent: %s (confidence: %f)\n", |
146 | | - queryResult.getIntent().getDisplayName(), queryResult.getIntentDetectionConfidence()); |
| 146 | + queryResult.getMatch().getIntent().getDisplayName(), |
| 147 | + queryResult.getMatch().getConfidence()); |
147 | 148 | } |
148 | 149 | } |
149 | 150 | } |
|
0 commit comments