|
1 | 1 | package com.assemblyai.api;
|
2 | 2 |
|
3 | 3 | import com.assemblyai.api.core.ClientOptions;
|
| 4 | +import com.assemblyai.api.core.ObjectMappers; |
4 | 5 | import com.assemblyai.api.core.RequestOptions;
|
5 | 6 | import com.assemblyai.api.resources.files.types.UploadedFile;
|
6 | 7 | import com.assemblyai.api.resources.transcripts.TranscriptsClient;
|
7 | 8 | import com.assemblyai.api.resources.transcripts.requests.TranscriptParams;
|
8 | 9 | import com.assemblyai.api.resources.transcripts.requests.WordSearchParams;
|
9 |
| -import com.assemblyai.api.resources.transcripts.types.Transcript; |
10 |
| -import com.assemblyai.api.resources.transcripts.types.TranscriptOptionalParams; |
11 |
| -import com.assemblyai.api.resources.transcripts.types.TranscriptStatus; |
12 |
| -import com.assemblyai.api.resources.transcripts.types.WordSearchResponse; |
| 10 | +import com.assemblyai.api.resources.transcripts.types.*; |
| 11 | +import com.fasterxml.jackson.core.JsonProcessingException; |
| 12 | +import com.fasterxml.jackson.databind.node.ObjectNode; |
13 | 13 |
|
14 | 14 | import java.io.File;
|
15 | 15 | import java.io.IOException;
|
@@ -233,45 +233,16 @@ public Transcript submit(String url, TranscriptOptionalParams transcriptParams)
|
233 | 233 | * @return Queued transcript
|
234 | 234 | */
|
235 | 235 | public Transcript submit(String url, TranscriptOptionalParams transcriptParams, RequestOptions requestOptions) {
|
236 |
| - TranscriptParams createTranscriptParams = TranscriptParams.builder() |
237 |
| - .audioUrl(url) |
238 |
| - .languageCode(transcriptParams.getLanguageCode()) |
239 |
| - .punctuate(transcriptParams.getPunctuate()) |
240 |
| - .formatText(transcriptParams.getFormatText()) |
241 |
| - .dualChannel(transcriptParams.getDualChannel()) |
242 |
| - .webhookUrl(transcriptParams.getWebhookUrl()) |
243 |
| - .webhookAuthHeaderName(transcriptParams.getWebhookAuthHeaderName()) |
244 |
| - .webhookAuthHeaderValue(transcriptParams.getWebhookAuthHeaderValue()) |
245 |
| - .autoHighlights(transcriptParams.getAutoHighlights()) |
246 |
| - .audioStartFrom(transcriptParams.getAudioStartFrom()) |
247 |
| - .audioEndAt(transcriptParams.getAudioEndAt()) |
248 |
| - .wordBoost(transcriptParams.getWordBoost()) |
249 |
| - .boostParam(transcriptParams.getBoostParam()) |
250 |
| - .filterProfanity(transcriptParams.getFilterProfanity()) |
251 |
| - .redactPii(transcriptParams.getRedactPii()) |
252 |
| - .redactPiiAudio(transcriptParams.getRedactPiiAudio()) |
253 |
| - .redactPiiAudioQuality(transcriptParams.getRedactPiiAudioQuality()) |
254 |
| - .redactPiiPolicies(transcriptParams.getRedactPiiPolicies()) |
255 |
| - .redactPiiSub(transcriptParams.getRedactPiiSub()) |
256 |
| - .speakerLabels(transcriptParams.getSpeakerLabels()) |
257 |
| - .speakersExpected(transcriptParams.getSpeakersExpected()) |
258 |
| - .contentSafety(transcriptParams.getContentSafety()) |
259 |
| - .iabCategories(transcriptParams.getIabCategories()) |
260 |
| - .languageDetection(transcriptParams.getLanguageDetection()) |
261 |
| - .customSpelling(transcriptParams.getCustomSpelling()) |
262 |
| - .disfluencies(transcriptParams.getDisfluencies()) |
263 |
| - .sentimentAnalysis(transcriptParams.getSentimentAnalysis()) |
264 |
| - .autoChapters(transcriptParams.getAutoChapters()) |
265 |
| - .entityDetection(transcriptParams.getEntityDetection()) |
266 |
| - .speechModel(transcriptParams.getSpeechModel()) |
267 |
| - .speechThreshold(transcriptParams.getSpeechThreshold()) |
268 |
| - .summarization(transcriptParams.getSummarization()) |
269 |
| - .summaryModel(transcriptParams.getSummaryModel()) |
270 |
| - .summaryType(transcriptParams.getSummaryType()) |
271 |
| - .customTopics(transcriptParams.getCustomTopics()) |
272 |
| - .topics(transcriptParams.getTopics()) |
273 |
| - .build(); |
274 |
| - return super.submit(createTranscriptParams, requestOptions); |
| 236 | + ObjectNode transcriptParamsJson = ObjectMappers.JSON_MAPPER.valueToTree(transcriptParams); |
| 237 | + transcriptParamsJson.put("audio_url", url); |
| 238 | + TranscriptParams fullTranscriptParams; |
| 239 | + try { |
| 240 | + fullTranscriptParams = ObjectMappers.JSON_MAPPER.treeToValue(transcriptParamsJson, TranscriptParams.class); |
| 241 | + } catch (JsonProcessingException e) { |
| 242 | + // this should never happen |
| 243 | + throw new RuntimeException(e); |
| 244 | + } |
| 245 | + return super.submit(fullTranscriptParams, requestOptions); |
275 | 246 | }
|
276 | 247 |
|
277 | 248 | /**
|
|
0 commit comments