IBM Watson Speech to Text
Since Camel 4.17
Only producer is supported
The IBM Watson Speech to Text component allows you to convert speech audio into written text using IBM Watson Speech to Text service.
Prerequisites
You must have a valid IBM Cloud account and an instance of the Watson Speech to Text service. More information is available at IBM Watson Speech to Text.
URI Format
ibm-watson-speech-to-text:label[?options]
You can append query options to the URI in the following format:
?option=value&option2=value&…
Configuring Options
Camel components are configured on two separate levels:
-
component level
-
endpoint level
Configuring Component Options
At the component level, you set general and shared configurations that are, then, inherited by the endpoints. It is the highest configuration level.
For example, a component may have security settings, credentials for authentication, urls for network connection and so forth.
Some components only have a few options, and others may have many. Because components typically have pre-configured defaults that are commonly used, then you may often only need to configure a few options on a component; or none at all.
You can configure components using:
-
the Component DSL.
-
in a configuration file (
application.properties,*.yamlfiles, etc). -
directly in the Java code.
Configuring Endpoint Options
You usually spend more time setting up endpoints because they have many options. These options help you customize what you want the endpoint to do. The options are also categorized into whether the endpoint is used as a consumer (from), as a producer (to), or both.
Configuring endpoints is most often done directly in the endpoint URI as path and query parameters. You can also use the Endpoint DSL and DataFormat DSL as a type safe way of configuring endpoints and data formats in Java.
A good practice when configuring options is to use Property Placeholders.
Property placeholders provide a few benefits:
-
They help prevent using hardcoded urls, port numbers, sensitive information, and other settings.
-
They allow externalizing the configuration from the code.
-
They help the code to become more flexible and reusable.
The following two sections list all the options, firstly for the component followed by the endpoint.
Component Options
The IBM Watson Speech to Text component supports the following options which are listed below.
| Name | Description | Default | Type |
|---|---|---|---|
The shared configuration of the endpoints. Each endpoint starts from a copy of it, and its endpoint options override the values. | WatsonSpeechToTextConfiguration | ||
The format (MIME type) of the audio for recognize, for example audio/wav, audio/flac, audio/mp3, audio/ogg or audio/webm. audio/l16, audio/alaw and audio/mulaw also need the sampling rate, as in audio/l16;rate=16000, and application/octet-stream lets the service detect the format. The CamelIBMWatsonSTTContentType header replaces this option. | audio/wav | String | |
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 during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel’s routing error handlers. Beware that when the first message is processed then creating and starting the producer may take a little time and prolong the total processing time of the processing. | false | boolean | |
The speech model that recognize uses, for example en-US_Multimedia or en-GB_Telephony. The sampling rate of the audio must be at least 16 kHz for a broadband or multimedia model and 8 kHz for a narrowband or telephony model. The CamelIBMWatsonSTTModel header replaces this option. | en-US_BroadbandModel | String | |
The operation that the producer performs: recognize transcribes audio, listModels and getModel return the speech models, and listCustomModels and getCustomModel the custom language models. The CamelIBMWatsonSTTOperation header replaces this option, and the producer fails if neither is set. Enum values:
| WatsonSpeechToTextOperations | ||
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. | String | ||
Whether recognize returns labels that identify which speaker spoke which words. The service then also returns the timestamps of the words, whatever the timestamps option is. The CamelIBMWatsonSTTSpeakerLabels header replaces this option. | false | boolean | |
Whether recognize returns the start and end time of each word, in seconds. The CamelIBMWatsonSTTTimestamps header replaces this option. | false | boolean | |
Whether recognize returns a confidence score from 0.0 to 1.0 for each word. The CamelIBMWatsonSTTWordConfidence header replaces this option. | false | boolean | |
Whether autowiring is enabled. This is used for automatic autowiring options (the option must be marked as autowired) by looking up in the registry to find if there is a single instance of matching type, which then gets configured on the component. This can be used for automatic configuring JDBC data sources, JMS connection factories, AWS Clients, etc. | true | boolean | |
Used for enabling or disabling all consumer based health checks from this component. | true | boolean | |
Used for enabling or disabling all producer based health checks from this component. Notice: Camel has by default disabled all producer based health-checks. You can turn on producer checks globally by setting camel.health.producersEnabled=true. | true | boolean | |
Required The IBM Cloud API key of the Speech to Text service instance. The client gets IAM access tokens with it. The endpoint fails to start without it. | String |
Endpoint Options
The IBM Watson Speech to Text endpoint is configured using URI syntax:
ibm-watson-speech-to-text:label
With the following path and query parameters:
Query Parameters
| Name | Description | Default | Type |
|---|---|---|---|
The format (MIME type) of the audio for recognize, for example audio/wav, audio/flac, audio/mp3, audio/ogg or audio/webm. audio/l16, audio/alaw and audio/mulaw also need the sampling rate, as in audio/l16;rate=16000, and application/octet-stream lets the service detect the format. The CamelIBMWatsonSTTContentType header replaces this option. | audio/wav | String | |
The speech model that recognize uses, for example en-US_Multimedia or en-GB_Telephony. The sampling rate of the audio must be at least 16 kHz for a broadband or multimedia model and 8 kHz for a narrowband or telephony model. The CamelIBMWatsonSTTModel header replaces this option. | en-US_BroadbandModel | String | |
The operation that the producer performs: recognize transcribes audio, listModels and getModel return the speech models, and listCustomModels and getCustomModel the custom language models. The CamelIBMWatsonSTTOperation header replaces this option, and the producer fails if neither is set. Enum values:
| WatsonSpeechToTextOperations | ||
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. | String | ||
Whether recognize returns labels that identify which speaker spoke which words. The service then also returns the timestamps of the words, whatever the timestamps option is. The CamelIBMWatsonSTTSpeakerLabels header replaces this option. | false | boolean | |
Whether recognize returns the start and end time of each word, in seconds. The CamelIBMWatsonSTTTimestamps header replaces this option. | false | boolean | |
Whether recognize returns a confidence score from 0.0 to 1.0 for each word. The CamelIBMWatsonSTTWordConfidence header replaces this option. | false | boolean | |
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 during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel’s routing error handlers. Beware that when the first message is processed then creating and starting the producer may take a little time and prolong the total processing time of the processing. | false | boolean | |
Required The IBM Cloud API key of the Speech to Text service instance. The client gets IAM access tokens with it. The endpoint fails to start without it. | String |
Message Headers
The IBM Watson Speech to Text component supports the following message header(s), which is/are listed below:
| Name | Description | Default | Type |
|---|---|---|---|
CamelIBMWatsonSTTOperation (producer) Constant: | The operation that the producer performs. It replaces the operation option. | String | |
CamelIBMWatsonSTTAudioFile (producer) Constant: | The audio file that recognize transcribes. If set, the producer sends this file instead of the message body. | File | |
CamelIBMWatsonSTTModel (producer) Constant: | The speech model that recognize uses. It replaces the model option. The producer sets it on the result to the model it used. | String | |
CamelIBMWatsonSTTContentType (producer) Constant: | 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. | String | |
CamelIBMWatsonSTTTimestamps (producer) Constant: | Whether recognize returns the start and end time of each word. It replaces the timestamps option. | Boolean | |
CamelIBMWatsonSTTWordConfidence (producer) Constant: | Whether recognize returns a confidence score for each word. It replaces the wordConfidence option. | Boolean | |
CamelIBMWatsonSTTSpeakerLabels (producer) Constant: | Whether recognize returns labels that identify the speaker of each word. It replaces the speakerLabels option. | Boolean | |
CamelIBMWatsonSTTModelName (producer) Constant: | 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. | String | |
CamelIBMWatsonSTTCustomizationId (producer) Constant: | The customization ID (a GUID) of the custom language model for getCustomModel. It comes before the CamelIBMWatsonSTTModelName header and the message body. | String | |
CamelIBMWatsonSTTLanguage (producer) Constant: | 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. | String | |
CamelIBMWatsonSTTTranscript (producer) Constant: | The transcript that recognize sets: the text of the first alternative of each result, joined in order. | String |
Message Body
The message body at each side of the IBM Watson Speech to Text component: Consumer is the body of the messages the consumer creates, Consumer reply the bodies a consumer that answers its caller can reply with, Producer input the bodies the producer can send or write, and Producer output the body after the producer.
| Side | Body | Description |
|---|---|---|
Producer input |
| 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 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.
|
Producer output |
| recognize gives the SpeechRecognitionResults of the IBM Watson SDK, with the transcript as text in the CamelIBMWatsonSTTTranscript header. Converted to text, it is the JSON of the results. listModels gives a List of SpeechModel and listCustomModels a List of LanguageModel.
|
The bodies are the ones with the default options. A side that is not listed is not known, and tooling does not guess it. The carriers, the sides and the tools that use them are described in Message Body Types.
Required Watson Speech to Text component options
You must provide the apiKey to access IBM Watson Speech to Text. Optionally, you can specify a custom serviceUrl if you’re using a dedicated or private instance.
Usage
Watson Speech to Text Producer operations
The IBM Watson Speech to Text component provides the following operations:
-
recognize - Transcribe audio to text
-
listModels - Get available language models
-
getModel - Get information about a specific model
-
listCustomModels - List custom language models
-
getCustomModel - Get information about a custom language model
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 message body: an InputStream, bytes, a File, a Path or the file of a file consumer. The producer closes the streams it opens, for the header file and for a body it has to open, such as a file. An InputStream body belongs to the caller, and the producer does not close it.
Examples
Recognize Audio to Text
Transcribe a WAV audio file to text:
-
Java
-
XML
-
YAML
from("file:/var/audio?noop=true")
.to("ibm-watson-speech-to-text:mySTT?apiKey=RAW(yourApiKey)&operation=recognize&contentType=audio/wav")
.log("Transcription: ${header.CamelIBMWatsonSTTTranscript}"); <route>
<from uri="file:/var/audio?noop=true"/>
<to uri="ibm-watson-speech-to-text:mySTT?apiKey=RAW(yourApiKey)&operation=recognize&contentType=audio/wav"/>
<log message="Transcription: ${header.CamelIBMWatsonSTTTranscript}"/>
</route> - route:
from:
uri: file:/var/audio
parameters:
noop: true
steps:
- to:
uri: ibm-watson-speech-to-text:mySTT
parameters:
apiKey: "RAW(yourApiKey)"
operation: recognize
contentType: audio/wav
- log:
message: "Transcription: ${header.CamelIBMWatsonSTTTranscript}" This will transcribe the audio file and extract the text.
Recognize with Timestamps
Transcribe audio and get word-level timestamps:
from("direct:start")
.setHeader("CamelIBMWatsonSTTAudioFile", constant(new File("/path/to/audio.wav")))
.setHeader("CamelIBMWatsonSTTTimestamps", constant(true))
.to("ibm-watson-speech-to-text:mySTT?apiKey=RAW(yourApiKey)&operation=recognize")
.process(exchange -> {
SpeechRecognitionResults results = exchange.getMessage().getBody(SpeechRecognitionResults.class);
results.getResults().forEach(result -> {
result.getAlternatives().forEach(alt -> {
alt.getTimestamps().forEach(timestamp -> {
System.out.println("Word: " + timestamp.getWord() +
" - Start: " + timestamp.getStartTime() +
" - End: " + timestamp.getEndTime());
});
});
});
}); Recognize with Word Confidence
Get confidence scores for each transcribed word:
from("direct:start")
.setBody(constant(audioInputStream))
.setHeader("CamelIBMWatsonSTTWordConfidence", constant(true))
.setHeader("CamelIBMWatsonSTTContentType", constant("audio/mp3"))
.to("ibm-watson-speech-to-text:mySTT?apiKey=RAW(yourApiKey)&operation=recognize")
.process(exchange -> {
SpeechRecognitionResults results = exchange.getMessage().getBody(SpeechRecognitionResults.class);
results.getResults().forEach(result -> {
result.getAlternatives().forEach(alt -> {
alt.getWordConfidence().forEach(wc -> {
System.out.println("Word: " + wc.getWord() +
" - Confidence: " + wc.getConfidence());
});
});
});
}); Available Language Models
Some commonly used models include:
English Models: - en-US_BroadbandModel - US English for high-quality audio (16 kHz) - en-US_NarrowbandModel - US English for telephony audio (8 kHz) - en-GB_BroadbandModel - UK English broadband - en-GB_NarrowbandModel - UK English narrowband
Spanish Models: - es-ES_BroadbandModel - Castilian Spanish - es-ES_NarrowbandModel - Castilian Spanish narrowband - es-MX_BroadbandModel - Mexican Spanish - es-LA_BroadbandModel - Latin American Spanish
French Models: - fr-FR_BroadbandModel - French broadband - fr-FR_NarrowbandModel - French narrowband - fr-CA_BroadbandModel - Canadian French
German Models: - de-DE_BroadbandModel - German broadband - de-DE_NarrowbandModel - German narrowband
Other Languages: - ja-JP_BroadbandModel - Japanese - ko-KR_BroadbandModel - Korean - pt-BR_BroadbandModel - Brazilian Portuguese - zh-CN_BroadbandModel - Mandarin Chinese - it-IT_BroadbandModel - Italian - ar-MS_BroadbandModel - Modern Standard Arabic
List Available Models
Get a list of all available language models:
from("direct:listModels")
.to("ibm-watson-speech-to-text:mySTT?apiKey=RAW(yourApiKey)&operation=listModels")
.process(exchange -> {
List<SpeechModel> models = exchange.getMessage().getBody(List.class);
models.forEach(model -> {
System.out.println("Model: " + model.getName() +
" - Language: " + model.getLanguage() +
" - Description: " + model.getDescription());
});
}); Get Model Information
Get detailed information about a specific model:
from("direct:getModel")
.setHeader("CamelIBMWatsonSTTModelName", constant("en-US_BroadbandModel"))
.to("ibm-watson-speech-to-text:mySTT?apiKey=RAW(yourApiKey)&operation=getModel")
.process(exchange -> {
SpeechModel model = exchange.getMessage().getBody(SpeechModel.class);
System.out.println("Model details: " + model);
}); Audio Format Options
The component supports various audio formats via the contentType parameter:
-
audio/wav - WAV format (default), PCM 16-bit
-
audio/mp3 - MP3 format
-
audio/flac - FLAC format, lossless compression
-
audio/ogg - Ogg Vorbis format with Opus codec
-
audio/webm - WebM format
Example with MP3 input:
-
Java
-
XML
-
YAML
from("file:/var/audio?include=.*\\.mp3")
.to("ibm-watson-speech-to-text:mySTT?apiKey=RAW(yourApiKey)&operation=recognize&contentType=audio/mp3")
.log("Transcript: ${header.CamelIBMWatsonSTTTranscript}"); <route>
<from uri="file:/var/audio?include=.*\.mp3"/>
<to uri="ibm-watson-speech-to-text:mySTT?apiKey=RAW(yourApiKey)&operation=recognize&contentType=audio/mp3"/>
<log message="Transcript: ${header.CamelIBMWatsonSTTTranscript}"/>
</route> - route:
from:
uri: file:/var/audio
parameters:
include: ".*\\.mp3"
steps:
- to:
uri: ibm-watson-speech-to-text:mySTT
parameters:
apiKey: "RAW(yourApiKey)"
operation: recognize
contentType: audio/mp3
- log:
message: "Transcript: ${header.CamelIBMWatsonSTTTranscript}" Recognize Different Languages
Transcribe audio in different languages by specifying the appropriate model:
// Transcribe Spanish audio
from("direct:spanish")
.setBody(constant(spanishAudioFile))
.setHeader("CamelIBMWatsonSTTModel", constant("es-ES_BroadbandModel"))
.to("ibm-watson-speech-to-text:mySTT?apiKey=RAW(yourApiKey)&operation=recognize")
.log("Spanish transcript: ${header.CamelIBMWatsonSTTTranscript}");
// Transcribe French audio
from("direct:french")
.setBody(constant(frenchAudioFile))
.to("ibm-watson-speech-to-text:mySTT?apiKey=RAW(yourApiKey)&operation=recognize&model=fr-FR_BroadbandModel")
.log("French transcript: ${header.CamelIBMWatsonSTTTranscript}"); Speaker Identification
Identify different speakers in multi-speaker audio:
from("direct:speakers")
.setHeader("CamelIBMWatsonSTTSpeakerLabels", constant(true))
.setHeader("CamelIBMWatsonSTTTimestamps", constant(true))
.to("ibm-watson-speech-to-text:mySTT?apiKey=RAW(yourApiKey)&operation=recognize")
.process(exchange -> {
SpeechRecognitionResults results = exchange.getMessage().getBody(SpeechRecognitionResults.class);
results.getSpeakerLabels().forEach(label -> {
System.out.println("Speaker " + label.getSpeaker() +
" from " + label.getFrom() +
" to " + label.getTo() +
": " + label.getFinal());
});
}); Using Custom Language Models
If you have created a custom language model, you can use it for recognition:
-
Java
-
XML
-
YAML
from("direct:customModel")
.setHeader("CamelIBMWatsonSTTModel", constant("your-custom-model-guid"))
.to("ibm-watson-speech-to-text:mySTT?apiKey=RAW(yourApiKey)&operation=recognize")
.log("Custom model transcript: ${header.CamelIBMWatsonSTTTranscript}"); <route>
<from uri="direct:customModel"/>
<setHeader name="CamelIBMWatsonSTTModel">
<constant>your-custom-model-guid</constant>
</setHeader>
<to uri="ibm-watson-speech-to-text:mySTT?apiKey=RAW(yourApiKey)&operation=recognize"/>
<log message="Custom model transcript: ${header.CamelIBMWatsonSTTTranscript}"/>
</route> - route:
from:
uri: direct:customModel
steps:
- setHeader:
name: CamelIBMWatsonSTTModel
constant: your-custom-model-guid
- to:
uri: ibm-watson-speech-to-text:mySTT
parameters:
apiKey: "RAW(yourApiKey)"
operation: recognize
- log:
message: "Custom model transcript: ${header.CamelIBMWatsonSTTTranscript}" List Custom Models
List all your custom language models:
from("direct:listCustomModels")
.to("ibm-watson-speech-to-text:mySTT?apiKey=RAW(yourApiKey)&operation=listCustomModels")
.process(exchange -> {
List<LanguageModel> models = exchange.getMessage().getBody(List.class);
models.forEach(model -> {
System.out.println("Custom Model: " + model.getCustomizationId() +
" - Name: " + model.getName() +
" - Language: " + model.getLanguage() +
" - Status: " + model.getStatus());
});
}); Get Custom Model Details
Get detailed information about a custom model:
from("direct:getCustomModel")
.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);
System.out.println("Custom model: " + model.getName() +
" - Status: " + model.getStatus() +
" - Progress: " + model.getProgress() + "%");
}); Watson Speech to Text Authentication
IBM Watson Speech to Text uses IBM Cloud IAM (Identity and Access Management) for authentication. You need to provide your IBM Cloud API key.
You can create API keys in the IBM Cloud console: 1. Go to https://cloud.ibm.com/iam/apikeys 2. Click "Create an IBM Cloud API key" 3. Copy the API key and use it in your Camel routes
For more information about authentication, see the IBM Watson STT documentation.
Watson Speech to Text Endpoints
If you have a dedicated or regional instance, you can specify a custom service URL:
from("direct:start")
.setBody(constant(audioFile))
.to("ibm-watson-speech-to-text:mySTT?apiKey=RAW(yourApiKey)&serviceUrl=https://api.eu-gb.speech-to-text.watson.cloud.ibm.com&operation=recognize")
.log("Transcript: ${header.CamelIBMWatsonSTTTranscript}"); Common regional endpoints: - Dallas: https://api.us-south.speech-to-text.watson.cloud.ibm.com - Washington DC: https://api.us-east.speech-to-text.watson.cloud.ibm.com - Frankfurt: https://api.eu-de.speech-to-text.watson.cloud.ibm.com - London: https://api.eu-gb.speech-to-text.watson.cloud.ibm.com - Tokyo: https://api.jp-tok.speech-to-text.watson.cloud.ibm.com - Sydney: https://api.au-syd.speech-to-text.watson.cloud.ibm.com
Integration Tests
This component includes comprehensive integration tests that validate the functionality against the actual IBM Watson Speech to Text service. These tests are disabled by default to prevent accidental API calls during regular builds.
Prerequisites for Running Integration Tests
-
IBM Cloud Account: You need a valid IBM Cloud account
-
Watson Speech to Text Service: Create a Watson Speech to Text service instance in IBM Cloud
-
API Credentials: Obtain your API key and service URL from the IBM Cloud console
To get your credentials:
-
Log in to IBM Cloud Console
-
Navigate to your Speech to Text service instance
-
Go to "Manage" → "Credentials"
-
Copy your API Key and Service URL
Running Integration Tests
Integration tests are executed with the verify goal and require system properties:
mvn verify \
-Dcamel.ibm.watson.stt.apiKey=YOUR_API_KEY \
-Dcamel.ibm.watson.stt.serviceUrl=YOUR_SERVICE_URL Alternatively, using environment variables:
export CAMEL_IBM_WATSON_STT_API_KEY=YOUR_API_KEY
export CAMEL_IBM_WATSON_STT_SERVICE_URL=YOUR_SERVICE_URL
mvn verify \
-Dcamel.ibm.watson.stt.apiKey=${CAMEL_IBM_WATSON_STT_API_KEY} \
-Dcamel.ibm.watson.stt.serviceUrl=${CAMEL_IBM_WATSON_STT_SERVICE_URL} Integration Test Coverage
The integration tests cover all major operations:
Recognition Operations:
-
Basic audio-to-text transcription with default model
-
Transcription with word timestamps
-
Transcription with word confidence scores
-
Different audio formats (WAV, MP3, FLAC)
-
Multiple languages (English, Spanish, French, German)
Model Operations:
-
Listing all available language models
-
Getting detailed information about specific models
Audio File Operations:
-
Reading audio files from disk
-
Processing different audio formats
-
Validating transcription accuracy
Custom Model Operations:
-
Listing custom language models (if available)
-
Getting custom model details (if available)
File Output Operations:
-
Saving transcription results to text files
-
Saving detailed results with timestamps to text files
-
Saving results with word confidence scores to text files
-
Processing multiple audio files and saving transcripts
Generated Audio Test Files
Integration tests automatically generate sample audio files in target/audio-input/:
-
test-audio.wav- Sample WAV file for testing -
test-audio-timestamps.wav- Sample WAV for timestamp testing -
test-audio-confidence.wav- Sample WAV for confidence score testing
These files are simple synthesized audio with known text for validation purposes.
Generated Transcription Output Files
When integration tests run successfully, transcription files are created in target/transcription-output/:
-
transcript-basic.txt- Basic transcription output -
transcript-with-timestamps.txt- Transcription with word-level timestamps -
transcript-detailed.txt- Detailed results with timestamps and word confidence scores -
transcript-file1.txt,transcript-file2.txt,transcript-file3.txt- Multiple file processing results
These files can be reviewed to verify transcription accuracy and examine the detailed recognition results including timestamps and confidence scores.
Important Notes
-
Integration tests make real API calls to IBM Watson and may incur charges
-
Tests are automatically skipped during regular
mvn testexecution -
Audio files in
target/are cleaned withmvn clean -
Tests verify transcription accuracy by comparing against known text
-
All tests include proper resource cleanup
Example Output
[INFO] Running org.apache.camel.component.ibm.watson.stt.integration.WatsonSpeechToTextIT
Created input directory: target/audio-input
Created output directory: target/transcription-output
Generated test audio file: target/audio-input/test-audio.wav
Successfully transcribed audio. Transcript: "Hello this is a test of IBM Watson Speech to Text"
Confidence: 0.98
Found 25 language models
Model: en-US_BroadbandModel - Language: en-US - Rate: 16000
Model: en-GB_BroadbandModel - Language: en-GB - Rate: 16000
Retrieved model details: en-US_BroadbandModel - Description: US English broadband model
Successfully transcribed with timestamps (5 words with timing information)
Successfully transcribed with word confidence (5 words with confidence scores)
Successfully saved transcript to file: target/transcription-output/transcript-basic.txt (size: 156 bytes)
Successfully saved transcript with timestamps to: target/transcription-output/transcript-with-timestamps.txt (size: 452 bytes)
Successfully saved detailed transcript to: target/transcription-output/transcript-detailed.txt (size: 678 bytes)
Created transcript file: transcript-file1.txt (size: 156 bytes)
Created transcript file: transcript-file2.txt (size: 156 bytes)
Created transcript file: transcript-file3.txt (size: 156 bytes)
Successfully transcribed and saved 3 audio files
[INFO] Tests run: 12, Failures: 0, Errors: 0, Skipped: 0 Dependencies
Maven users will need to add the following dependency to their pom.xml.
pom.xml
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-ibm-watson-speech-to-text</artifactId>
<version>x.x.x</version>
<!-- use the same version as your Camel core version -->
</dependency> where x.x.x is the version number of Camel.