SpeechToText extends BaseService { public ServiceCall<RecognitionJob> createJob(CreateJobOptions createJobOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( createJobOptions, "createJobOptions cannot be null"); String[] pathSegments = {"v1/recognitions"}; RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("speech_to_text", "v1", "createJob"); for (Entry<String, String> header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); if (createJobOptions.contentType() != null) { builder.header("Content-Type", createJobOptions.contentType()); } if (createJobOptions.model() != null) { builder.query("model", createJobOptions.model()); } if (createJobOptions.callbackUrl() != null) { builder.query("callback_url", createJobOptions.callbackUrl()); } if (createJobOptions.events() != null) { builder.query("events", createJobOptions.events()); } if (createJobOptions.userToken() != null) { builder.query("user_token", createJobOptions.userToken()); } if (createJobOptions.resultsTtl() != null) { builder.query("results_ttl", String.valueOf(createJobOptions.resultsTtl())); } if (createJobOptions.languageCustomizationId() != null) { builder.query("language_customization_id", createJobOptions.languageCustomizationId()); } if (createJobOptions.acousticCustomizationId() != null) { builder.query("acoustic_customization_id", createJobOptions.acousticCustomizationId()); } if (createJobOptions.baseModelVersion() != null) { builder.query("base_model_version", createJobOptions.baseModelVersion()); } if (createJobOptions.customizationWeight() != null) { builder.query("customization_weight", String.valueOf(createJobOptions.customizationWeight())); } if (createJobOptions.inactivityTimeout() != null) { builder.query("inactivity_timeout", String.valueOf(createJobOptions.inactivityTimeout())); } if (createJobOptions.keywords() != null) { builder.query("keywords", RequestUtils.join(createJobOptions.keywords(), ",")); } if (createJobOptions.keywordsThreshold() != null) { builder.query("keywords_threshold", String.valueOf(createJobOptions.keywordsThreshold())); } if (createJobOptions.maxAlternatives() != null) { builder.query("max_alternatives", String.valueOf(createJobOptions.maxAlternatives())); } if (createJobOptions.wordAlternativesThreshold() != null) { builder.query( "word_alternatives_threshold", String.valueOf(createJobOptions.wordAlternativesThreshold())); } if (createJobOptions.wordConfidence() != null) { builder.query("word_confidence", String.valueOf(createJobOptions.wordConfidence())); } if (createJobOptions.timestamps() != null) { builder.query("timestamps", String.valueOf(createJobOptions.timestamps())); } if (createJobOptions.profanityFilter() != null) { builder.query("profanity_filter", String.valueOf(createJobOptions.profanityFilter())); } if (createJobOptions.smartFormatting() != null) { builder.query("smart_formatting", String.valueOf(createJobOptions.smartFormatting())); } if (createJobOptions.speakerLabels() != null) { builder.query("speaker_labels", String.valueOf(createJobOptions.speakerLabels())); } if (createJobOptions.customizationId() != null) { builder.query("customization_id", createJobOptions.customizationId()); } if (createJobOptions.grammarName() != null) { builder.query("grammar_name", createJobOptions.grammarName()); } if (createJobOptions.redaction() != null) { builder.query("redaction", String.valueOf(createJobOptions.redaction())); } if (createJobOptions.processingMetrics() != null) { builder.query("processing_metrics", String.valueOf(createJobOptions.processingMetrics())); } if (createJobOptions.processingMetricsInterval() != null) { builder.query( "processing_metrics_interval", String.valueOf(createJobOptions.processingMetricsInterval())); } if (createJobOptions.audioMetrics() != null) { builder.query("audio_metrics", String.valueOf(createJobOptions.audioMetrics())); } if (createJobOptions.endOfPhraseSilenceTime() != null) { builder.query( "end_of_phrase_silence_time", String.valueOf(createJobOptions.endOfPhraseSilenceTime())); } if (createJobOptions.splitTranscriptAtPhraseEnd() != null) { builder.query( "split_transcript_at_phrase_end", String.valueOf(createJobOptions.splitTranscriptAtPhraseEnd())); } if (createJobOptions.speechDetectorSensitivity() != null) { builder.query( "speech_detector_sensitivity", String.valueOf(createJobOptions.speechDetectorSensitivity())); } if (createJobOptions.backgroundAudioSuppression() != null) { builder.query( "background_audio_suppression", String.valueOf(createJobOptions.backgroundAudioSuppression())); } builder.bodyContent(createJobOptions.contentType(), null, null, createJobOptions.audio()); ResponseConverter<RecognitionJob> responseConverter = ResponseConverterUtils.getValue( new com.google.gson.reflect.TypeToken<RecognitionJob>() {}.getType()); return createServiceCall(builder.build(), responseConverter); } SpeechToText();  SpeechToText(Authenticator authenticator);  SpeechToText(String serviceName);  SpeechToText(String serviceName, Authenticator authenticator); ServiceCall<SpeechModels> listModels(ListModelsOptions listModelsOptions); ServiceCall<SpeechModels> listModels(); ServiceCall<SpeechModel> getModel(GetModelOptions getModelOptions); ServiceCall<SpeechRecognitionResults> recognize(RecognizeOptions recognizeOptions); WebSocket recognizeUsingWebSocket(
      RecognizeOptions recognizeOptions, RecognizeCallback callback); ServiceCall<RegisterStatus> registerCallback(
      RegisterCallbackOptions registerCallbackOptions); ServiceCall<Void> unregisterCallback(UnregisterCallbackOptions unregisterCallbackOptions); ServiceCall<RecognitionJob> createJob(CreateJobOptions createJobOptions); ServiceCall<RecognitionJobs> checkJobs(CheckJobsOptions checkJobsOptions); ServiceCall<RecognitionJobs> checkJobs(); ServiceCall<RecognitionJob> checkJob(CheckJobOptions checkJobOptions); ServiceCall<Void> deleteJob(DeleteJobOptions deleteJobOptions); ServiceCall<LanguageModel> createLanguageModel(
      CreateLanguageModelOptions createLanguageModelOptions); ServiceCall<LanguageModels> listLanguageModels(
      ListLanguageModelsOptions listLanguageModelsOptions); ServiceCall<LanguageModels> listLanguageModels(); ServiceCall<LanguageModel> getLanguageModel(
      GetLanguageModelOptions getLanguageModelOptions); ServiceCall<Void> deleteLanguageModel(
      DeleteLanguageModelOptions deleteLanguageModelOptions); ServiceCall<TrainingResponse> trainLanguageModel(
      TrainLanguageModelOptions trainLanguageModelOptions); ServiceCall<Void> resetLanguageModel(ResetLanguageModelOptions resetLanguageModelOptions); ServiceCall<Void> upgradeLanguageModel(
      UpgradeLanguageModelOptions upgradeLanguageModelOptions); ServiceCall<Corpora> listCorpora(ListCorporaOptions listCorporaOptions); ServiceCall<Void> addCorpus(AddCorpusOptions addCorpusOptions); ServiceCall<Corpus> getCorpus(GetCorpusOptions getCorpusOptions); ServiceCall<Void> deleteCorpus(DeleteCorpusOptions deleteCorpusOptions); ServiceCall<Words> listWords(ListWordsOptions listWordsOptions); ServiceCall<Void> addWords(AddWordsOptions addWordsOptions); ServiceCall<Void> addWord(AddWordOptions addWordOptions); ServiceCall<Word> getWord(GetWordOptions getWordOptions); ServiceCall<Void> deleteWord(DeleteWordOptions deleteWordOptions); ServiceCall<Grammars> listGrammars(ListGrammarsOptions listGrammarsOptions); ServiceCall<Void> addGrammar(AddGrammarOptions addGrammarOptions); ServiceCall<Grammar> getGrammar(GetGrammarOptions getGrammarOptions); ServiceCall<Void> deleteGrammar(DeleteGrammarOptions deleteGrammarOptions); ServiceCall<AcousticModel> createAcousticModel(
      CreateAcousticModelOptions createAcousticModelOptions); ServiceCall<AcousticModels> listAcousticModels(
      ListAcousticModelsOptions listAcousticModelsOptions); ServiceCall<AcousticModels> listAcousticModels(); ServiceCall<AcousticModel> getAcousticModel(
      GetAcousticModelOptions getAcousticModelOptions); ServiceCall<Void> deleteAcousticModel(
      DeleteAcousticModelOptions deleteAcousticModelOptions); ServiceCall<TrainingResponse> trainAcousticModel(
      TrainAcousticModelOptions trainAcousticModelOptions); ServiceCall<Void> resetAcousticModel(ResetAcousticModelOptions resetAcousticModelOptions); ServiceCall<Void> upgradeAcousticModel(
      UpgradeAcousticModelOptions upgradeAcousticModelOptions); ServiceCall<AudioResources> listAudio(ListAudioOptions listAudioOptions); ServiceCall<Void> addAudio(AddAudioOptions addAudioOptions); ServiceCall<AudioListing> getAudio(GetAudioOptions getAudioOptions); ServiceCall<Void> deleteAudio(DeleteAudioOptions deleteAudioOptions); ServiceCall<Void> deleteUserData(DeleteUserDataOptions deleteUserDataOptions);  }
@Test public void testCreateJob() throws InterruptedException, FileNotFoundException { String callbackUrl = "callback"; String events = CreateJobOptions.Events.RECOGNITIONS_STARTED; String userToken = "token"; Long resultsTtl = 5L; File audio = SAMPLE_WAV; String contentType = HttpMediaType.AUDIO_WAV; String model = CreateJobOptions.Model.EN_US_BROADBANDMODEL; String customizationId = "customizationId"; Double customizationWeight = 5d; String version = "version"; Long inactivityTimeout = 20L; List<String> keywords = Arrays.asList("keyword1", "keyword2"); Float keywordsThreshold = 5f; Boolean wordConfidence = true; Boolean timestamps = true; Boolean profanityFilter = true; Boolean smartFormatting = true; Boolean speakerLabels = true; Double endOfPhraseSilenceTime = 2.0; Boolean splitTranscriptAtPhraseEnd = true; RecognitionJob job = loadFixture("src/test/resources/speech_to_text/job.json", RecognitionJob.class); server.enqueue( new MockResponse() .addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON) .setBody(GSON.toJson(job))); CreateJobOptions createOptions = new CreateJobOptions.Builder() .callbackUrl(callbackUrl) .events(events) .userToken(userToken) .resultsTtl(resultsTtl) .audio(audio) .contentType(contentType) .model(model) .languageCustomizationId(customizationId) .customizationWeight(customizationWeight) .baseModelVersion(version) .inactivityTimeout(inactivityTimeout) .keywords(keywords) .keywordsThreshold(keywordsThreshold) .wordConfidence(wordConfidence) .timestamps(timestamps) .profanityFilter(profanityFilter) .smartFormatting(smartFormatting) .speakerLabels(speakerLabels) .endOfPhraseSilenceTime(endOfPhraseSilenceTime) .splitTranscriptAtPhraseEnd(splitTranscriptAtPhraseEnd) .build(); assertEquals((Double) 2.0, createOptions.endOfPhraseSilenceTime()); assertTrue(createOptions.splitTranscriptAtPhraseEnd()); service.createJob(createOptions).execute().getResult(); final RecordedRequest request = server.takeRequest(); assertEquals("POST", request.getMethod()); assertEquals( PATH_RECOGNITIONS + "?model=" + model + "&callback_url=" + callbackUrl + "&events=" + events + "&user_token=" + userToken + "&results_ttl=" + resultsTtl + "&language_customization_id=" + customizationId + "&base_model_version=" + version + "&customization_weight=" + customizationWeight + "&inactivity_timeout=" + inactivityTimeout + "&keywords=" + RequestUtils.encode(StringUtils.join(keywords, ',')) + "&keywords_threshold=" + keywordsThreshold + "&word_confidence=" + wordConfidence + "&timestamps=" + timestamps + "&profanity_filter=" + profanityFilter + "&smart_formatting=" + smartFormatting + "&speaker_labels=" + speakerLabels + "&end_of_phrase_silence_time=" + endOfPhraseSilenceTime + "&split_transcript_at_phrase_end=" + splitTranscriptAtPhraseEnd, request.getPath()); }