commonMain.aws.sdk.kotlin.services.transcribestreaming.DefaultTranscribeStreamingClient.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of transcribestreaming-jvm Show documentation
Show all versions of transcribestreaming-jvm Show documentation
The AWS SDK for Kotlin client for Transcribe Streaming
// Code generated by smithy-kotlin-codegen. DO NOT EDIT!
package aws.sdk.kotlin.services.transcribestreaming
import aws.sdk.kotlin.runtime.client.AwsClientOption
import aws.sdk.kotlin.runtime.http.ApiMetadata
import aws.sdk.kotlin.runtime.http.AwsUserAgentMetadata
import aws.sdk.kotlin.runtime.http.middleware.AwsRetryHeaderMiddleware
import aws.sdk.kotlin.runtime.http.middleware.RecursionDetection
import aws.sdk.kotlin.runtime.http.middleware.UserAgent
import aws.sdk.kotlin.services.transcribestreaming.endpoints.internal.ResolveEndpoint
import aws.sdk.kotlin.services.transcribestreaming.endpoints.internal.bindAwsBuiltins
import aws.sdk.kotlin.services.transcribestreaming.model.*
import aws.sdk.kotlin.services.transcribestreaming.model.StartCallAnalyticsStreamTranscriptionRequest
import aws.sdk.kotlin.services.transcribestreaming.model.StartMedicalStreamTranscriptionRequest
import aws.sdk.kotlin.services.transcribestreaming.model.StartStreamTranscriptionRequest
import aws.sdk.kotlin.services.transcribestreaming.transform.*
import aws.smithy.kotlin.runtime.auth.awssigning.AwsHttpSigner
import aws.smithy.kotlin.runtime.auth.awssigning.AwsSigningAttributes
import aws.smithy.kotlin.runtime.client.SdkClientOption
import aws.smithy.kotlin.runtime.http.SdkHttpClient
import aws.smithy.kotlin.runtime.http.operation.SdkHttpOperation
import aws.smithy.kotlin.runtime.http.operation.context
import aws.smithy.kotlin.runtime.http.operation.execute
import aws.smithy.kotlin.runtime.http.operation.sdkRequestId
import aws.smithy.kotlin.runtime.io.SdkManagedGroup
import aws.smithy.kotlin.runtime.io.addIfManaged
import aws.smithy.kotlin.runtime.operation.ExecutionContext
import aws.smithy.kotlin.runtime.tracing.withRootTraceSpan
import aws.smithy.kotlin.runtime.util.putIfAbsent
import kotlin.coroutines.coroutineContext
public const val ServiceId: String = "Transcribe Streaming"
public const val ServiceApiVersion: String = "2017-10-26"
public const val SdkVersion: String = "0.21.0-beta"
internal class DefaultTranscribeStreamingClient(override val config: TranscribeStreamingClient.Config) : TranscribeStreamingClient {
private val managedResources = SdkManagedGroup()
private val client = SdkHttpClient(config.httpClientEngine)
init {
managedResources.addIfManaged(config.httpClientEngine)
managedResources.addIfManaged(config.credentialsProvider)
}
private val awsUserAgentMetadata = AwsUserAgentMetadata.fromEnvironment(ApiMetadata(ServiceId, SdkVersion))
/**
* Starts a bidirectional HTTP/2 or WebSocket stream where audio is streamed to Amazon Transcribe and the transcription results are streamed to your application. Use this operation for [Call Analytics](https://docs.aws.amazon.com/transcribe/latest/dg/call-analytics.html) transcriptions.
*
* The following parameters are required:
* + `language-code`
* + `media-encoding`
* + `sample-rate`
*
* For more information on streaming with Amazon Transcribe, see [Transcribing streaming audio](https://docs.aws.amazon.com/transcribe/latest/dg/streaming.html).
*/
override suspend fun startCallAnalyticsStreamTranscription(input: StartCallAnalyticsStreamTranscriptionRequest, block: suspend (StartCallAnalyticsStreamTranscriptionResponse) -> T): T {
val op = SdkHttpOperation.build {
serializer = StartCallAnalyticsStreamTranscriptionOperationSerializer()
deserializer = StartCallAnalyticsStreamTranscriptionOperationDeserializer()
context {
expectedHttpStatus = 200
service = serviceName
operationName = "StartCallAnalyticsStreamTranscription"
}
}
op.execution.retryStrategy = config.retryStrategy
op.execution.retryPolicy = config.retryPolicy
mergeServiceDefaults(op.context)
op.interceptors.add(ResolveEndpoint(config.endpointProvider) {
bindAwsBuiltins(config)
})
op.install(AwsRetryHeaderMiddleware())
op.install(UserAgent(awsUserAgentMetadata))
op.install(RecursionDetection())
op.execution.signer = AwsHttpSigner {
this.signer = config.signer
this.credentialsProvider = config.credentialsProvider
this.service = "transcribe"
}
op.interceptors.addAll(config.interceptors)
val rootSpan = config.tracer.createRootSpan("StartCallAnalyticsStreamTranscription-${op.context.sdkRequestId}")
return coroutineContext.withRootTraceSpan(rootSpan) {
op.execute(client, input, block)
}
}
/**
* Starts a bidirectional HTTP/2 or WebSocket stream where audio is streamed to Amazon Transcribe Medical and the transcription results are streamed to your application.
*
* The following parameters are required:
* + `language-code`
* + `media-encoding`
* + `sample-rate`
*
* For more information on streaming with Amazon Transcribe Medical, see [Transcribing streaming audio](https://docs.aws.amazon.com/transcribe/latest/dg/streaming.html).
*/
override suspend fun startMedicalStreamTranscription(input: StartMedicalStreamTranscriptionRequest, block: suspend (StartMedicalStreamTranscriptionResponse) -> T): T {
val op = SdkHttpOperation.build {
serializer = StartMedicalStreamTranscriptionOperationSerializer()
deserializer = StartMedicalStreamTranscriptionOperationDeserializer()
context {
expectedHttpStatus = 200
service = serviceName
operationName = "StartMedicalStreamTranscription"
}
}
op.execution.retryStrategy = config.retryStrategy
op.execution.retryPolicy = config.retryPolicy
mergeServiceDefaults(op.context)
op.interceptors.add(ResolveEndpoint(config.endpointProvider) {
bindAwsBuiltins(config)
})
op.install(AwsRetryHeaderMiddleware())
op.install(UserAgent(awsUserAgentMetadata))
op.install(RecursionDetection())
op.execution.signer = AwsHttpSigner {
this.signer = config.signer
this.credentialsProvider = config.credentialsProvider
this.service = "transcribe"
}
op.interceptors.addAll(config.interceptors)
val rootSpan = config.tracer.createRootSpan("StartMedicalStreamTranscription-${op.context.sdkRequestId}")
return coroutineContext.withRootTraceSpan(rootSpan) {
op.execute(client, input, block)
}
}
/**
* Starts a bidirectional HTTP/2 or WebSocket stream where audio is streamed to Amazon Transcribe and the transcription results are streamed to your application.
*
* The following parameters are required:
* + `language-code` or `identify-language`
* + `media-encoding`
* + `sample-rate`
*
* For more information on streaming with Amazon Transcribe, see [Transcribing streaming audio](https://docs.aws.amazon.com/transcribe/latest/dg/streaming.html).
*/
override suspend fun startStreamTranscription(input: StartStreamTranscriptionRequest, block: suspend (StartStreamTranscriptionResponse) -> T): T {
val op = SdkHttpOperation.build {
serializer = StartStreamTranscriptionOperationSerializer()
deserializer = StartStreamTranscriptionOperationDeserializer()
context {
expectedHttpStatus = 200
service = serviceName
operationName = "StartStreamTranscription"
}
}
op.execution.retryStrategy = config.retryStrategy
op.execution.retryPolicy = config.retryPolicy
mergeServiceDefaults(op.context)
op.interceptors.add(ResolveEndpoint(config.endpointProvider) {
bindAwsBuiltins(config)
})
op.install(AwsRetryHeaderMiddleware())
op.install(UserAgent(awsUserAgentMetadata))
op.install(RecursionDetection())
op.execution.signer = AwsHttpSigner {
this.signer = config.signer
this.credentialsProvider = config.credentialsProvider
this.service = "transcribe"
}
op.interceptors.addAll(config.interceptors)
val rootSpan = config.tracer.createRootSpan("StartStreamTranscription-${op.context.sdkRequestId}")
return coroutineContext.withRootTraceSpan(rootSpan) {
op.execute(client, input, block)
}
}
override fun close() {
managedResources.unshareAll()
}
/**
* merge the defaults configured for the service into the execution context before firing off a request
*/
private suspend fun mergeServiceDefaults(ctx: ExecutionContext) {
ctx.putIfAbsent(AwsClientOption.Region, config.region)
ctx.putIfAbsent(SdkClientOption.ServiceName, serviceName)
ctx.putIfAbsent(SdkClientOption.LogMode, config.sdkLogMode)
ctx.putIfAbsent(AwsSigningAttributes.SigningService, "transcribe")
ctx.putIfAbsent(AwsSigningAttributes.Signer, config.signer)
ctx.putIfAbsent(AwsSigningAttributes.SigningRegion, config.region)
ctx.putIfAbsent(AwsSigningAttributes.CredentialsProvider, config.credentialsProvider)
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy