This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new 558b8a3c0a70 CAMEL-27625: camel-ibm-watson-speech-to-text - producer
health check, customization ID header, producer labels (#31009)
558b8a3c0a70 is described below
commit 558b8a3c0a70cddc2ace50f450011919997c2bc7
Author: allthingssecurity <[email protected]>
AuthorDate: Sat Nov 28 03:22:29 2026 +0530
CAMEL-27625: camel-ibm-watson-speech-to-text - producer health check,
customization ID header, producer labels (#31009)
1. The component has the healthCheckConsumerEnabled and
healthCheckProducerEnabled options of HealthCheckComponent, but no health
check. The producer now registers one in the producers repository, as the
AWS producers do. It lists the models of the service and is DOWN, with
the
HTTP status code, when the call fails. It runs only when producer health
checks are enabled (they are off by default in Camel), and
healthCheckProducerEnabled=false leaves it out.
3. serviceUrl had the label common although the component is producer only.
It is now in the producer group.
4. The headers had no label. All now have the label producer.
5. getCustomModel read the customization ID of the custom language model
from the CamelIBMWatsonSTTModelName header. The new
CamelIBMWatsonSTTCustomizationId header gives it, and
CamelIBMWatsonSTTModelName is still read when the new header is not set,
then the body, as before.
Not changed: 2 (the label path). It is not used, and CAMEL-23832 documents
it as a free logical name; giving it a meaning would change existing
endpoints.
Regenerated ibm-watson-speech-to-text.json (component and catalog copy),
the catalog copy of the doc page, and the endpoint and component DSL. Doc
page: a health check section, and the getCustomModel example uses the new
header. Upgrade guide entry for 4.24.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
---
.../components/ibm-watson-speech-to-text.json | 41 ++--
.../docs/ibm-watson-speech-to-text-component.adoc | 9 +-
.../ibm/watson/stt/ibm-watson-speech-to-text.json | 41 ++--
.../docs/ibm-watson-speech-to-text-component.adoc | 9 +-
.../stt/WatsonSpeechToTextConfiguration.java | 2 +-
.../watson/stt/WatsonSpeechToTextConstants.java | 38 ++--
.../ibm/watson/stt/WatsonSpeechToTextEndpoint.java | 13 +-
.../ibm/watson/stt/WatsonSpeechToTextProducer.java | 34 +++-
.../stt/WatsonSpeechToTextProducerHealthCheck.java | 61 ++++++
...tsonSpeechToTextCustomModelHealthCheckTest.java | 208 +++++++++++++++++++++
.../ROOT/pages/camel-4x-upgrade-guide-4_24.adoc | 10 +
...mWatsonSpeechToTextComponentBuilderFactory.java | 42 ++---
.../WatsonSpeechToTextEndpointBuilderFactory.java | 57 +++---
13 files changed, 465 insertions(+), 100 deletions(-)
diff --git
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/ibm-watson-speech-to-text.json
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/ibm-watson-speech-to-text.json
index 38bb85cbc096..c7963da6c3a3 100644
---
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/ibm-watson-speech-to-text.json
+++
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/ibm-watson-speech-to-text.json
@@ -25,11 +25,11 @@
},
"componentProperties": {
"configuration": { "index": 0, "kind": "property", "displayName":
"Configuration", "group": "producer", "label": "", "required": false, "type":
"object", "javaType":
"org.apache.camel.component.ibm.watson.stt.WatsonSpeechToTextConfiguration",
"deprecated": false, "autowired": false, "secret": false, "description": "The
shared configuration of the endpoints. Each endpoint starts from a copy of it,
and its endpoint options override the values." },
- "serviceUrl": { "index": 1, "kind": "property", "displayName": "Service
Url", "group": "common", "label": "common", "required": false, "type":
"string", "javaType": "java.lang.String", "deprecated": false, "autowired":
false, "secret": false, "configurationClass":
"org.apache.camel.component.ibm.watson.stt.WatsonSpeechToTextConfiguration",
"configurationField": "configuration", "description": "The URL of the Speech to
Text service instance, for example https:\/\/api.eu-de.speech-to-t [...]
- "contentType": { "index": 2, "kind": "property", "displayName": "Content
Type", "group": "producer", "label": "producer", "required": false, "type":
"string", "javaType": "java.lang.String", "deprecated": false, "autowired":
false, "secret": false, "defaultValue": "audio\/wav", "configurationClass":
"org.apache.camel.component.ibm.watson.stt.WatsonSpeechToTextConfiguration",
"configurationField": "configuration", "description": "The format (MIME type)
of the audio for recognize, for [...]
- "lazyStartProducer": { "index": 3, "kind": "property", "displayName":
"Lazy Start Producer", "group": "producer", "label": "producer", "required":
false, "type": "boolean", "javaType": "boolean", "deprecated": false,
"autowired": false, "secret": false, "defaultValue": false, "description":
"Whether the producer should be started lazy (on the first message). By
starting lazy you can use this to allow CamelContext and routes to startup in
situations where a producer may otherwise fail [...]
- "model": { "index": 4, "kind": "property", "displayName": "Model",
"group": "producer", "label": "producer", "required": false, "type": "string",
"javaType": "java.lang.String", "deprecated": false, "autowired": false,
"secret": false, "defaultValue": "en-US_BroadbandModel", "configurationClass":
"org.apache.camel.component.ibm.watson.stt.WatsonSpeechToTextConfiguration",
"configurationField": "configuration", "description": "The speech model that
recognize uses, for example en-US_Mu [...]
- "operation": { "index": 5, "kind": "property", "displayName": "Operation",
"group": "producer", "label": "producer", "required": false, "type": "enum",
"javaType":
"org.apache.camel.component.ibm.watson.stt.WatsonSpeechToTextOperations",
"enum": [ "recognize", "listModels", "getModel", "listCustomModels",
"getCustomModel" ], "deprecated": false, "autowired": false, "secret": false,
"configurationClass":
"org.apache.camel.component.ibm.watson.stt.WatsonSpeechToTextConfiguration",
"con [...]
+ "contentType": { "index": 1, "kind": "property", "displayName": "Content
Type", "group": "producer", "label": "producer", "required": false, "type":
"string", "javaType": "java.lang.String", "deprecated": false, "autowired":
false, "secret": false, "defaultValue": "audio\/wav", "configurationClass":
"org.apache.camel.component.ibm.watson.stt.WatsonSpeechToTextConfiguration",
"configurationField": "configuration", "description": "The format (MIME type)
of the audio for recognize, for [...]
+ "lazyStartProducer": { "index": 2, "kind": "property", "displayName":
"Lazy Start Producer", "group": "producer", "label": "producer", "required":
false, "type": "boolean", "javaType": "boolean", "deprecated": false,
"autowired": false, "secret": false, "defaultValue": false, "description":
"Whether the producer should be started lazy (on the first message). By
starting lazy you can use this to allow CamelContext and routes to startup in
situations where a producer may otherwise fail [...]
+ "model": { "index": 3, "kind": "property", "displayName": "Model",
"group": "producer", "label": "producer", "required": false, "type": "string",
"javaType": "java.lang.String", "deprecated": false, "autowired": false,
"secret": false, "defaultValue": "en-US_BroadbandModel", "configurationClass":
"org.apache.camel.component.ibm.watson.stt.WatsonSpeechToTextConfiguration",
"configurationField": "configuration", "description": "The speech model that
recognize uses, for example en-US_Mu [...]
+ "operation": { "index": 4, "kind": "property", "displayName": "Operation",
"group": "producer", "label": "producer", "required": false, "type": "enum",
"javaType":
"org.apache.camel.component.ibm.watson.stt.WatsonSpeechToTextOperations",
"enum": [ "recognize", "listModels", "getModel", "listCustomModels",
"getCustomModel" ], "deprecated": false, "autowired": false, "secret": false,
"configurationClass":
"org.apache.camel.component.ibm.watson.stt.WatsonSpeechToTextConfiguration",
"con [...]
+ "serviceUrl": { "index": 5, "kind": "property", "displayName": "Service
Url", "group": "producer", "label": "producer", "required": false, "type":
"string", "javaType": "java.lang.String", "deprecated": false, "autowired":
false, "secret": false, "configurationClass":
"org.apache.camel.component.ibm.watson.stt.WatsonSpeechToTextConfiguration",
"configurationField": "configuration", "description": "The URL of the Speech to
Text service instance, for example https:\/\/api.eu-de.speech- [...]
"speakerLabels": { "index": 6, "kind": "property", "displayName": "Speaker
Labels", "group": "producer", "label": "producer", "required": false, "type":
"boolean", "javaType": "boolean", "deprecated": false, "autowired": false,
"secret": false, "defaultValue": false, "configurationClass":
"org.apache.camel.component.ibm.watson.stt.WatsonSpeechToTextConfiguration",
"configurationField": "configuration", "description": "Whether recognize
returns labels that identify which speaker spoke [...]
"timestamps": { "index": 7, "kind": "property", "displayName":
"Timestamps", "group": "producer", "label": "producer", "required": false,
"type": "boolean", "javaType": "boolean", "deprecated": false, "autowired":
false, "secret": false, "defaultValue": false, "configurationClass":
"org.apache.camel.component.ibm.watson.stt.WatsonSpeechToTextConfiguration",
"configurationField": "configuration", "description": "Whether recognize
returns the start and end time of each word, in seconds [...]
"wordConfidence": { "index": 8, "kind": "property", "displayName": "Word
Confidence", "group": "producer", "label": "producer", "required": false,
"type": "boolean", "javaType": "boolean", "deprecated": false, "autowired":
false, "secret": false, "defaultValue": false, "configurationClass":
"org.apache.camel.component.ibm.watson.stt.WatsonSpeechToTextConfiguration",
"configurationField": "configuration", "description": "Whether recognize
returns a confidence score from 0.0 to 1.0 for [...]
@@ -39,27 +39,28 @@
"apiKey": { "index": 12, "kind": "property", "displayName": "Api Key",
"group": "security", "label": "security", "required": true, "type": "string",
"javaType": "java.lang.String", "deprecated": false, "autowired": false,
"secret": true, "security": "secret", "configurationClass":
"org.apache.camel.component.ibm.watson.stt.WatsonSpeechToTextConfiguration",
"configurationField": "configuration", "description": "The IBM Cloud API key of
the Speech to Text service instance. The client g [...]
},
"headers": {
- "CamelIBMWatsonSTTOperation": { "index": 0, "kind": "header",
"displayName": "", "group": "producer", "label": "", "required": false,
"javaType": "String", "deprecated": false, "autowired": false, "secret": false,
"description": "The operation that the producer performs. It replaces the
operation option.", "constantName":
"org.apache.camel.component.ibm.watson.stt.WatsonSpeechToTextConstants#OPERATION"
},
- "CamelIBMWatsonSTTAudioFile": { "index": 1, "kind": "header",
"displayName": "", "group": "producer", "label": "", "required": false,
"javaType": "java.io.File", "deprecated": false, "autowired": false, "secret":
false, "description": "The audio file that recognize transcribes. If set, the
producer sends this file instead of the message body.", "constantName":
"org.apache.camel.component.ibm.watson.stt.WatsonSpeechToTextConstants#AUDIO_FILE"
},
- "CamelIBMWatsonSTTModel": { "index": 2, "kind": "header", "displayName":
"", "group": "producer", "label": "", "required": false, "javaType": "String",
"deprecated": false, "autowired": false, "secret": false, "description": "The
speech model that recognize uses. It replaces the model option. The producer
sets it on the result to the model it used.", "constantName":
"org.apache.camel.component.ibm.watson.stt.WatsonSpeechToTextConstants#MODEL" },
- "CamelIBMWatsonSTTContentType": { "index": 3, "kind": "header",
"displayName": "", "group": "producer", "label": "", "required": false,
"javaType": "String", "deprecated": false, "autowired": false, "secret": false,
"description": "The format (MIME type) of the audio for recognize. It replaces
the contentType option. The producer sets it on the result to the format it
sent.", "constantName":
"org.apache.camel.component.ibm.watson.stt.WatsonSpeechToTextConstants#CONTENT_TYPE"
},
- "CamelIBMWatsonSTTTimestamps": { "index": 4, "kind": "header",
"displayName": "", "group": "producer", "label": "", "required": false,
"javaType": "Boolean", "deprecated": false, "autowired": false, "secret":
false, "description": "Whether recognize returns the start and end time of each
word. It replaces the timestamps option.", "constantName":
"org.apache.camel.component.ibm.watson.stt.WatsonSpeechToTextConstants#TIMESTAMPS"
},
- "CamelIBMWatsonSTTWordConfidence": { "index": 5, "kind": "header",
"displayName": "", "group": "producer", "label": "", "required": false,
"javaType": "Boolean", "deprecated": false, "autowired": false, "secret":
false, "description": "Whether recognize returns a confidence score for each
word. It replaces the wordConfidence option.", "constantName":
"org.apache.camel.component.ibm.watson.stt.WatsonSpeechToTextConstants#WORD_CONFIDENCE"
},
- "CamelIBMWatsonSTTSpeakerLabels": { "index": 6, "kind": "header",
"displayName": "", "group": "producer", "label": "", "required": false,
"javaType": "Boolean", "deprecated": false, "autowired": false, "secret":
false, "description": "Whether recognize returns labels that identify the
speaker of each word. It replaces the speakerLabels option.", "constantName":
"org.apache.camel.component.ibm.watson.stt.WatsonSpeechToTextConstants#SPEAKER_LABELS"
},
- "CamelIBMWatsonSTTModelName": { "index": 7, "kind": "header",
"displayName": "", "group": "producer", "label": "", "required": false,
"javaType": "String", "deprecated": false, "autowired": false, "secret": false,
"description": "The name of the speech model for getModel, or the customization
ID of the custom language model for getCustomModel. If not set, the producer
reads it from the message body.", "constantName":
"org.apache.camel.component.ibm.watson.stt.WatsonSpeechToTextConsta [...]
- "CamelIBMWatsonSTTLanguage": { "index": 8, "kind": "header",
"displayName": "", "group": "producer", "label": "", "required": false,
"javaType": "String", "deprecated": false, "autowired": false, "secret": false,
"description": "The language for listCustomModels, for example en-US, to list
only the custom language models of that language. If not set, all custom
language models of the service instance are listed.", "constantName":
"org.apache.camel.component.ibm.watson.stt.WatsonSpeec [...]
- "CamelIBMWatsonSTTTranscript": { "index": 9, "kind": "header",
"displayName": "", "group": "producer", "label": "", "required": false,
"javaType": "String", "deprecated": false, "autowired": false, "secret": false,
"description": "The transcript that recognize sets: the text of the first
alternative of each result, joined in order.", "constantName":
"org.apache.camel.component.ibm.watson.stt.WatsonSpeechToTextConstants#TRANSCRIPT"
}
+ "CamelIBMWatsonSTTOperation": { "index": 0, "kind": "header",
"displayName": "", "group": "producer", "label": "producer", "required": false,
"javaType": "String", "deprecated": false, "autowired": false, "secret": false,
"description": "The operation that the producer performs. It replaces the
operation option.", "constantName":
"org.apache.camel.component.ibm.watson.stt.WatsonSpeechToTextConstants#OPERATION"
},
+ "CamelIBMWatsonSTTAudioFile": { "index": 1, "kind": "header",
"displayName": "", "group": "producer", "label": "producer", "required": false,
"javaType": "java.io.File", "deprecated": false, "autowired": false, "secret":
false, "description": "The audio file that recognize transcribes. If set, the
producer sends this file instead of the message body.", "constantName":
"org.apache.camel.component.ibm.watson.stt.WatsonSpeechToTextConstants#AUDIO_FILE"
},
+ "CamelIBMWatsonSTTModel": { "index": 2, "kind": "header", "displayName":
"", "group": "producer", "label": "producer", "required": false, "javaType":
"String", "deprecated": false, "autowired": false, "secret": false,
"description": "The speech model that recognize uses. It replaces the model
option. The producer sets it on the result to the model it used.",
"constantName":
"org.apache.camel.component.ibm.watson.stt.WatsonSpeechToTextConstants#MODEL" },
+ "CamelIBMWatsonSTTContentType": { "index": 3, "kind": "header",
"displayName": "", "group": "producer", "label": "producer", "required": false,
"javaType": "String", "deprecated": false, "autowired": false, "secret": false,
"description": "The format (MIME type) of the audio for recognize. It replaces
the contentType option. The producer sets it on the result to the format it
sent.", "constantName":
"org.apache.camel.component.ibm.watson.stt.WatsonSpeechToTextConstants#CONTENT_TYPE"
},
+ "CamelIBMWatsonSTTTimestamps": { "index": 4, "kind": "header",
"displayName": "", "group": "producer", "label": "producer", "required": false,
"javaType": "Boolean", "deprecated": false, "autowired": false, "secret":
false, "description": "Whether recognize returns the start and end time of each
word. It replaces the timestamps option.", "constantName":
"org.apache.camel.component.ibm.watson.stt.WatsonSpeechToTextConstants#TIMESTAMPS"
},
+ "CamelIBMWatsonSTTWordConfidence": { "index": 5, "kind": "header",
"displayName": "", "group": "producer", "label": "producer", "required": false,
"javaType": "Boolean", "deprecated": false, "autowired": false, "secret":
false, "description": "Whether recognize returns a confidence score for each
word. It replaces the wordConfidence option.", "constantName":
"org.apache.camel.component.ibm.watson.stt.WatsonSpeechToTextConstants#WORD_CONFIDENCE"
},
+ "CamelIBMWatsonSTTSpeakerLabels": { "index": 6, "kind": "header",
"displayName": "", "group": "producer", "label": "producer", "required": false,
"javaType": "Boolean", "deprecated": false, "autowired": false, "secret":
false, "description": "Whether recognize returns labels that identify the
speaker of each word. It replaces the speakerLabels option.", "constantName":
"org.apache.camel.component.ibm.watson.stt.WatsonSpeechToTextConstants#SPEAKER_LABELS"
},
+ "CamelIBMWatsonSTTModelName": { "index": 7, "kind": "header",
"displayName": "", "group": "producer", "label": "producer", "required": false,
"javaType": "String", "deprecated": false, "autowired": false, "secret": false,
"description": "The name of the speech model for getModel. getCustomModel reads
it as the customization ID of the custom language model when the
CamelIBMWatsonSTTCustomizationId header is not set. If not set, the producer
reads it from the message body.", "constantN [...]
+ "CamelIBMWatsonSTTCustomizationId": { "index": 8, "kind": "header",
"displayName": "", "group": "producer", "label": "producer", "required": false,
"javaType": "String", "deprecated": false, "autowired": false, "secret": false,
"description": "The customization ID (a GUID) of the custom language model for
getCustomModel. It comes before the CamelIBMWatsonSTTModelName header and the
message body.", "constantName":
"org.apache.camel.component.ibm.watson.stt.WatsonSpeechToTextConstants# [...]
+ "CamelIBMWatsonSTTLanguage": { "index": 9, "kind": "header",
"displayName": "", "group": "producer", "label": "producer", "required": false,
"javaType": "String", "deprecated": false, "autowired": false, "secret": false,
"description": "The language for listCustomModels, for example en-US, to list
only the custom language models of that language. If not set, all custom
language models of the service instance are listed.", "constantName":
"org.apache.camel.component.ibm.watson.stt.Wat [...]
+ "CamelIBMWatsonSTTTranscript": { "index": 10, "kind": "header",
"displayName": "", "group": "producer", "label": "producer", "required": false,
"javaType": "String", "deprecated": false, "autowired": false, "secret": false,
"description": "The transcript that recognize sets: the text of the first
alternative of each result, joined in order.", "constantName":
"org.apache.camel.component.ibm.watson.stt.WatsonSpeechToTextConstants#TRANSCRIPT"
}
},
"bodyTypes": {
- "producerIn": { "carriers": [ "bytes", "stream", "file" ], "byOption": [ {
"option": "operation", "value": "listModels", "carriers": [ "any" ] }, {
"option": "operation", "value": "getModel", "carriers": [ "text" ] }, {
"option": "operation", "value": "listCustomModels", "carriers": [ "any" ] }, {
"option": "operation", "value": "getCustomModel", "carriers": [ "text" ] } ],
"description": "The audio to recognize in the format of contentType (audio\/wav
by default), as bytes, a stream [...]
+ "producerIn": { "carriers": [ "bytes", "stream", "file" ], "byOption": [ {
"option": "operation", "value": "listModels", "carriers": [ "any" ] }, {
"option": "operation", "value": "getModel", "carriers": [ "text" ] }, {
"option": "operation", "value": "listCustomModels", "carriers": [ "any" ] }, {
"option": "operation", "value": "getCustomModel", "carriers": [ "text" ] } ],
"description": "The audio to recognize in the format of contentType (audio\/wav
by default), as bytes, a stream [...]
"producerOut": { "carriers": [ "pojo" ], "javaType":
"com.ibm.watson.speech_to_text.v1.model.SpeechRecognitionResults", "byOption":
[ { "option": "operation", "value": "listModels", "carriers": [ "list" ] }, {
"option": "operation", "value": "getModel", "carriers": [ "pojo" ], "javaType":
"com.ibm.watson.speech_to_text.v1.model.SpeechModel" }, { "option":
"operation", "value": "listCustomModels", "carriers": [ "list" ] }, { "option":
"operation", "value": "getCustomModel", "carriers" [...]
},
"properties": {
"label": { "index": 0, "kind": "path", "displayName": "Label", "group":
"producer", "label": "", "required": true, "type": "string", "javaType":
"java.lang.String", "deprecated": false, "autowired": false, "secret": false,
"description": "A logical name for the endpoint, for example to tell endpoints
apart. The component does not use it." },
- "serviceUrl": { "index": 1, "kind": "parameter", "displayName": "Service
Url", "group": "common", "label": "common", "required": false, "type":
"string", "javaType": "java.lang.String", "deprecated": false, "autowired":
false, "secret": false, "configurationClass":
"org.apache.camel.component.ibm.watson.stt.WatsonSpeechToTextConfiguration",
"configurationField": "configuration", "description": "The URL of the Speech to
Text service instance, for example https:\/\/api.eu-de.speech-to- [...]
- "contentType": { "index": 2, "kind": "parameter", "displayName": "Content
Type", "group": "producer", "label": "producer", "required": false, "type":
"string", "javaType": "java.lang.String", "deprecated": false, "autowired":
false, "secret": false, "defaultValue": "audio\/wav", "configurationClass":
"org.apache.camel.component.ibm.watson.stt.WatsonSpeechToTextConfiguration",
"configurationField": "configuration", "description": "The format (MIME type)
of the audio for recognize, for [...]
- "model": { "index": 3, "kind": "parameter", "displayName": "Model",
"group": "producer", "label": "producer", "required": false, "type": "string",
"javaType": "java.lang.String", "deprecated": false, "autowired": false,
"secret": false, "defaultValue": "en-US_BroadbandModel", "configurationClass":
"org.apache.camel.component.ibm.watson.stt.WatsonSpeechToTextConfiguration",
"configurationField": "configuration", "description": "The speech model that
recognize uses, for example en-US_M [...]
- "operation": { "index": 4, "kind": "parameter", "displayName":
"Operation", "group": "producer", "label": "producer", "required": false,
"type": "enum", "javaType":
"org.apache.camel.component.ibm.watson.stt.WatsonSpeechToTextOperations",
"enum": [ "recognize", "listModels", "getModel", "listCustomModels",
"getCustomModel" ], "deprecated": false, "autowired": false, "secret": false,
"configurationClass":
"org.apache.camel.component.ibm.watson.stt.WatsonSpeechToTextConfiguration",
"co [...]
+ "contentType": { "index": 1, "kind": "parameter", "displayName": "Content
Type", "group": "producer", "label": "producer", "required": false, "type":
"string", "javaType": "java.lang.String", "deprecated": false, "autowired":
false, "secret": false, "defaultValue": "audio\/wav", "configurationClass":
"org.apache.camel.component.ibm.watson.stt.WatsonSpeechToTextConfiguration",
"configurationField": "configuration", "description": "The format (MIME type)
of the audio for recognize, for [...]
+ "model": { "index": 2, "kind": "parameter", "displayName": "Model",
"group": "producer", "label": "producer", "required": false, "type": "string",
"javaType": "java.lang.String", "deprecated": false, "autowired": false,
"secret": false, "defaultValue": "en-US_BroadbandModel", "configurationClass":
"org.apache.camel.component.ibm.watson.stt.WatsonSpeechToTextConfiguration",
"configurationField": "configuration", "description": "The speech model that
recognize uses, for example en-US_M [...]
+ "operation": { "index": 3, "kind": "parameter", "displayName":
"Operation", "group": "producer", "label": "producer", "required": false,
"type": "enum", "javaType":
"org.apache.camel.component.ibm.watson.stt.WatsonSpeechToTextOperations",
"enum": [ "recognize", "listModels", "getModel", "listCustomModels",
"getCustomModel" ], "deprecated": false, "autowired": false, "secret": false,
"configurationClass":
"org.apache.camel.component.ibm.watson.stt.WatsonSpeechToTextConfiguration",
"co [...]
+ "serviceUrl": { "index": 4, "kind": "parameter", "displayName": "Service
Url", "group": "producer", "label": "producer", "required": false, "type":
"string", "javaType": "java.lang.String", "deprecated": false, "autowired":
false, "secret": false, "configurationClass":
"org.apache.camel.component.ibm.watson.stt.WatsonSpeechToTextConfiguration",
"configurationField": "configuration", "description": "The URL of the Speech to
Text service instance, for example https:\/\/api.eu-de.speech [...]
"speakerLabels": { "index": 5, "kind": "parameter", "displayName":
"Speaker Labels", "group": "producer", "label": "producer", "required": false,
"type": "boolean", "javaType": "boolean", "deprecated": false, "autowired":
false, "secret": false, "defaultValue": false, "configurationClass":
"org.apache.camel.component.ibm.watson.stt.WatsonSpeechToTextConfiguration",
"configurationField": "configuration", "description": "Whether recognize
returns labels that identify which speaker spok [...]
"timestamps": { "index": 6, "kind": "parameter", "displayName":
"Timestamps", "group": "producer", "label": "producer", "required": false,
"type": "boolean", "javaType": "boolean", "deprecated": false, "autowired":
false, "secret": false, "defaultValue": false, "configurationClass":
"org.apache.camel.component.ibm.watson.stt.WatsonSpeechToTextConfiguration",
"configurationField": "configuration", "description": "Whether recognize
returns the start and end time of each word, in second [...]
"wordConfidence": { "index": 7, "kind": "parameter", "displayName": "Word
Confidence", "group": "producer", "label": "producer", "required": false,
"type": "boolean", "javaType": "boolean", "deprecated": false, "autowired":
false, "secret": false, "defaultValue": false, "configurationClass":
"org.apache.camel.component.ibm.watson.stt.WatsonSpeechToTextConfiguration",
"configurationField": "configuration", "description": "Whether recognize
returns a confidence score from 0.0 to 1.0 fo [...]
diff --git
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/ibm-watson-speech-to-text-component.adoc
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/ibm-watson-speech-to-text-component.adoc
index 26849a91c80f..077ca0c91acc 100644
---
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/ibm-watson-speech-to-text-component.adoc
+++
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/ibm-watson-speech-to-text-component.adoc
@@ -57,6 +57,13 @@ The IBM Watson Speech to Text component provides the
following operations:
If you don't specify an operation explicitly, you must set it via the
`operation` parameter.
+=== Health check
+
+The producer registers a health check that lists the models of the service, so
it is down when Speech to Text cannot
+be reached or rejects the request. Like the other producer health checks of
Camel, it runs only when producer
+health checks are enabled, for example with
`camel.health.producersEnabled=true`, and the
+`healthCheckProducerEnabled` option of the component turns it off.
+
=== Audio input
The `recognize` operation reads the audio from the file of the
`CamelIBMWatsonSTTAudioFile` header, or from the
@@ -418,7 +425,7 @@ Get detailed information about a custom model:
[source,java]
----
from("direct:getCustomModel")
- .setHeader("CamelIBMWatsonSTTModelName", constant("your-custom-model-guid"))
+ .setHeader("CamelIBMWatsonSTTCustomizationId",
constant("your-custom-model-guid"))
.to("ibm-watson-speech-to-text:mySTT?apiKey=RAW(yourApiKey)&operation=getCustomModel")
.process(exchange -> {
LanguageModel model = exchange.getMessage().getBody(LanguageModel.class);
diff --git
a/components/camel-ibm/camel-ibm-watson-speech-to-text/src/generated/resources/META-INF/org/apache/camel/component/ibm/watson/stt/ibm-watson-speech-to-text.json
b/components/camel-ibm/camel-ibm-watson-speech-to-text/src/generated/resources/META-INF/org/apache/camel/component/ibm/watson/stt/ibm-watson-speech-to-text.json
index 38bb85cbc096..c7963da6c3a3 100644
---
a/components/camel-ibm/camel-ibm-watson-speech-to-text/src/generated/resources/META-INF/org/apache/camel/component/ibm/watson/stt/ibm-watson-speech-to-text.json
+++
b/components/camel-ibm/camel-ibm-watson-speech-to-text/src/generated/resources/META-INF/org/apache/camel/component/ibm/watson/stt/ibm-watson-speech-to-text.json
@@ -25,11 +25,11 @@
},
"componentProperties": {
"configuration": { "index": 0, "kind": "property", "displayName":
"Configuration", "group": "producer", "label": "", "required": false, "type":
"object", "javaType":
"org.apache.camel.component.ibm.watson.stt.WatsonSpeechToTextConfiguration",
"deprecated": false, "autowired": false, "secret": false, "description": "The
shared configuration of the endpoints. Each endpoint starts from a copy of it,
and its endpoint options override the values." },
- "serviceUrl": { "index": 1, "kind": "property", "displayName": "Service
Url", "group": "common", "label": "common", "required": false, "type":
"string", "javaType": "java.lang.String", "deprecated": false, "autowired":
false, "secret": false, "configurationClass":
"org.apache.camel.component.ibm.watson.stt.WatsonSpeechToTextConfiguration",
"configurationField": "configuration", "description": "The URL of the Speech to
Text service instance, for example https:\/\/api.eu-de.speech-to-t [...]
- "contentType": { "index": 2, "kind": "property", "displayName": "Content
Type", "group": "producer", "label": "producer", "required": false, "type":
"string", "javaType": "java.lang.String", "deprecated": false, "autowired":
false, "secret": false, "defaultValue": "audio\/wav", "configurationClass":
"org.apache.camel.component.ibm.watson.stt.WatsonSpeechToTextConfiguration",
"configurationField": "configuration", "description": "The format (MIME type)
of the audio for recognize, for [...]
- "lazyStartProducer": { "index": 3, "kind": "property", "displayName":
"Lazy Start Producer", "group": "producer", "label": "producer", "required":
false, "type": "boolean", "javaType": "boolean", "deprecated": false,
"autowired": false, "secret": false, "defaultValue": false, "description":
"Whether the producer should be started lazy (on the first message). By
starting lazy you can use this to allow CamelContext and routes to startup in
situations where a producer may otherwise fail [...]
- "model": { "index": 4, "kind": "property", "displayName": "Model",
"group": "producer", "label": "producer", "required": false, "type": "string",
"javaType": "java.lang.String", "deprecated": false, "autowired": false,
"secret": false, "defaultValue": "en-US_BroadbandModel", "configurationClass":
"org.apache.camel.component.ibm.watson.stt.WatsonSpeechToTextConfiguration",
"configurationField": "configuration", "description": "The speech model that
recognize uses, for example en-US_Mu [...]
- "operation": { "index": 5, "kind": "property", "displayName": "Operation",
"group": "producer", "label": "producer", "required": false, "type": "enum",
"javaType":
"org.apache.camel.component.ibm.watson.stt.WatsonSpeechToTextOperations",
"enum": [ "recognize", "listModels", "getModel", "listCustomModels",
"getCustomModel" ], "deprecated": false, "autowired": false, "secret": false,
"configurationClass":
"org.apache.camel.component.ibm.watson.stt.WatsonSpeechToTextConfiguration",
"con [...]
+ "contentType": { "index": 1, "kind": "property", "displayName": "Content
Type", "group": "producer", "label": "producer", "required": false, "type":
"string", "javaType": "java.lang.String", "deprecated": false, "autowired":
false, "secret": false, "defaultValue": "audio\/wav", "configurationClass":
"org.apache.camel.component.ibm.watson.stt.WatsonSpeechToTextConfiguration",
"configurationField": "configuration", "description": "The format (MIME type)
of the audio for recognize, for [...]
+ "lazyStartProducer": { "index": 2, "kind": "property", "displayName":
"Lazy Start Producer", "group": "producer", "label": "producer", "required":
false, "type": "boolean", "javaType": "boolean", "deprecated": false,
"autowired": false, "secret": false, "defaultValue": false, "description":
"Whether the producer should be started lazy (on the first message). By
starting lazy you can use this to allow CamelContext and routes to startup in
situations where a producer may otherwise fail [...]
+ "model": { "index": 3, "kind": "property", "displayName": "Model",
"group": "producer", "label": "producer", "required": false, "type": "string",
"javaType": "java.lang.String", "deprecated": false, "autowired": false,
"secret": false, "defaultValue": "en-US_BroadbandModel", "configurationClass":
"org.apache.camel.component.ibm.watson.stt.WatsonSpeechToTextConfiguration",
"configurationField": "configuration", "description": "The speech model that
recognize uses, for example en-US_Mu [...]
+ "operation": { "index": 4, "kind": "property", "displayName": "Operation",
"group": "producer", "label": "producer", "required": false, "type": "enum",
"javaType":
"org.apache.camel.component.ibm.watson.stt.WatsonSpeechToTextOperations",
"enum": [ "recognize", "listModels", "getModel", "listCustomModels",
"getCustomModel" ], "deprecated": false, "autowired": false, "secret": false,
"configurationClass":
"org.apache.camel.component.ibm.watson.stt.WatsonSpeechToTextConfiguration",
"con [...]
+ "serviceUrl": { "index": 5, "kind": "property", "displayName": "Service
Url", "group": "producer", "label": "producer", "required": false, "type":
"string", "javaType": "java.lang.String", "deprecated": false, "autowired":
false, "secret": false, "configurationClass":
"org.apache.camel.component.ibm.watson.stt.WatsonSpeechToTextConfiguration",
"configurationField": "configuration", "description": "The URL of the Speech to
Text service instance, for example https:\/\/api.eu-de.speech- [...]
"speakerLabels": { "index": 6, "kind": "property", "displayName": "Speaker
Labels", "group": "producer", "label": "producer", "required": false, "type":
"boolean", "javaType": "boolean", "deprecated": false, "autowired": false,
"secret": false, "defaultValue": false, "configurationClass":
"org.apache.camel.component.ibm.watson.stt.WatsonSpeechToTextConfiguration",
"configurationField": "configuration", "description": "Whether recognize
returns labels that identify which speaker spoke [...]
"timestamps": { "index": 7, "kind": "property", "displayName":
"Timestamps", "group": "producer", "label": "producer", "required": false,
"type": "boolean", "javaType": "boolean", "deprecated": false, "autowired":
false, "secret": false, "defaultValue": false, "configurationClass":
"org.apache.camel.component.ibm.watson.stt.WatsonSpeechToTextConfiguration",
"configurationField": "configuration", "description": "Whether recognize
returns the start and end time of each word, in seconds [...]
"wordConfidence": { "index": 8, "kind": "property", "displayName": "Word
Confidence", "group": "producer", "label": "producer", "required": false,
"type": "boolean", "javaType": "boolean", "deprecated": false, "autowired":
false, "secret": false, "defaultValue": false, "configurationClass":
"org.apache.camel.component.ibm.watson.stt.WatsonSpeechToTextConfiguration",
"configurationField": "configuration", "description": "Whether recognize
returns a confidence score from 0.0 to 1.0 for [...]
@@ -39,27 +39,28 @@
"apiKey": { "index": 12, "kind": "property", "displayName": "Api Key",
"group": "security", "label": "security", "required": true, "type": "string",
"javaType": "java.lang.String", "deprecated": false, "autowired": false,
"secret": true, "security": "secret", "configurationClass":
"org.apache.camel.component.ibm.watson.stt.WatsonSpeechToTextConfiguration",
"configurationField": "configuration", "description": "The IBM Cloud API key of
the Speech to Text service instance. The client g [...]
},
"headers": {
- "CamelIBMWatsonSTTOperation": { "index": 0, "kind": "header",
"displayName": "", "group": "producer", "label": "", "required": false,
"javaType": "String", "deprecated": false, "autowired": false, "secret": false,
"description": "The operation that the producer performs. It replaces the
operation option.", "constantName":
"org.apache.camel.component.ibm.watson.stt.WatsonSpeechToTextConstants#OPERATION"
},
- "CamelIBMWatsonSTTAudioFile": { "index": 1, "kind": "header",
"displayName": "", "group": "producer", "label": "", "required": false,
"javaType": "java.io.File", "deprecated": false, "autowired": false, "secret":
false, "description": "The audio file that recognize transcribes. If set, the
producer sends this file instead of the message body.", "constantName":
"org.apache.camel.component.ibm.watson.stt.WatsonSpeechToTextConstants#AUDIO_FILE"
},
- "CamelIBMWatsonSTTModel": { "index": 2, "kind": "header", "displayName":
"", "group": "producer", "label": "", "required": false, "javaType": "String",
"deprecated": false, "autowired": false, "secret": false, "description": "The
speech model that recognize uses. It replaces the model option. The producer
sets it on the result to the model it used.", "constantName":
"org.apache.camel.component.ibm.watson.stt.WatsonSpeechToTextConstants#MODEL" },
- "CamelIBMWatsonSTTContentType": { "index": 3, "kind": "header",
"displayName": "", "group": "producer", "label": "", "required": false,
"javaType": "String", "deprecated": false, "autowired": false, "secret": false,
"description": "The format (MIME type) of the audio for recognize. It replaces
the contentType option. The producer sets it on the result to the format it
sent.", "constantName":
"org.apache.camel.component.ibm.watson.stt.WatsonSpeechToTextConstants#CONTENT_TYPE"
},
- "CamelIBMWatsonSTTTimestamps": { "index": 4, "kind": "header",
"displayName": "", "group": "producer", "label": "", "required": false,
"javaType": "Boolean", "deprecated": false, "autowired": false, "secret":
false, "description": "Whether recognize returns the start and end time of each
word. It replaces the timestamps option.", "constantName":
"org.apache.camel.component.ibm.watson.stt.WatsonSpeechToTextConstants#TIMESTAMPS"
},
- "CamelIBMWatsonSTTWordConfidence": { "index": 5, "kind": "header",
"displayName": "", "group": "producer", "label": "", "required": false,
"javaType": "Boolean", "deprecated": false, "autowired": false, "secret":
false, "description": "Whether recognize returns a confidence score for each
word. It replaces the wordConfidence option.", "constantName":
"org.apache.camel.component.ibm.watson.stt.WatsonSpeechToTextConstants#WORD_CONFIDENCE"
},
- "CamelIBMWatsonSTTSpeakerLabels": { "index": 6, "kind": "header",
"displayName": "", "group": "producer", "label": "", "required": false,
"javaType": "Boolean", "deprecated": false, "autowired": false, "secret":
false, "description": "Whether recognize returns labels that identify the
speaker of each word. It replaces the speakerLabels option.", "constantName":
"org.apache.camel.component.ibm.watson.stt.WatsonSpeechToTextConstants#SPEAKER_LABELS"
},
- "CamelIBMWatsonSTTModelName": { "index": 7, "kind": "header",
"displayName": "", "group": "producer", "label": "", "required": false,
"javaType": "String", "deprecated": false, "autowired": false, "secret": false,
"description": "The name of the speech model for getModel, or the customization
ID of the custom language model for getCustomModel. If not set, the producer
reads it from the message body.", "constantName":
"org.apache.camel.component.ibm.watson.stt.WatsonSpeechToTextConsta [...]
- "CamelIBMWatsonSTTLanguage": { "index": 8, "kind": "header",
"displayName": "", "group": "producer", "label": "", "required": false,
"javaType": "String", "deprecated": false, "autowired": false, "secret": false,
"description": "The language for listCustomModels, for example en-US, to list
only the custom language models of that language. If not set, all custom
language models of the service instance are listed.", "constantName":
"org.apache.camel.component.ibm.watson.stt.WatsonSpeec [...]
- "CamelIBMWatsonSTTTranscript": { "index": 9, "kind": "header",
"displayName": "", "group": "producer", "label": "", "required": false,
"javaType": "String", "deprecated": false, "autowired": false, "secret": false,
"description": "The transcript that recognize sets: the text of the first
alternative of each result, joined in order.", "constantName":
"org.apache.camel.component.ibm.watson.stt.WatsonSpeechToTextConstants#TRANSCRIPT"
}
+ "CamelIBMWatsonSTTOperation": { "index": 0, "kind": "header",
"displayName": "", "group": "producer", "label": "producer", "required": false,
"javaType": "String", "deprecated": false, "autowired": false, "secret": false,
"description": "The operation that the producer performs. It replaces the
operation option.", "constantName":
"org.apache.camel.component.ibm.watson.stt.WatsonSpeechToTextConstants#OPERATION"
},
+ "CamelIBMWatsonSTTAudioFile": { "index": 1, "kind": "header",
"displayName": "", "group": "producer", "label": "producer", "required": false,
"javaType": "java.io.File", "deprecated": false, "autowired": false, "secret":
false, "description": "The audio file that recognize transcribes. If set, the
producer sends this file instead of the message body.", "constantName":
"org.apache.camel.component.ibm.watson.stt.WatsonSpeechToTextConstants#AUDIO_FILE"
},
+ "CamelIBMWatsonSTTModel": { "index": 2, "kind": "header", "displayName":
"", "group": "producer", "label": "producer", "required": false, "javaType":
"String", "deprecated": false, "autowired": false, "secret": false,
"description": "The speech model that recognize uses. It replaces the model
option. The producer sets it on the result to the model it used.",
"constantName":
"org.apache.camel.component.ibm.watson.stt.WatsonSpeechToTextConstants#MODEL" },
+ "CamelIBMWatsonSTTContentType": { "index": 3, "kind": "header",
"displayName": "", "group": "producer", "label": "producer", "required": false,
"javaType": "String", "deprecated": false, "autowired": false, "secret": false,
"description": "The format (MIME type) of the audio for recognize. It replaces
the contentType option. The producer sets it on the result to the format it
sent.", "constantName":
"org.apache.camel.component.ibm.watson.stt.WatsonSpeechToTextConstants#CONTENT_TYPE"
},
+ "CamelIBMWatsonSTTTimestamps": { "index": 4, "kind": "header",
"displayName": "", "group": "producer", "label": "producer", "required": false,
"javaType": "Boolean", "deprecated": false, "autowired": false, "secret":
false, "description": "Whether recognize returns the start and end time of each
word. It replaces the timestamps option.", "constantName":
"org.apache.camel.component.ibm.watson.stt.WatsonSpeechToTextConstants#TIMESTAMPS"
},
+ "CamelIBMWatsonSTTWordConfidence": { "index": 5, "kind": "header",
"displayName": "", "group": "producer", "label": "producer", "required": false,
"javaType": "Boolean", "deprecated": false, "autowired": false, "secret":
false, "description": "Whether recognize returns a confidence score for each
word. It replaces the wordConfidence option.", "constantName":
"org.apache.camel.component.ibm.watson.stt.WatsonSpeechToTextConstants#WORD_CONFIDENCE"
},
+ "CamelIBMWatsonSTTSpeakerLabels": { "index": 6, "kind": "header",
"displayName": "", "group": "producer", "label": "producer", "required": false,
"javaType": "Boolean", "deprecated": false, "autowired": false, "secret":
false, "description": "Whether recognize returns labels that identify the
speaker of each word. It replaces the speakerLabels option.", "constantName":
"org.apache.camel.component.ibm.watson.stt.WatsonSpeechToTextConstants#SPEAKER_LABELS"
},
+ "CamelIBMWatsonSTTModelName": { "index": 7, "kind": "header",
"displayName": "", "group": "producer", "label": "producer", "required": false,
"javaType": "String", "deprecated": false, "autowired": false, "secret": false,
"description": "The name of the speech model for getModel. getCustomModel reads
it as the customization ID of the custom language model when the
CamelIBMWatsonSTTCustomizationId header is not set. If not set, the producer
reads it from the message body.", "constantN [...]
+ "CamelIBMWatsonSTTCustomizationId": { "index": 8, "kind": "header",
"displayName": "", "group": "producer", "label": "producer", "required": false,
"javaType": "String", "deprecated": false, "autowired": false, "secret": false,
"description": "The customization ID (a GUID) of the custom language model for
getCustomModel. It comes before the CamelIBMWatsonSTTModelName header and the
message body.", "constantName":
"org.apache.camel.component.ibm.watson.stt.WatsonSpeechToTextConstants# [...]
+ "CamelIBMWatsonSTTLanguage": { "index": 9, "kind": "header",
"displayName": "", "group": "producer", "label": "producer", "required": false,
"javaType": "String", "deprecated": false, "autowired": false, "secret": false,
"description": "The language for listCustomModels, for example en-US, to list
only the custom language models of that language. If not set, all custom
language models of the service instance are listed.", "constantName":
"org.apache.camel.component.ibm.watson.stt.Wat [...]
+ "CamelIBMWatsonSTTTranscript": { "index": 10, "kind": "header",
"displayName": "", "group": "producer", "label": "producer", "required": false,
"javaType": "String", "deprecated": false, "autowired": false, "secret": false,
"description": "The transcript that recognize sets: the text of the first
alternative of each result, joined in order.", "constantName":
"org.apache.camel.component.ibm.watson.stt.WatsonSpeechToTextConstants#TRANSCRIPT"
}
},
"bodyTypes": {
- "producerIn": { "carriers": [ "bytes", "stream", "file" ], "byOption": [ {
"option": "operation", "value": "listModels", "carriers": [ "any" ] }, {
"option": "operation", "value": "getModel", "carriers": [ "text" ] }, {
"option": "operation", "value": "listCustomModels", "carriers": [ "any" ] }, {
"option": "operation", "value": "getCustomModel", "carriers": [ "text" ] } ],
"description": "The audio to recognize in the format of contentType (audio\/wav
by default), as bytes, a stream [...]
+ "producerIn": { "carriers": [ "bytes", "stream", "file" ], "byOption": [ {
"option": "operation", "value": "listModels", "carriers": [ "any" ] }, {
"option": "operation", "value": "getModel", "carriers": [ "text" ] }, {
"option": "operation", "value": "listCustomModels", "carriers": [ "any" ] }, {
"option": "operation", "value": "getCustomModel", "carriers": [ "text" ] } ],
"description": "The audio to recognize in the format of contentType (audio\/wav
by default), as bytes, a stream [...]
"producerOut": { "carriers": [ "pojo" ], "javaType":
"com.ibm.watson.speech_to_text.v1.model.SpeechRecognitionResults", "byOption":
[ { "option": "operation", "value": "listModels", "carriers": [ "list" ] }, {
"option": "operation", "value": "getModel", "carriers": [ "pojo" ], "javaType":
"com.ibm.watson.speech_to_text.v1.model.SpeechModel" }, { "option":
"operation", "value": "listCustomModels", "carriers": [ "list" ] }, { "option":
"operation", "value": "getCustomModel", "carriers" [...]
},
"properties": {
"label": { "index": 0, "kind": "path", "displayName": "Label", "group":
"producer", "label": "", "required": true, "type": "string", "javaType":
"java.lang.String", "deprecated": false, "autowired": false, "secret": false,
"description": "A logical name for the endpoint, for example to tell endpoints
apart. The component does not use it." },
- "serviceUrl": { "index": 1, "kind": "parameter", "displayName": "Service
Url", "group": "common", "label": "common", "required": false, "type":
"string", "javaType": "java.lang.String", "deprecated": false, "autowired":
false, "secret": false, "configurationClass":
"org.apache.camel.component.ibm.watson.stt.WatsonSpeechToTextConfiguration",
"configurationField": "configuration", "description": "The URL of the Speech to
Text service instance, for example https:\/\/api.eu-de.speech-to- [...]
- "contentType": { "index": 2, "kind": "parameter", "displayName": "Content
Type", "group": "producer", "label": "producer", "required": false, "type":
"string", "javaType": "java.lang.String", "deprecated": false, "autowired":
false, "secret": false, "defaultValue": "audio\/wav", "configurationClass":
"org.apache.camel.component.ibm.watson.stt.WatsonSpeechToTextConfiguration",
"configurationField": "configuration", "description": "The format (MIME type)
of the audio for recognize, for [...]
- "model": { "index": 3, "kind": "parameter", "displayName": "Model",
"group": "producer", "label": "producer", "required": false, "type": "string",
"javaType": "java.lang.String", "deprecated": false, "autowired": false,
"secret": false, "defaultValue": "en-US_BroadbandModel", "configurationClass":
"org.apache.camel.component.ibm.watson.stt.WatsonSpeechToTextConfiguration",
"configurationField": "configuration", "description": "The speech model that
recognize uses, for example en-US_M [...]
- "operation": { "index": 4, "kind": "parameter", "displayName":
"Operation", "group": "producer", "label": "producer", "required": false,
"type": "enum", "javaType":
"org.apache.camel.component.ibm.watson.stt.WatsonSpeechToTextOperations",
"enum": [ "recognize", "listModels", "getModel", "listCustomModels",
"getCustomModel" ], "deprecated": false, "autowired": false, "secret": false,
"configurationClass":
"org.apache.camel.component.ibm.watson.stt.WatsonSpeechToTextConfiguration",
"co [...]
+ "contentType": { "index": 1, "kind": "parameter", "displayName": "Content
Type", "group": "producer", "label": "producer", "required": false, "type":
"string", "javaType": "java.lang.String", "deprecated": false, "autowired":
false, "secret": false, "defaultValue": "audio\/wav", "configurationClass":
"org.apache.camel.component.ibm.watson.stt.WatsonSpeechToTextConfiguration",
"configurationField": "configuration", "description": "The format (MIME type)
of the audio for recognize, for [...]
+ "model": { "index": 2, "kind": "parameter", "displayName": "Model",
"group": "producer", "label": "producer", "required": false, "type": "string",
"javaType": "java.lang.String", "deprecated": false, "autowired": false,
"secret": false, "defaultValue": "en-US_BroadbandModel", "configurationClass":
"org.apache.camel.component.ibm.watson.stt.WatsonSpeechToTextConfiguration",
"configurationField": "configuration", "description": "The speech model that
recognize uses, for example en-US_M [...]
+ "operation": { "index": 3, "kind": "parameter", "displayName":
"Operation", "group": "producer", "label": "producer", "required": false,
"type": "enum", "javaType":
"org.apache.camel.component.ibm.watson.stt.WatsonSpeechToTextOperations",
"enum": [ "recognize", "listModels", "getModel", "listCustomModels",
"getCustomModel" ], "deprecated": false, "autowired": false, "secret": false,
"configurationClass":
"org.apache.camel.component.ibm.watson.stt.WatsonSpeechToTextConfiguration",
"co [...]
+ "serviceUrl": { "index": 4, "kind": "parameter", "displayName": "Service
Url", "group": "producer", "label": "producer", "required": false, "type":
"string", "javaType": "java.lang.String", "deprecated": false, "autowired":
false, "secret": false, "configurationClass":
"org.apache.camel.component.ibm.watson.stt.WatsonSpeechToTextConfiguration",
"configurationField": "configuration", "description": "The URL of the Speech to
Text service instance, for example https:\/\/api.eu-de.speech [...]
"speakerLabels": { "index": 5, "kind": "parameter", "displayName":
"Speaker Labels", "group": "producer", "label": "producer", "required": false,
"type": "boolean", "javaType": "boolean", "deprecated": false, "autowired":
false, "secret": false, "defaultValue": false, "configurationClass":
"org.apache.camel.component.ibm.watson.stt.WatsonSpeechToTextConfiguration",
"configurationField": "configuration", "description": "Whether recognize
returns labels that identify which speaker spok [...]
"timestamps": { "index": 6, "kind": "parameter", "displayName":
"Timestamps", "group": "producer", "label": "producer", "required": false,
"type": "boolean", "javaType": "boolean", "deprecated": false, "autowired":
false, "secret": false, "defaultValue": false, "configurationClass":
"org.apache.camel.component.ibm.watson.stt.WatsonSpeechToTextConfiguration",
"configurationField": "configuration", "description": "Whether recognize
returns the start and end time of each word, in second [...]
"wordConfidence": { "index": 7, "kind": "parameter", "displayName": "Word
Confidence", "group": "producer", "label": "producer", "required": false,
"type": "boolean", "javaType": "boolean", "deprecated": false, "autowired":
false, "secret": false, "defaultValue": false, "configurationClass":
"org.apache.camel.component.ibm.watson.stt.WatsonSpeechToTextConfiguration",
"configurationField": "configuration", "description": "Whether recognize
returns a confidence score from 0.0 to 1.0 fo [...]
diff --git
a/components/camel-ibm/camel-ibm-watson-speech-to-text/src/main/docs/ibm-watson-speech-to-text-component.adoc
b/components/camel-ibm/camel-ibm-watson-speech-to-text/src/main/docs/ibm-watson-speech-to-text-component.adoc
index 26849a91c80f..077ca0c91acc 100644
---
a/components/camel-ibm/camel-ibm-watson-speech-to-text/src/main/docs/ibm-watson-speech-to-text-component.adoc
+++
b/components/camel-ibm/camel-ibm-watson-speech-to-text/src/main/docs/ibm-watson-speech-to-text-component.adoc
@@ -57,6 +57,13 @@ The IBM Watson Speech to Text component provides the
following operations:
If you don't specify an operation explicitly, you must set it via the
`operation` parameter.
+=== Health check
+
+The producer registers a health check that lists the models of the service, so
it is down when Speech to Text cannot
+be reached or rejects the request. Like the other producer health checks of
Camel, it runs only when producer
+health checks are enabled, for example with
`camel.health.producersEnabled=true`, and the
+`healthCheckProducerEnabled` option of the component turns it off.
+
=== Audio input
The `recognize` operation reads the audio from the file of the
`CamelIBMWatsonSTTAudioFile` header, or from the
@@ -418,7 +425,7 @@ Get detailed information about a custom model:
[source,java]
----
from("direct:getCustomModel")
- .setHeader("CamelIBMWatsonSTTModelName", constant("your-custom-model-guid"))
+ .setHeader("CamelIBMWatsonSTTCustomizationId",
constant("your-custom-model-guid"))
.to("ibm-watson-speech-to-text:mySTT?apiKey=RAW(yourApiKey)&operation=getCustomModel")
.process(exchange -> {
LanguageModel model = exchange.getMessage().getBody(LanguageModel.class);
diff --git
a/components/camel-ibm/camel-ibm-watson-speech-to-text/src/main/java/org/apache/camel/component/ibm/watson/stt/WatsonSpeechToTextConfiguration.java
b/components/camel-ibm/camel-ibm-watson-speech-to-text/src/main/java/org/apache/camel/component/ibm/watson/stt/WatsonSpeechToTextConfiguration.java
index e1885c87a170..74071e6fb8dd 100644
---
a/components/camel-ibm/camel-ibm-watson-speech-to-text/src/main/java/org/apache/camel/component/ibm/watson/stt/WatsonSpeechToTextConfiguration.java
+++
b/components/camel-ibm/camel-ibm-watson-speech-to-text/src/main/java/org/apache/camel/component/ibm/watson/stt/WatsonSpeechToTextConfiguration.java
@@ -30,7 +30,7 @@ public class WatsonSpeechToTextConfiguration implements
Cloneable {
@Metadata(required = true)
private String apiKey;
- @UriParam(label = "common",
+ @UriParam(label = "producer",
description = "The URL of the Speech to Text service instance,
for example"
+ "
https://api.eu-de.speech-to-text.watson.cloud.ibm.com. If not set, the IBM
Watson SDK uses"
+ "
https://api.us-south.speech-to-text.watson.cloud.ibm.com, unless its external
configuration,"
diff --git
a/components/camel-ibm/camel-ibm-watson-speech-to-text/src/main/java/org/apache/camel/component/ibm/watson/stt/WatsonSpeechToTextConstants.java
b/components/camel-ibm/camel-ibm-watson-speech-to-text/src/main/java/org/apache/camel/component/ibm/watson/stt/WatsonSpeechToTextConstants.java
index cdba46b8174a..2029937f23cc 100644
---
a/components/camel-ibm/camel-ibm-watson-speech-to-text/src/main/java/org/apache/camel/component/ibm/watson/stt/WatsonSpeechToTextConstants.java
+++
b/components/camel-ibm/camel-ibm-watson-speech-to-text/src/main/java/org/apache/camel/component/ibm/watson/stt/WatsonSpeechToTextConstants.java
@@ -23,47 +23,63 @@ import org.apache.camel.spi.Metadata;
*/
public interface WatsonSpeechToTextConstants {
- @Metadata(description = "The operation that the producer performs. It
replaces the operation option.", javaType = "String")
+ @Metadata(label = "producer", description = "The operation that the
producer performs. It replaces the operation option.",
+ javaType = "String")
String OPERATION = "CamelIBMWatsonSTTOperation";
// Recognition headers
- @Metadata(description = "The audio file that recognize transcribes. If
set, the producer sends this file instead of the"
+ @Metadata(label = "producer",
+ description = "The audio file that recognize transcribes. If
set, the producer sends this file instead of the"
+ " message body.",
javaType = "java.io.File")
String AUDIO_FILE = "CamelIBMWatsonSTTAudioFile";
- @Metadata(description = "The speech model that recognize uses. It replaces
the model option. The producer sets it on"
+ @Metadata(label = "producer",
+ description = "The speech model that recognize uses. It replaces
the model option. The producer sets it on"
+ " the result to the model it used.",
javaType = "String")
String MODEL = "CamelIBMWatsonSTTModel";
- @Metadata(description = "The format (MIME type) of the audio for
recognize. It replaces the contentType option. The"
+ @Metadata(label = "producer",
+ description = "The format (MIME type) of the audio for
recognize. It replaces the contentType option. The"
+ " producer sets it on the result to the format
it sent.",
javaType = "String")
String CONTENT_TYPE = "CamelIBMWatsonSTTContentType";
- @Metadata(description = "Whether recognize returns the start and end time
of each word. It replaces the timestamps"
+ @Metadata(label = "producer",
+ description = "Whether recognize returns the start and end time
of each word. It replaces the timestamps"
+ " option.",
javaType = "Boolean")
String TIMESTAMPS = "CamelIBMWatsonSTTTimestamps";
- @Metadata(description = "Whether recognize returns a confidence score for
each word. It replaces the wordConfidence"
+ @Metadata(label = "producer",
+ description = "Whether recognize returns a confidence score for
each word. It replaces the wordConfidence"
+ " option.",
javaType = "Boolean")
String WORD_CONFIDENCE = "CamelIBMWatsonSTTWordConfidence";
- @Metadata(description = "Whether recognize returns labels that identify
the speaker of each word. It replaces the"
+ @Metadata(label = "producer",
+ description = "Whether recognize returns labels that identify
the speaker of each word. It replaces the"
+ " speakerLabels option.",
javaType = "Boolean")
String SPEAKER_LABELS = "CamelIBMWatsonSTTSpeakerLabels";
// Model headers
- @Metadata(description = "The name of the speech model for getModel, or the
customization ID of the custom language"
- + " model for getCustomModel. If not set, the
producer reads it from the message body.",
+ @Metadata(label = "producer",
+ description = "The name of the speech model for getModel.
getCustomModel reads it as the customization ID"
+ + " of the custom language model when the
CamelIBMWatsonSTTCustomizationId header is not set."
+ + " If not set, the producer reads it from the
message body.",
javaType = "String")
String MODEL_NAME = "CamelIBMWatsonSTTModelName";
- @Metadata(description = "The language for listCustomModels, for example
en-US, to list only the custom language models"
+ @Metadata(label = "producer",
+ description = "The customization ID (a GUID) of the custom
language model for getCustomModel. It comes"
+ + " before the CamelIBMWatsonSTTModelName header
and the message body.",
+ javaType = "String")
+ String CUSTOMIZATION_ID = "CamelIBMWatsonSTTCustomizationId";
+ @Metadata(label = "producer",
+ description = "The language for listCustomModels, for example
en-US, to list only the custom language models"
+ " of that language. If not set, all custom
language models of the service instance are listed.",
javaType = "String")
String LANGUAGE = "CamelIBMWatsonSTTLanguage";
// Output headers
- @Metadata(description = "The transcript that recognize sets: the text of
the first alternative of each result, joined"
+ @Metadata(label = "producer",
+ description = "The transcript that recognize sets: the text of
the first alternative of each result, joined"
+ " in order.",
javaType = "String")
String TRANSCRIPT = "CamelIBMWatsonSTTTranscript";
diff --git
a/components/camel-ibm/camel-ibm-watson-speech-to-text/src/main/java/org/apache/camel/component/ibm/watson/stt/WatsonSpeechToTextEndpoint.java
b/components/camel-ibm/camel-ibm-watson-speech-to-text/src/main/java/org/apache/camel/component/ibm/watson/stt/WatsonSpeechToTextEndpoint.java
index 01c6f8f4cfde..6a5530cb0507 100644
---
a/components/camel-ibm/camel-ibm-watson-speech-to-text/src/main/java/org/apache/camel/component/ibm/watson/stt/WatsonSpeechToTextEndpoint.java
+++
b/components/camel-ibm/camel-ibm-watson-speech-to-text/src/main/java/org/apache/camel/component/ibm/watson/stt/WatsonSpeechToTextEndpoint.java
@@ -49,9 +49,11 @@ import org.apache.camel.support.DefaultEndpoint;
carriers =
Carrier.TEXT) },
description = "The audio to recognize in the
format of contentType (audio/wav by default), as"
+ " bytes, a stream or a file,
unless the CamelIBMWatsonSTTAudioFile header gives a"
- + " file. No body or a Map
fails, and text is sent as its bytes. getModel and"
- + " getCustomModel read the
model name or ID as text unless the"
- + " CamelIBMWatsonSTTModelName
header gives it"),
+ + " file. No body or a Map
fails, and text is sent as its bytes. getModel reads the"
+ + " model name as text unless
the CamelIBMWatsonSTTModelName header gives it, and"
+ + " getCustomModel the
customization ID unless the"
+ + "
CamelIBMWatsonSTTCustomizationId or CamelIBMWatsonSTTModelName header"
+ + " gives it"),
producerOut = @BodyType(value = Carrier.POJO,
javaType =
"com.ibm.watson.speech_to_text.v1.model.SpeechRecognitionResults",
byOption = {
@@ -121,6 +123,11 @@ public class WatsonSpeechToTextEndpoint extends
DefaultEndpoint implements Endpo
this.label = label;
}
+ @Override
+ public WatsonSpeechToTextComponent getComponent() {
+ return (WatsonSpeechToTextComponent) super.getComponent();
+ }
+
public WatsonSpeechToTextConfiguration getConfiguration() {
return configuration;
}
diff --git
a/components/camel-ibm/camel-ibm-watson-speech-to-text/src/main/java/org/apache/camel/component/ibm/watson/stt/WatsonSpeechToTextProducer.java
b/components/camel-ibm/camel-ibm-watson-speech-to-text/src/main/java/org/apache/camel/component/ibm/watson/stt/WatsonSpeechToTextProducer.java
index d2293c82fb00..b9058adcd142 100644
---
a/components/camel-ibm/camel-ibm-watson-speech-to-text/src/main/java/org/apache/camel/component/ibm/watson/stt/WatsonSpeechToTextProducer.java
+++
b/components/camel-ibm/camel-ibm-watson-speech-to-text/src/main/java/org/apache/camel/component/ibm/watson/stt/WatsonSpeechToTextProducer.java
@@ -34,6 +34,9 @@ import
com.ibm.watson.speech_to_text.v1.model.SpeechRecognitionResult;
import com.ibm.watson.speech_to_text.v1.model.SpeechRecognitionResults;
import org.apache.camel.Exchange;
import org.apache.camel.Message;
+import org.apache.camel.health.HealthCheck;
+import org.apache.camel.health.HealthCheckHelper;
+import org.apache.camel.health.WritableHealthCheckRepository;
import org.apache.camel.support.DefaultProducer;
import org.apache.camel.util.IOHelper;
import org.slf4j.Logger;
@@ -43,6 +46,9 @@ public class WatsonSpeechToTextProducer extends
DefaultProducer {
private static final Logger LOG =
LoggerFactory.getLogger(WatsonSpeechToTextProducer.class);
+ private HealthCheck producerHealthCheck;
+ private WritableHealthCheckRepository healthCheckRepository;
+
public WatsonSpeechToTextProducer(WatsonSpeechToTextEndpoint endpoint) {
super(endpoint);
}
@@ -72,6 +78,28 @@ public class WatsonSpeechToTextProducer extends
DefaultProducer {
}
}
+ @Override
+ protected void doStart() throws Exception {
+ super.doStart();
+ // health-check is optional so discover and resolve
+ healthCheckRepository = HealthCheckHelper.getHealthCheckRepository(
+ getEndpoint().getCamelContext(), "producers",
WritableHealthCheckRepository.class);
+ if (healthCheckRepository != null) {
+ producerHealthCheck = new
WatsonSpeechToTextProducerHealthCheck(getEndpoint(), getEndpoint().getId());
+
producerHealthCheck.setEnabled(getEndpoint().getComponent().isHealthCheckProducerEnabled());
+ healthCheckRepository.addHealthCheck(producerHealthCheck);
+ }
+ }
+
+ @Override
+ protected void doStop() throws Exception {
+ if (healthCheckRepository != null && producerHealthCheck != null) {
+ healthCheckRepository.removeHealthCheck(producerHealthCheck);
+ producerHealthCheck = null;
+ }
+ super.doStop();
+ }
+
@Override
public WatsonSpeechToTextEndpoint getEndpoint() {
return (WatsonSpeechToTextEndpoint) super.getEndpoint();
@@ -238,7 +266,11 @@ public class WatsonSpeechToTextProducer extends
DefaultProducer {
throw new IllegalStateException("STT client not initialized");
}
- String modelId =
exchange.getIn().getHeader(WatsonSpeechToTextConstants.MODEL_NAME,
String.class);
+ String modelId =
exchange.getIn().getHeader(WatsonSpeechToTextConstants.CUSTOMIZATION_ID,
String.class);
+ if (modelId == null) {
+ // the header that getModel uses, which was the only one before
the customization ID header
+ modelId =
exchange.getIn().getHeader(WatsonSpeechToTextConstants.MODEL_NAME,
String.class);
+ }
if (modelId == null) {
modelId = exchange.getIn().getBody(String.class);
}
diff --git
a/components/camel-ibm/camel-ibm-watson-speech-to-text/src/main/java/org/apache/camel/component/ibm/watson/stt/WatsonSpeechToTextProducerHealthCheck.java
b/components/camel-ibm/camel-ibm-watson-speech-to-text/src/main/java/org/apache/camel/component/ibm/watson/stt/WatsonSpeechToTextProducerHealthCheck.java
new file mode 100644
index 000000000000..b49b821ea90d
--- /dev/null
+++
b/components/camel-ibm/camel-ibm-watson-speech-to-text/src/main/java/org/apache/camel/component/ibm/watson/stt/WatsonSpeechToTextProducerHealthCheck.java
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.ibm.watson.stt;
+
+import java.util.Map;
+
+import com.ibm.cloud.sdk.core.service.exception.ServiceResponseException;
+import com.ibm.watson.speech_to_text.v1.SpeechToText;
+import org.apache.camel.health.HealthCheckResultBuilder;
+import org.apache.camel.impl.health.AbstractHealthCheck;
+
+/**
+ * Checks that the Speech to Text service answers, by listing its models.
+ */
+public class WatsonSpeechToTextProducerHealthCheck extends AbstractHealthCheck
{
+
+ private final WatsonSpeechToTextEndpoint endpoint;
+
+ public WatsonSpeechToTextProducerHealthCheck(WatsonSpeechToTextEndpoint
endpoint, String clientId) {
+ super("camel", "producer:ibm-watson-speech-to-text-" + clientId);
+ this.endpoint = endpoint;
+ }
+
+ @Override
+ protected void doCall(HealthCheckResultBuilder builder, Map<String,
Object> options) {
+ SpeechToText stt = endpoint.getSttClient();
+ if (stt == null) {
+ builder.message("The Speech to Text client is not created");
+ builder.down();
+ return;
+ }
+ try {
+ stt.listModels().execute();
+ } catch (ServiceResponseException e) {
+ builder.message(e.getMessage());
+ builder.error(e);
+ builder.detail(SERVICE_STATUS_CODE, e.getStatusCode());
+ builder.down();
+ return;
+ } catch (Exception e) {
+ builder.error(e);
+ builder.down();
+ return;
+ }
+ builder.up();
+ }
+}
diff --git
a/components/camel-ibm/camel-ibm-watson-speech-to-text/src/test/java/org/apache/camel/component/ibm/watson/stt/WatsonSpeechToTextCustomModelHealthCheckTest.java
b/components/camel-ibm/camel-ibm-watson-speech-to-text/src/test/java/org/apache/camel/component/ibm/watson/stt/WatsonSpeechToTextCustomModelHealthCheckTest.java
new file mode 100644
index 000000000000..6eae39e210e6
--- /dev/null
+++
b/components/camel-ibm/camel-ibm-watson-speech-to-text/src/test/java/org/apache/camel/component/ibm/watson/stt/WatsonSpeechToTextCustomModelHealthCheckTest.java
@@ -0,0 +1,208 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.ibm.watson.stt;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.net.InetSocketAddress;
+import java.nio.charset.StandardCharsets;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.concurrent.TimeUnit;
+
+import com.ibm.cloud.sdk.core.security.NoAuthAuthenticator;
+import com.ibm.watson.speech_to_text.v1.SpeechToText;
+import com.ibm.watson.speech_to_text.v1.model.LanguageModel;
+import com.sun.net.httpserver.HttpExchange;
+import com.sun.net.httpserver.HttpServer;
+import org.apache.camel.CamelContext;
+import org.apache.camel.Exchange;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.health.HealthCheck;
+import org.apache.camel.health.HealthCheckHelper;
+import org.apache.camel.health.HealthCheckRegistry;
+import org.apache.camel.health.HealthCheckRepository;
+import org.apache.camel.impl.health.AbstractHealthCheck;
+import org.apache.camel.impl.health.DefaultHealthCheckRegistry;
+import org.apache.camel.test.junit6.CamelTestSupport;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import static org.awaitility.Awaitility.await;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
+/**
+ * The getCustomModel operation takes the customization ID from its own
header, and the producer has a health check that
+ * lists the models of the service. The service is played by a JDK HttpServer.
+ */
+class WatsonSpeechToTextCustomModelHealthCheckTest extends CamelTestSupport {
+
+ // the literal name, so that the test also runs against a version without
the constant
+ private static final String CUSTOMIZATION_ID_HEADER =
"CamelIBMWatsonSTTCustomizationId";
+
+ private static final List<String> REQUESTS = new CopyOnWriteArrayList<>();
+ private static volatile int modelsStatus = 200;
+ private static HttpServer server;
+
+ @BeforeAll
+ static void startServer() throws IOException {
+ server = HttpServer.create(new InetSocketAddress("localhost", 0), 0);
+ server.createContext("/",
WatsonSpeechToTextCustomModelHealthCheckTest::handle);
+ server.start();
+ }
+
+ @AfterAll
+ static void stopServer() {
+ if (server != null) {
+ server.stop(0);
+ }
+ }
+
+ private static void handle(HttpExchange exchange) throws IOException {
+ String path = exchange.getRequestURI().getPath();
+ REQUESTS.add(path);
+ int status;
+ String response;
+ if (path.equals("/v1/models")) {
+ status = modelsStatus;
+ response = status == 200 ? "{\"models\":[]}" : "{\"code\":" +
status + ",\"error\":\"service unavailable\"}";
+ } else if (path.startsWith("/v1/customizations/")) {
+ status = 200;
+ String id = path.substring("/v1/customizations/".length());
+ response = "{\"customization_id\":\"" + id + "\",\"name\":\"custom
model\"}";
+ } else {
+ status = 404;
+ response = "{\"code\":404,\"error\":\"not found\"}";
+ }
+ byte[] bytes = response.getBytes(StandardCharsets.UTF_8);
+ exchange.getResponseHeaders().add("Content-Type", "application/json");
+ exchange.sendResponseHeaders(status, bytes.length);
+ try (OutputStream out = exchange.getResponseBody()) {
+ out.write(bytes);
+ }
+ }
+
+ @BeforeEach
+ void reset() {
+ REQUESTS.clear();
+ modelsStatus = 200;
+ }
+
+ @Override
+ protected CamelContext createCamelContext() throws Exception {
+ CamelContext context = super.createCamelContext();
+ HealthCheckRegistry registry = new DefaultHealthCheckRegistry();
+ registry.setCamelContext(context);
+ HealthCheckRepository producers = (HealthCheckRepository)
registry.resolveById("producers");
+ producers.setEnabled(true);
+ registry.register(producers);
+
context.getCamelContextExtension().addContextPlugin(HealthCheckRegistry.class,
registry);
+ return context;
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() {
+ WatsonSpeechToTextConfiguration configuration = new
WatsonSpeechToTextConfiguration();
+ configuration.setApiKey("test-key");
+
configuration.setOperation(WatsonSpeechToTextOperations.getCustomModel);
+ WatsonSpeechToTextComponent component
+ =
getContext().getComponent("ibm-watson-speech-to-text",
WatsonSpeechToTextComponent.class);
+ from("direct:getCustomModel")
+ .to(new
TestServerEndpoint("ibm-watson-speech-to-text:test", component, configuration));
+ }
+ };
+ }
+
+ @Test
+ void theCustomizationIdHeaderSelectsTheCustomModel() {
+ Exchange result = getCustomModel(Map.of(CUSTOMIZATION_ID_HEADER,
"guid-1"));
+
+ assertFalse(result.isFailed(), () -> "failed: " +
result.getException());
+ assertEquals("guid-1", assertInstanceOf(LanguageModel.class,
result.getMessage().getBody()).getCustomizationId());
+ assertEquals(List.of("/v1/customizations/guid-1"), REQUESTS);
+ }
+
+ @Test
+ void theCustomizationIdHeaderComesBeforeTheModelNameHeader() {
+ Exchange result = getCustomModel(Map.of(CUSTOMIZATION_ID_HEADER,
"guid-1",
+ WatsonSpeechToTextConstants.MODEL_NAME, "guid-2"));
+
+ assertFalse(result.isFailed(), () -> "failed: " +
result.getException());
+ assertEquals(List.of("/v1/customizations/guid-1"), REQUESTS);
+ }
+
+ @Test
+ void theModelNameHeaderIsStillTheCustomizationIdWithoutTheNewHeader() {
+ Exchange result =
getCustomModel(Map.of(WatsonSpeechToTextConstants.MODEL_NAME, "guid-2"));
+
+ assertFalse(result.isFailed(), () -> "failed: " +
result.getException());
+ assertEquals(List.of("/v1/customizations/guid-2"), REQUESTS);
+ }
+
+ @Test
+ void theProducerHealthCheckListsTheModels() {
+ await().atMost(20, TimeUnit.SECONDS).untilAsserted(() -> {
+ HealthCheck.Result result = producerCheck();
+ assertEquals(HealthCheck.State.UP, result.getState());
+ });
+ assertEquals("/v1/models", REQUESTS.get(REQUESTS.size() - 1));
+
+ modelsStatus = 503;
+ await().atMost(20, TimeUnit.SECONDS).untilAsserted(() -> {
+ HealthCheck.Result result = producerCheck();
+ assertEquals(HealthCheck.State.DOWN, result.getState());
+ assertEquals(503,
result.getDetails().get(AbstractHealthCheck.SERVICE_STATUS_CODE));
+ });
+ }
+
+ private HealthCheck.Result producerCheck() {
+ HealthCheck.Result result =
HealthCheckHelper.invokeReadiness(context).stream()
+ .filter(r ->
r.getCheck().getId().startsWith("producer:ibm-watson-speech-to-text"))
+ .findFirst().orElse(null);
+ assertNotNull(result, "no producer health check of
ibm-watson-speech-to-text");
+ return result;
+ }
+
+ private Exchange getCustomModel(Map<String, Object> headers) {
+ return template.request("direct:getCustomModel", e ->
e.getIn().getHeaders().putAll(headers));
+ }
+
+ private static final class TestServerEndpoint extends
WatsonSpeechToTextEndpoint {
+
+ private final SpeechToText client;
+
+ TestServerEndpoint(String uri, WatsonSpeechToTextComponent component,
WatsonSpeechToTextConfiguration configuration) {
+ super(uri, component, configuration);
+ client = new SpeechToText(new NoAuthAuthenticator());
+ client.setServiceUrl("http://localhost:" +
server.getAddress().getPort());
+ }
+
+ @Override
+ public SpeechToText getSttClient() {
+ return client;
+ }
+ }
+}
diff --git
a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc
b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc
index 0cb9a2fa143a..3b7eb5e2f38e 100644
--- a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc
+++ b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc
@@ -921,6 +921,16 @@ expires; the endpoint fails to start when the profile
gives no token. The identi
that watsonx.data accepts. `apiKey` is no longer marked as required in the
catalog, as `oauthProfile` can take its
place; an endpoint with neither still fails to start.
+=== camel-ibm-watson-speech-to-text - a producer health check, and a header
for the customization ID
+
+The producer now registers a health check that lists the models of Speech to
Text. It runs only when producer health
+checks are enabled (`camel.health.producersEnabled=true`), and then reports
DOWN while the service cannot be reached
+or rejects the request. Set the `healthCheckProducerEnabled` option of the
component to `false` to turn it off.
+
+`getCustomModel` reads the customization ID of the custom language model from
the new
+`CamelIBMWatsonSTTCustomizationId` header, and from
`CamelIBMWatsonSTTModelName` when the new header is not set, as
+before. The `serviceUrl` option and the headers are in the `producer` group of
the catalog and the docs.
+
=== camel-ibm-watsonx-ai - the OAuth token of oauthProfile is sent as a Bearer
token
With `oauthProfile`, the endpoint used to obtain an access token once at
startup and use it as `apiKey`, so the token
diff --git
a/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/IbmWatsonSpeechToTextComponentBuilderFactory.java
b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/IbmWatsonSpeechToTextComponentBuilderFactory.java
index 05c0871c7302..d785611a8a09 100644
---
a/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/IbmWatsonSpeechToTextComponentBuilderFactory.java
+++
b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/IbmWatsonSpeechToTextComponentBuilderFactory.java
@@ -69,26 +69,6 @@ public interface
IbmWatsonSpeechToTextComponentBuilderFactory {
return this;
}
- /**
- * The URL of the Speech to Text service instance, for example
- * https://api.eu-de.speech-to-text.watson.cloud.ibm.com. If not set,
- * the IBM Watson SDK uses
- * https://api.us-south.speech-to-text.watson.cloud.ibm.com, unless its
- * external configuration, such as the SPEECH_TO_TEXT_URL environment
- * variable, gives a URL.
- *
- * The option is a: <code>java.lang.String</code> type.
- *
- * Group: common
- *
- * @param serviceUrl the value to set
- * @return the dsl builder
- */
- default IbmWatsonSpeechToTextComponentBuilder
serviceUrl(java.lang.String serviceUrl) {
- doSetProperty("serviceUrl", serviceUrl);
- return this;
- }
-
/**
* The format (MIME type) of the audio for recognize, for example
@@ -177,6 +157,26 @@ public interface
IbmWatsonSpeechToTextComponentBuilderFactory {
return this;
}
+ /**
+ * The URL of the Speech to Text service instance, for example
+ * https://api.eu-de.speech-to-text.watson.cloud.ibm.com. If not set,
+ * the IBM Watson SDK uses
+ * https://api.us-south.speech-to-text.watson.cloud.ibm.com, unless its
+ * external configuration, such as the SPEECH_TO_TEXT_URL environment
+ * variable, gives a URL.
+ *
+ * The option is a: <code>java.lang.String</code> type.
+ *
+ * Group: producer
+ *
+ * @param serviceUrl the value to set
+ * @return the dsl builder
+ */
+ default IbmWatsonSpeechToTextComponentBuilder
serviceUrl(java.lang.String serviceUrl) {
+ doSetProperty("serviceUrl", serviceUrl);
+ return this;
+ }
+
/**
* Whether recognize returns labels that identify which speaker spoke
@@ -332,11 +332,11 @@ public interface
IbmWatsonSpeechToTextComponentBuilderFactory {
Object value) {
switch (name) {
case "configuration": ((WatsonSpeechToTextComponent)
component).setConfiguration((org.apache.camel.component.ibm.watson.stt.WatsonSpeechToTextConfiguration)
value); return true;
- case "serviceUrl":
getOrCreateConfiguration((WatsonSpeechToTextComponent)
component).setServiceUrl((java.lang.String) value); return true;
case "contentType":
getOrCreateConfiguration((WatsonSpeechToTextComponent)
component).setContentType((java.lang.String) value); return true;
case "lazyStartProducer": ((WatsonSpeechToTextComponent)
component).setLazyStartProducer((boolean) value); return true;
case "model":
getOrCreateConfiguration((WatsonSpeechToTextComponent)
component).setModel((java.lang.String) value); return true;
case "operation":
getOrCreateConfiguration((WatsonSpeechToTextComponent)
component).setOperation((org.apache.camel.component.ibm.watson.stt.WatsonSpeechToTextOperations)
value); return true;
+ case "serviceUrl":
getOrCreateConfiguration((WatsonSpeechToTextComponent)
component).setServiceUrl((java.lang.String) value); return true;
case "speakerLabels":
getOrCreateConfiguration((WatsonSpeechToTextComponent)
component).setSpeakerLabels((boolean) value); return true;
case "timestamps":
getOrCreateConfiguration((WatsonSpeechToTextComponent)
component).setTimestamps((boolean) value); return true;
case "wordConfidence":
getOrCreateConfiguration((WatsonSpeechToTextComponent)
component).setWordConfidence((boolean) value); return true;
diff --git
a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/WatsonSpeechToTextEndpointBuilderFactory.java
b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/WatsonSpeechToTextEndpointBuilderFactory.java
index 98366712d8a2..c5914ff08a0a 100644
---
a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/WatsonSpeechToTextEndpointBuilderFactory.java
+++
b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/WatsonSpeechToTextEndpointBuilderFactory.java
@@ -45,25 +45,6 @@ public interface WatsonSpeechToTextEndpointBuilderFactory {
return (AdvancedWatsonSpeechToTextEndpointBuilder) this;
}
- /**
- * The URL of the Speech to Text service instance, for example
- * https://api.eu-de.speech-to-text.watson.cloud.ibm.com. If not set,
- * the IBM Watson SDK uses
- * https://api.us-south.speech-to-text.watson.cloud.ibm.com, unless its
- * external configuration, such as the SPEECH_TO_TEXT_URL environment
- * variable, gives a URL.
- *
- * The option is a: <code>java.lang.String</code> type.
- *
- * Group: common
- *
- * @param serviceUrl the value to set
- * @return the dsl builder
- */
- default WatsonSpeechToTextEndpointBuilder serviceUrl(String
serviceUrl) {
- doSetProperty("serviceUrl", serviceUrl);
- return this;
- }
/**
* The format (MIME type) of the audio for recognize, for example
* audio/wav, audio/flac, audio/mp3, audio/ogg or audio/webm.
audio/l16,
@@ -141,6 +122,25 @@ public interface WatsonSpeechToTextEndpointBuilderFactory {
doSetProperty("operation", operation);
return this;
}
+ /**
+ * The URL of the Speech to Text service instance, for example
+ * https://api.eu-de.speech-to-text.watson.cloud.ibm.com. If not set,
+ * the IBM Watson SDK uses
+ * https://api.us-south.speech-to-text.watson.cloud.ibm.com, unless its
+ * external configuration, such as the SPEECH_TO_TEXT_URL environment
+ * variable, gives a URL.
+ *
+ * The option is a: <code>java.lang.String</code> type.
+ *
+ * Group: producer
+ *
+ * @param serviceUrl the value to set
+ * @return the dsl builder
+ */
+ default WatsonSpeechToTextEndpointBuilder serviceUrl(String
serviceUrl) {
+ doSetProperty("serviceUrl", serviceUrl);
+ return this;
+ }
/**
* Whether recognize returns labels that identify which speaker spoke
* which words. The service then also returns the timestamps of the
@@ -484,8 +484,9 @@ public interface WatsonSpeechToTextEndpointBuilderFactory {
return "CamelIBMWatsonSTTSpeakerLabels";
}
/**
- * The name of the speech model for getModel, or the customization ID
of
- * the custom language model for getCustomModel. If not set, the
+ * The name of the speech model for getModel. getCustomModel reads it
as
+ * the customization ID of the custom language model when the
+ * CamelIBMWatsonSTTCustomizationId header is not set. If not set, the
* producer reads it from the message body.
*
* The option is a: {@code String} type.
@@ -497,6 +498,20 @@ public interface WatsonSpeechToTextEndpointBuilderFactory {
public String iBMWatsonSTTModelName() {
return "CamelIBMWatsonSTTModelName";
}
+ /**
+ * The customization ID (a GUID) of the custom language model for
+ * getCustomModel. It comes before the CamelIBMWatsonSTTModelName
header
+ * and the message body.
+ *
+ * The option is a: {@code String} type.
+ *
+ * Group: producer
+ *
+ * @return the name of the header {@code IBMWatsonSTTCustomizationId}.
+ */
+ public String iBMWatsonSTTCustomizationId() {
+ return "CamelIBMWatsonSTTCustomizationId";
+ }
/**
* The language for listCustomModels, for example en-US, to list only
* the custom language models of that language. If not set, all custom