gnodet-bot commented on code in PR #28353:
URL: https://github.com/apache/camel/pull/28353#discussion_r4364398035


##########
components/camel-aws/camel-aws2-transcribe/src/main/java/org/apache/camel/component/aws2/transcribe/Transcribe2Producer.java:
##########
@@ -917,6 +910,32 @@ private void applyIfPresent(Exchange exchange, String 
header, Consumer<String> s
         }
     }
 
+    /**
+     * Reads the phrases (or words of a vocabulary filter) header as a list of 
strings. A single String is taken as a
+     * list of one phrase.
+     */
+    private List<String> getPhrases(Exchange exchange) {
+        Object value = 
exchange.getIn().getHeader(Transcribe2Constants.VOCABULARY_PHRASES);
+        if (value == null) {
+            return null;
+        }
+        if (value instanceof String phrase) {
+            return phrase.isBlank() ? null : List.of(phrase);
+        }
+        if (value instanceof Collection<?> collection) {
+            List<String> phrases = new ArrayList<>(collection.size());
+            for (Object phrase : collection) {
+                if (phrase != null) {
+                    phrases.add(phrase.toString());
+                }
+            }
+            return phrases;
+        }
+        throw new IllegalArgumentException(
+                "The " + Transcribe2Constants.VOCABULARY_PHRASES + " header 
must be a List<String> or a String, was: "
+                                           + value.getClass().getName());

Review Comment:
   Test transcribe



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to