github.com/aavshr/aws-sdk-go@v1.41.3/service/transcribestreamingservice/api.go (about) 1 // Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. 2 3 package transcribestreamingservice 4 5 import ( 6 "bytes" 7 "fmt" 8 "io" 9 "sync" 10 "time" 11 12 "github.com/aavshr/aws-sdk-go/aws" 13 "github.com/aavshr/aws-sdk-go/aws/awserr" 14 "github.com/aavshr/aws-sdk-go/aws/awsutil" 15 "github.com/aavshr/aws-sdk-go/aws/client" 16 "github.com/aavshr/aws-sdk-go/aws/request" 17 "github.com/aavshr/aws-sdk-go/aws/signer/v4" 18 "github.com/aavshr/aws-sdk-go/private/protocol" 19 "github.com/aavshr/aws-sdk-go/private/protocol/eventstream" 20 "github.com/aavshr/aws-sdk-go/private/protocol/eventstream/eventstreamapi" 21 "github.com/aavshr/aws-sdk-go/private/protocol/rest" 22 "github.com/aavshr/aws-sdk-go/private/protocol/restjson" 23 ) 24 25 const opStartMedicalStreamTranscription = "StartMedicalStreamTranscription" 26 27 // StartMedicalStreamTranscriptionRequest generates a "aws/request.Request" representing the 28 // client's request for the StartMedicalStreamTranscription operation. The "output" return 29 // value will be populated with the request's response once the request completes 30 // successfully. 31 // 32 // Use "Send" method on the returned Request to send the API call to the service. 33 // the "output" return value is not valid until after Send returns without error. 34 // 35 // See StartMedicalStreamTranscription for more information on using the StartMedicalStreamTranscription 36 // API call, and error handling. 37 // 38 // This method is useful when you want to inject custom logic or configuration 39 // into the SDK's request lifecycle. Such as custom headers, or retry logic. 40 // 41 // 42 // // Example sending a request using the StartMedicalStreamTranscriptionRequest method. 43 // req, resp := client.StartMedicalStreamTranscriptionRequest(params) 44 // 45 // err := req.Send() 46 // if err == nil { // resp is now filled 47 // fmt.Println(resp) 48 // } 49 // 50 // See also, https://docs.aws.amazon.com/goto/WebAPI/transcribe-streaming-2017-10-26/StartMedicalStreamTranscription 51 func (c *TranscribeStreamingService) StartMedicalStreamTranscriptionRequest(input *StartMedicalStreamTranscriptionInput) (req *request.Request, output *StartMedicalStreamTranscriptionOutput) { 52 op := &request.Operation{ 53 Name: opStartMedicalStreamTranscription, 54 HTTPMethod: "POST", 55 HTTPPath: "/medical-stream-transcription", 56 } 57 58 if input == nil { 59 input = &StartMedicalStreamTranscriptionInput{} 60 } 61 62 output = &StartMedicalStreamTranscriptionOutput{} 63 req = c.newRequest(op, input, output) 64 req.Handlers.UnmarshalMeta.PushBack( 65 protocol.RequireHTTPMinProtocol{Major: 2}.Handler, 66 ) 67 68 es := NewStartMedicalStreamTranscriptionEventStream() 69 output.eventStream = es 70 71 req.Handlers.Sign.PushFront(es.setupInputPipe) 72 req.Handlers.UnmarshalError.PushBackNamed(request.NamedHandler{ 73 Name: "InputPipeCloser", 74 Fn: func(r *request.Request) { 75 err := es.closeInputPipe() 76 if err != nil { 77 r.Error = awserr.New(eventstreamapi.InputWriterCloseErrorCode, err.Error(), r.Error) 78 } 79 }, 80 }) 81 req.Handlers.Build.PushBack(request.WithSetRequestHeaders(map[string]string{ 82 "Content-Type": "application/vnd.amazon.eventstream", 83 "X-Amz-Content-Sha256": "STREAMING-AWS4-HMAC-SHA256-EVENTS", 84 })) 85 req.Handlers.Build.Swap(restjson.BuildHandler.Name, rest.BuildHandler) 86 req.Handlers.Send.Swap(client.LogHTTPRequestHandler.Name, client.LogHTTPRequestHeaderHandler) 87 req.Handlers.Unmarshal.PushBack(es.runInputStream) 88 89 req.Handlers.Send.Swap(client.LogHTTPResponseHandler.Name, client.LogHTTPResponseHeaderHandler) 90 req.Handlers.Unmarshal.Swap(restjson.UnmarshalHandler.Name, rest.UnmarshalHandler) 91 req.Handlers.Unmarshal.PushBack(es.runOutputStream) 92 req.Handlers.Unmarshal.PushBack(es.runOnStreamPartClose) 93 return 94 } 95 96 // StartMedicalStreamTranscription API operation for Amazon Transcribe Streaming Service. 97 // 98 // Starts a bidirectional HTTP/2 stream where audio is streamed to Amazon Transcribe 99 // Medical and the transcription results are streamed to your application. 100 // 101 // Returns awserr.Error for service API and SDK errors. Use runtime type assertions 102 // with awserr.Error's Code and Message methods to get detailed information about 103 // the error. 104 // 105 // See the AWS API reference guide for Amazon Transcribe Streaming Service's 106 // API operation StartMedicalStreamTranscription for usage and error information. 107 // 108 // Returned Error Types: 109 // * BadRequestException 110 // One or more arguments to the StartStreamTranscription or StartMedicalStreamTranscription 111 // operation was invalid. For example, MediaEncoding was not set to a valid 112 // encoding, or LanguageCode was not set to a valid code. Check the parameters 113 // and try your request again. 114 // 115 // * LimitExceededException 116 // You have exceeded the maximum number of concurrent transcription streams, 117 // are starting transcription streams too quickly, or the maximum audio length 118 // of 4 hours. Wait until a stream has finished processing, or break your audio 119 // stream into smaller chunks and try your request again. 120 // 121 // * InternalFailureException 122 // A problem occurred while processing the audio. Amazon Transcribe or Amazon 123 // Transcribe Medical terminated processing. Try your request again. 124 // 125 // * ConflictException 126 // A new stream started with the same session ID. The current stream has been 127 // terminated. 128 // 129 // * ServiceUnavailableException 130 // Service is currently unavailable. Try your request later. 131 // 132 // See also, https://docs.aws.amazon.com/goto/WebAPI/transcribe-streaming-2017-10-26/StartMedicalStreamTranscription 133 func (c *TranscribeStreamingService) StartMedicalStreamTranscription(input *StartMedicalStreamTranscriptionInput) (*StartMedicalStreamTranscriptionOutput, error) { 134 req, out := c.StartMedicalStreamTranscriptionRequest(input) 135 return out, req.Send() 136 } 137 138 // StartMedicalStreamTranscriptionWithContext is the same as StartMedicalStreamTranscription with the addition of 139 // the ability to pass a context and additional request options. 140 // 141 // See StartMedicalStreamTranscription for details on how to use this API operation. 142 // 143 // The context must be non-nil and will be used for request cancellation. If 144 // the context is nil a panic will occur. In the future the SDK may create 145 // sub-contexts for http.Requests. See https://golang.org/pkg/context/ 146 // for more information on using Contexts. 147 func (c *TranscribeStreamingService) StartMedicalStreamTranscriptionWithContext(ctx aws.Context, input *StartMedicalStreamTranscriptionInput, opts ...request.Option) (*StartMedicalStreamTranscriptionOutput, error) { 148 req, out := c.StartMedicalStreamTranscriptionRequest(input) 149 req.SetContext(ctx) 150 req.ApplyOptions(opts...) 151 return out, req.Send() 152 } 153 154 var _ awserr.Error 155 156 // StartMedicalStreamTranscriptionEventStream provides the event stream handling for the StartMedicalStreamTranscription. 157 // 158 // For testing and mocking the event stream this type should be initialized via 159 // the NewStartMedicalStreamTranscriptionEventStream constructor function. Using the functional options 160 // to pass in nested mock behavior. 161 type StartMedicalStreamTranscriptionEventStream struct { 162 163 // Writer is the EventStream writer for the AudioStream 164 // events. This value is automatically set by the SDK when the API call is made 165 // Use this member when unit testing your code with the SDK to mock out the 166 // EventStream Writer. 167 // 168 // Must not be nil. 169 Writer AudioStreamWriter 170 171 inputWriter io.WriteCloser 172 173 // Reader is the EventStream reader for the MedicalTranscriptResultStream 174 // events. This value is automatically set by the SDK when the API call is made 175 // Use this member when unit testing your code with the SDK to mock out the 176 // EventStream Reader. 177 // 178 // Must not be nil. 179 Reader MedicalTranscriptResultStreamReader 180 181 outputReader io.ReadCloser 182 183 done chan struct{} 184 closeOnce sync.Once 185 err *eventstreamapi.OnceError 186 } 187 188 // NewStartMedicalStreamTranscriptionEventStream initializes an StartMedicalStreamTranscriptionEventStream. 189 // This function should only be used for testing and mocking the StartMedicalStreamTranscriptionEventStream 190 // stream within your application. 191 // 192 // The Writer member must be set before writing events to the stream. 193 // 194 // The Reader member must be set before reading events from the stream. 195 // 196 // es := NewStartMedicalStreamTranscriptionEventStream(func(o *StartMedicalStreamTranscriptionEventStream{ 197 // es.Writer = myMockStreamWriter 198 // es.Reader = myMockStreamReader 199 // }) 200 func NewStartMedicalStreamTranscriptionEventStream(opts ...func(*StartMedicalStreamTranscriptionEventStream)) *StartMedicalStreamTranscriptionEventStream { 201 es := &StartMedicalStreamTranscriptionEventStream{ 202 done: make(chan struct{}), 203 err: eventstreamapi.NewOnceError(), 204 } 205 206 for _, fn := range opts { 207 fn(es) 208 } 209 210 return es 211 } 212 213 func (es *StartMedicalStreamTranscriptionEventStream) runOnStreamPartClose(r *request.Request) { 214 if es.done == nil { 215 return 216 } 217 go es.waitStreamPartClose() 218 219 } 220 221 func (es *StartMedicalStreamTranscriptionEventStream) waitStreamPartClose() { 222 var inputErrCh <-chan struct{} 223 if v, ok := es.Writer.(interface{ ErrorSet() <-chan struct{} }); ok { 224 inputErrCh = v.ErrorSet() 225 } 226 var outputErrCh <-chan struct{} 227 if v, ok := es.Reader.(interface{ ErrorSet() <-chan struct{} }); ok { 228 outputErrCh = v.ErrorSet() 229 } 230 var outputClosedCh <-chan struct{} 231 if v, ok := es.Reader.(interface{ Closed() <-chan struct{} }); ok { 232 outputClosedCh = v.Closed() 233 } 234 235 select { 236 case <-es.done: 237 case <-inputErrCh: 238 es.err.SetError(es.Writer.Err()) 239 es.Close() 240 case <-outputErrCh: 241 es.err.SetError(es.Reader.Err()) 242 es.Close() 243 case <-outputClosedCh: 244 if err := es.Reader.Err(); err != nil { 245 es.err.SetError(es.Reader.Err()) 246 } 247 es.Close() 248 } 249 } 250 251 func (es *StartMedicalStreamTranscriptionEventStream) setupInputPipe(r *request.Request) { 252 inputReader, inputWriter := io.Pipe() 253 r.SetStreamingBody(inputReader) 254 es.inputWriter = inputWriter 255 } 256 257 // Closes the input-pipe writer 258 func (es *StartMedicalStreamTranscriptionEventStream) closeInputPipe() error { 259 if es.inputWriter != nil { 260 return es.inputWriter.Close() 261 } 262 return nil 263 } 264 265 // Send writes the event to the stream blocking until the event is written. 266 // Returns an error if the event was not written. 267 // 268 // These events are: 269 // 270 // * AudioEvent 271 func (es *StartMedicalStreamTranscriptionEventStream) Send(ctx aws.Context, event AudioStreamEvent) error { 272 return es.Writer.Send(ctx, event) 273 } 274 275 func (es *StartMedicalStreamTranscriptionEventStream) runInputStream(r *request.Request) { 276 var opts []func(*eventstream.Encoder) 277 if r.Config.Logger != nil && r.Config.LogLevel.Matches(aws.LogDebugWithEventStreamBody) { 278 opts = append(opts, eventstream.EncodeWithLogger(r.Config.Logger)) 279 } 280 var encoder eventstreamapi.Encoder = eventstream.NewEncoder(es.inputWriter, opts...) 281 282 var closer aws.MultiCloser 283 sigSeed, err := v4.GetSignedRequestSignature(r.HTTPRequest) 284 if err != nil { 285 r.Error = awserr.New(request.ErrCodeSerialization, 286 "unable to get initial request's signature", err) 287 return 288 } 289 signer := eventstreamapi.NewSignEncoder( 290 v4.NewStreamSigner(r.ClientInfo.SigningRegion, r.ClientInfo.SigningName, 291 sigSeed, r.Config.Credentials), 292 encoder, 293 ) 294 encoder = signer 295 closer = append(closer, signer) 296 closer = append(closer, es.inputWriter) 297 298 eventWriter := eventstreamapi.NewEventWriter(encoder, 299 protocol.HandlerPayloadMarshal{ 300 Marshalers: r.Handlers.BuildStream, 301 }, 302 eventTypeForAudioStreamEvent, 303 ) 304 305 es.Writer = &writeAudioStream{ 306 StreamWriter: eventstreamapi.NewStreamWriter(eventWriter, closer), 307 } 308 } 309 310 // Events returns a channel to read events from. 311 // 312 // These events are: 313 // 314 // * MedicalTranscriptEvent 315 // * MedicalTranscriptResultStreamUnknownEvent 316 func (es *StartMedicalStreamTranscriptionEventStream) Events() <-chan MedicalTranscriptResultStreamEvent { 317 return es.Reader.Events() 318 } 319 320 func (es *StartMedicalStreamTranscriptionEventStream) runOutputStream(r *request.Request) { 321 var opts []func(*eventstream.Decoder) 322 if r.Config.Logger != nil && r.Config.LogLevel.Matches(aws.LogDebugWithEventStreamBody) { 323 opts = append(opts, eventstream.DecodeWithLogger(r.Config.Logger)) 324 } 325 326 unmarshalerForEvent := unmarshalerForMedicalTranscriptResultStreamEvent{ 327 metadata: protocol.ResponseMetadata{ 328 StatusCode: r.HTTPResponse.StatusCode, 329 RequestID: r.RequestID, 330 }, 331 }.UnmarshalerForEventName 332 333 decoder := eventstream.NewDecoder(r.HTTPResponse.Body, opts...) 334 eventReader := eventstreamapi.NewEventReader(decoder, 335 protocol.HandlerPayloadUnmarshal{ 336 Unmarshalers: r.Handlers.UnmarshalStream, 337 }, 338 unmarshalerForEvent, 339 ) 340 341 es.outputReader = r.HTTPResponse.Body 342 es.Reader = newReadMedicalTranscriptResultStream(eventReader) 343 } 344 345 // Close closes the stream. This will also cause the stream to be closed. 346 // Close must be called when done using the stream API. Not calling Close 347 // may result in resource leaks. 348 // 349 // Will close the underlying EventStream writer, and no more events can be 350 // sent. 351 // 352 // You can use the closing of the Reader's Events channel to terminate your 353 // application's read from the API's stream. 354 // 355 func (es *StartMedicalStreamTranscriptionEventStream) Close() (err error) { 356 es.closeOnce.Do(es.safeClose) 357 return es.Err() 358 } 359 360 func (es *StartMedicalStreamTranscriptionEventStream) safeClose() { 361 if es.done != nil { 362 close(es.done) 363 } 364 365 t := time.NewTicker(time.Second) 366 defer t.Stop() 367 writeCloseDone := make(chan error) 368 go func() { 369 if err := es.Writer.Close(); err != nil { 370 es.err.SetError(err) 371 } 372 close(writeCloseDone) 373 }() 374 select { 375 case <-t.C: 376 case <-writeCloseDone: 377 } 378 if err := es.closeInputPipe(); err != nil { 379 es.err.SetError(err) 380 } 381 382 es.Reader.Close() 383 if es.outputReader != nil { 384 es.outputReader.Close() 385 } 386 } 387 388 // Err returns any error that occurred while reading or writing EventStream 389 // Events from the service API's response. Returns nil if there were no errors. 390 func (es *StartMedicalStreamTranscriptionEventStream) Err() error { 391 if err := es.err.Err(); err != nil { 392 return err 393 } 394 if err := es.Writer.Err(); err != nil { 395 return err 396 } 397 if err := es.Reader.Err(); err != nil { 398 return err 399 } 400 401 return nil 402 } 403 404 const opStartStreamTranscription = "StartStreamTranscription" 405 406 // StartStreamTranscriptionRequest generates a "aws/request.Request" representing the 407 // client's request for the StartStreamTranscription operation. The "output" return 408 // value will be populated with the request's response once the request completes 409 // successfully. 410 // 411 // Use "Send" method on the returned Request to send the API call to the service. 412 // the "output" return value is not valid until after Send returns without error. 413 // 414 // See StartStreamTranscription for more information on using the StartStreamTranscription 415 // API call, and error handling. 416 // 417 // This method is useful when you want to inject custom logic or configuration 418 // into the SDK's request lifecycle. Such as custom headers, or retry logic. 419 // 420 // 421 // // Example sending a request using the StartStreamTranscriptionRequest method. 422 // req, resp := client.StartStreamTranscriptionRequest(params) 423 // 424 // err := req.Send() 425 // if err == nil { // resp is now filled 426 // fmt.Println(resp) 427 // } 428 // 429 // See also, https://docs.aws.amazon.com/goto/WebAPI/transcribe-streaming-2017-10-26/StartStreamTranscription 430 func (c *TranscribeStreamingService) StartStreamTranscriptionRequest(input *StartStreamTranscriptionInput) (req *request.Request, output *StartStreamTranscriptionOutput) { 431 op := &request.Operation{ 432 Name: opStartStreamTranscription, 433 HTTPMethod: "POST", 434 HTTPPath: "/stream-transcription", 435 } 436 437 if input == nil { 438 input = &StartStreamTranscriptionInput{} 439 } 440 441 output = &StartStreamTranscriptionOutput{} 442 req = c.newRequest(op, input, output) 443 req.Handlers.UnmarshalMeta.PushBack( 444 protocol.RequireHTTPMinProtocol{Major: 2}.Handler, 445 ) 446 447 es := NewStartStreamTranscriptionEventStream() 448 output.eventStream = es 449 450 req.Handlers.Sign.PushFront(es.setupInputPipe) 451 req.Handlers.UnmarshalError.PushBackNamed(request.NamedHandler{ 452 Name: "InputPipeCloser", 453 Fn: func(r *request.Request) { 454 err := es.closeInputPipe() 455 if err != nil { 456 r.Error = awserr.New(eventstreamapi.InputWriterCloseErrorCode, err.Error(), r.Error) 457 } 458 }, 459 }) 460 req.Handlers.Build.PushBack(request.WithSetRequestHeaders(map[string]string{ 461 "Content-Type": "application/vnd.amazon.eventstream", 462 "X-Amz-Content-Sha256": "STREAMING-AWS4-HMAC-SHA256-EVENTS", 463 })) 464 req.Handlers.Build.Swap(restjson.BuildHandler.Name, rest.BuildHandler) 465 req.Handlers.Send.Swap(client.LogHTTPRequestHandler.Name, client.LogHTTPRequestHeaderHandler) 466 req.Handlers.Unmarshal.PushBack(es.runInputStream) 467 468 req.Handlers.Send.Swap(client.LogHTTPResponseHandler.Name, client.LogHTTPResponseHeaderHandler) 469 req.Handlers.Unmarshal.Swap(restjson.UnmarshalHandler.Name, rest.UnmarshalHandler) 470 req.Handlers.Unmarshal.PushBack(es.runOutputStream) 471 req.Handlers.Unmarshal.PushBack(es.runOnStreamPartClose) 472 return 473 } 474 475 // StartStreamTranscription API operation for Amazon Transcribe Streaming Service. 476 // 477 // Starts a bidirectional HTTP/2 stream where audio is streamed to Amazon Transcribe 478 // and the transcription results are streamed to your application. 479 // 480 // The following are encoded as HTTP/2 headers: 481 // 482 // * x-amzn-transcribe-language-code 483 // 484 // * x-amzn-transcribe-media-encoding 485 // 486 // * x-amzn-transcribe-sample-rate 487 // 488 // * x-amzn-transcribe-session-id 489 // 490 // See the SDK for Go API Reference (https://docs.aws.amazon.com/sdk-for-go/api/service/transcribestreamingservice/#TranscribeStreamingService.StartStreamTranscription) 491 // for more detail. 492 // 493 // Returns awserr.Error for service API and SDK errors. Use runtime type assertions 494 // with awserr.Error's Code and Message methods to get detailed information about 495 // the error. 496 // 497 // See the AWS API reference guide for Amazon Transcribe Streaming Service's 498 // API operation StartStreamTranscription for usage and error information. 499 // 500 // Returned Error Types: 501 // * BadRequestException 502 // One or more arguments to the StartStreamTranscription or StartMedicalStreamTranscription 503 // operation was invalid. For example, MediaEncoding was not set to a valid 504 // encoding, or LanguageCode was not set to a valid code. Check the parameters 505 // and try your request again. 506 // 507 // * LimitExceededException 508 // You have exceeded the maximum number of concurrent transcription streams, 509 // are starting transcription streams too quickly, or the maximum audio length 510 // of 4 hours. Wait until a stream has finished processing, or break your audio 511 // stream into smaller chunks and try your request again. 512 // 513 // * InternalFailureException 514 // A problem occurred while processing the audio. Amazon Transcribe or Amazon 515 // Transcribe Medical terminated processing. Try your request again. 516 // 517 // * ConflictException 518 // A new stream started with the same session ID. The current stream has been 519 // terminated. 520 // 521 // * ServiceUnavailableException 522 // Service is currently unavailable. Try your request later. 523 // 524 // See also, https://docs.aws.amazon.com/goto/WebAPI/transcribe-streaming-2017-10-26/StartStreamTranscription 525 func (c *TranscribeStreamingService) StartStreamTranscription(input *StartStreamTranscriptionInput) (*StartStreamTranscriptionOutput, error) { 526 req, out := c.StartStreamTranscriptionRequest(input) 527 return out, req.Send() 528 } 529 530 // StartStreamTranscriptionWithContext is the same as StartStreamTranscription with the addition of 531 // the ability to pass a context and additional request options. 532 // 533 // See StartStreamTranscription for details on how to use this API operation. 534 // 535 // The context must be non-nil and will be used for request cancellation. If 536 // the context is nil a panic will occur. In the future the SDK may create 537 // sub-contexts for http.Requests. See https://golang.org/pkg/context/ 538 // for more information on using Contexts. 539 func (c *TranscribeStreamingService) StartStreamTranscriptionWithContext(ctx aws.Context, input *StartStreamTranscriptionInput, opts ...request.Option) (*StartStreamTranscriptionOutput, error) { 540 req, out := c.StartStreamTranscriptionRequest(input) 541 req.SetContext(ctx) 542 req.ApplyOptions(opts...) 543 return out, req.Send() 544 } 545 546 var _ awserr.Error 547 548 // StartStreamTranscriptionEventStream provides the event stream handling for the StartStreamTranscription. 549 // 550 // For testing and mocking the event stream this type should be initialized via 551 // the NewStartStreamTranscriptionEventStream constructor function. Using the functional options 552 // to pass in nested mock behavior. 553 type StartStreamTranscriptionEventStream struct { 554 555 // Writer is the EventStream writer for the AudioStream 556 // events. This value is automatically set by the SDK when the API call is made 557 // Use this member when unit testing your code with the SDK to mock out the 558 // EventStream Writer. 559 // 560 // Must not be nil. 561 Writer AudioStreamWriter 562 563 inputWriter io.WriteCloser 564 565 // Reader is the EventStream reader for the TranscriptResultStream 566 // events. This value is automatically set by the SDK when the API call is made 567 // Use this member when unit testing your code with the SDK to mock out the 568 // EventStream Reader. 569 // 570 // Must not be nil. 571 Reader TranscriptResultStreamReader 572 573 outputReader io.ReadCloser 574 575 done chan struct{} 576 closeOnce sync.Once 577 err *eventstreamapi.OnceError 578 } 579 580 // NewStartStreamTranscriptionEventStream initializes an StartStreamTranscriptionEventStream. 581 // This function should only be used for testing and mocking the StartStreamTranscriptionEventStream 582 // stream within your application. 583 // 584 // The Writer member must be set before writing events to the stream. 585 // 586 // The Reader member must be set before reading events from the stream. 587 // 588 // es := NewStartStreamTranscriptionEventStream(func(o *StartStreamTranscriptionEventStream{ 589 // es.Writer = myMockStreamWriter 590 // es.Reader = myMockStreamReader 591 // }) 592 func NewStartStreamTranscriptionEventStream(opts ...func(*StartStreamTranscriptionEventStream)) *StartStreamTranscriptionEventStream { 593 es := &StartStreamTranscriptionEventStream{ 594 done: make(chan struct{}), 595 err: eventstreamapi.NewOnceError(), 596 } 597 598 for _, fn := range opts { 599 fn(es) 600 } 601 602 return es 603 } 604 605 func (es *StartStreamTranscriptionEventStream) runOnStreamPartClose(r *request.Request) { 606 if es.done == nil { 607 return 608 } 609 go es.waitStreamPartClose() 610 611 } 612 613 func (es *StartStreamTranscriptionEventStream) waitStreamPartClose() { 614 var inputErrCh <-chan struct{} 615 if v, ok := es.Writer.(interface{ ErrorSet() <-chan struct{} }); ok { 616 inputErrCh = v.ErrorSet() 617 } 618 var outputErrCh <-chan struct{} 619 if v, ok := es.Reader.(interface{ ErrorSet() <-chan struct{} }); ok { 620 outputErrCh = v.ErrorSet() 621 } 622 var outputClosedCh <-chan struct{} 623 if v, ok := es.Reader.(interface{ Closed() <-chan struct{} }); ok { 624 outputClosedCh = v.Closed() 625 } 626 627 select { 628 case <-es.done: 629 case <-inputErrCh: 630 es.err.SetError(es.Writer.Err()) 631 es.Close() 632 case <-outputErrCh: 633 es.err.SetError(es.Reader.Err()) 634 es.Close() 635 case <-outputClosedCh: 636 if err := es.Reader.Err(); err != nil { 637 es.err.SetError(es.Reader.Err()) 638 } 639 es.Close() 640 } 641 } 642 643 func (es *StartStreamTranscriptionEventStream) setupInputPipe(r *request.Request) { 644 inputReader, inputWriter := io.Pipe() 645 r.SetStreamingBody(inputReader) 646 es.inputWriter = inputWriter 647 } 648 649 // Closes the input-pipe writer 650 func (es *StartStreamTranscriptionEventStream) closeInputPipe() error { 651 if es.inputWriter != nil { 652 return es.inputWriter.Close() 653 } 654 return nil 655 } 656 657 // Send writes the event to the stream blocking until the event is written. 658 // Returns an error if the event was not written. 659 // 660 // These events are: 661 // 662 // * AudioEvent 663 func (es *StartStreamTranscriptionEventStream) Send(ctx aws.Context, event AudioStreamEvent) error { 664 return es.Writer.Send(ctx, event) 665 } 666 667 func (es *StartStreamTranscriptionEventStream) runInputStream(r *request.Request) { 668 var opts []func(*eventstream.Encoder) 669 if r.Config.Logger != nil && r.Config.LogLevel.Matches(aws.LogDebugWithEventStreamBody) { 670 opts = append(opts, eventstream.EncodeWithLogger(r.Config.Logger)) 671 } 672 var encoder eventstreamapi.Encoder = eventstream.NewEncoder(es.inputWriter, opts...) 673 674 var closer aws.MultiCloser 675 sigSeed, err := v4.GetSignedRequestSignature(r.HTTPRequest) 676 if err != nil { 677 r.Error = awserr.New(request.ErrCodeSerialization, 678 "unable to get initial request's signature", err) 679 return 680 } 681 signer := eventstreamapi.NewSignEncoder( 682 v4.NewStreamSigner(r.ClientInfo.SigningRegion, r.ClientInfo.SigningName, 683 sigSeed, r.Config.Credentials), 684 encoder, 685 ) 686 encoder = signer 687 closer = append(closer, signer) 688 closer = append(closer, es.inputWriter) 689 690 eventWriter := eventstreamapi.NewEventWriter(encoder, 691 protocol.HandlerPayloadMarshal{ 692 Marshalers: r.Handlers.BuildStream, 693 }, 694 eventTypeForAudioStreamEvent, 695 ) 696 697 es.Writer = &writeAudioStream{ 698 StreamWriter: eventstreamapi.NewStreamWriter(eventWriter, closer), 699 } 700 } 701 702 // Events returns a channel to read events from. 703 // 704 // These events are: 705 // 706 // * TranscriptEvent 707 // * TranscriptResultStreamUnknownEvent 708 func (es *StartStreamTranscriptionEventStream) Events() <-chan TranscriptResultStreamEvent { 709 return es.Reader.Events() 710 } 711 712 func (es *StartStreamTranscriptionEventStream) runOutputStream(r *request.Request) { 713 var opts []func(*eventstream.Decoder) 714 if r.Config.Logger != nil && r.Config.LogLevel.Matches(aws.LogDebugWithEventStreamBody) { 715 opts = append(opts, eventstream.DecodeWithLogger(r.Config.Logger)) 716 } 717 718 unmarshalerForEvent := unmarshalerForTranscriptResultStreamEvent{ 719 metadata: protocol.ResponseMetadata{ 720 StatusCode: r.HTTPResponse.StatusCode, 721 RequestID: r.RequestID, 722 }, 723 }.UnmarshalerForEventName 724 725 decoder := eventstream.NewDecoder(r.HTTPResponse.Body, opts...) 726 eventReader := eventstreamapi.NewEventReader(decoder, 727 protocol.HandlerPayloadUnmarshal{ 728 Unmarshalers: r.Handlers.UnmarshalStream, 729 }, 730 unmarshalerForEvent, 731 ) 732 733 es.outputReader = r.HTTPResponse.Body 734 es.Reader = newReadTranscriptResultStream(eventReader) 735 } 736 737 // Close closes the stream. This will also cause the stream to be closed. 738 // Close must be called when done using the stream API. Not calling Close 739 // may result in resource leaks. 740 // 741 // Will close the underlying EventStream writer, and no more events can be 742 // sent. 743 // 744 // You can use the closing of the Reader's Events channel to terminate your 745 // application's read from the API's stream. 746 // 747 func (es *StartStreamTranscriptionEventStream) Close() (err error) { 748 es.closeOnce.Do(es.safeClose) 749 return es.Err() 750 } 751 752 func (es *StartStreamTranscriptionEventStream) safeClose() { 753 if es.done != nil { 754 close(es.done) 755 } 756 757 t := time.NewTicker(time.Second) 758 defer t.Stop() 759 writeCloseDone := make(chan error) 760 go func() { 761 if err := es.Writer.Close(); err != nil { 762 es.err.SetError(err) 763 } 764 close(writeCloseDone) 765 }() 766 select { 767 case <-t.C: 768 case <-writeCloseDone: 769 } 770 if err := es.closeInputPipe(); err != nil { 771 es.err.SetError(err) 772 } 773 774 es.Reader.Close() 775 if es.outputReader != nil { 776 es.outputReader.Close() 777 } 778 } 779 780 // Err returns any error that occurred while reading or writing EventStream 781 // Events from the service API's response. Returns nil if there were no errors. 782 func (es *StartStreamTranscriptionEventStream) Err() error { 783 if err := es.err.Err(); err != nil { 784 return err 785 } 786 if err := es.Writer.Err(); err != nil { 787 return err 788 } 789 if err := es.Reader.Err(); err != nil { 790 return err 791 } 792 793 return nil 794 } 795 796 // A list of possible transcriptions for the audio. 797 type Alternative struct { 798 _ struct{} `type:"structure"` 799 800 // Contains the entities identified as personally identifiable information (PII) 801 // in the transcription output. 802 Entities []*Entity `type:"list"` 803 804 // One or more alternative interpretations of the input audio. 805 Items []*Item `type:"list"` 806 807 // The text that was transcribed from the audio. 808 Transcript *string `type:"string"` 809 } 810 811 // String returns the string representation. 812 // 813 // API parameter values that are decorated as "sensitive" in the API will not 814 // be included in the string output. The member name will be present, but the 815 // value will be replaced with "sensitive". 816 func (s Alternative) String() string { 817 return awsutil.Prettify(s) 818 } 819 820 // GoString returns the string representation. 821 // 822 // API parameter values that are decorated as "sensitive" in the API will not 823 // be included in the string output. The member name will be present, but the 824 // value will be replaced with "sensitive". 825 func (s Alternative) GoString() string { 826 return s.String() 827 } 828 829 // SetEntities sets the Entities field's value. 830 func (s *Alternative) SetEntities(v []*Entity) *Alternative { 831 s.Entities = v 832 return s 833 } 834 835 // SetItems sets the Items field's value. 836 func (s *Alternative) SetItems(v []*Item) *Alternative { 837 s.Items = v 838 return s 839 } 840 841 // SetTranscript sets the Transcript field's value. 842 func (s *Alternative) SetTranscript(v string) *Alternative { 843 s.Transcript = &v 844 return s 845 } 846 847 // Provides a wrapper for the audio chunks that you are sending. 848 // 849 // For information on audio encoding in Amazon Transcribe, see Speech input 850 // (https://docs.aws.amazon.com/transcribe/latest/dg/input.html). For information 851 // on audio encoding formats in Amazon Transcribe Medical, see Speech input 852 // (https://docs.aws.amazon.com/transcribe/latest/dg/input-med.html). 853 type AudioEvent struct { 854 _ struct{} `type:"structure" payload:"AudioChunk"` 855 856 // An audio blob that contains the next part of the audio that you want to transcribe. 857 // The maximum audio chunk size is 32 KB. 858 // AudioChunk is automatically base64 encoded/decoded by the SDK. 859 AudioChunk []byte `type:"blob"` 860 } 861 862 // String returns the string representation. 863 // 864 // API parameter values that are decorated as "sensitive" in the API will not 865 // be included in the string output. The member name will be present, but the 866 // value will be replaced with "sensitive". 867 func (s AudioEvent) String() string { 868 return awsutil.Prettify(s) 869 } 870 871 // GoString returns the string representation. 872 // 873 // API parameter values that are decorated as "sensitive" in the API will not 874 // be included in the string output. The member name will be present, but the 875 // value will be replaced with "sensitive". 876 func (s AudioEvent) GoString() string { 877 return s.String() 878 } 879 880 // SetAudioChunk sets the AudioChunk field's value. 881 func (s *AudioEvent) SetAudioChunk(v []byte) *AudioEvent { 882 s.AudioChunk = v 883 return s 884 } 885 886 // The AudioEvent is and event in the AudioStream group of events. 887 func (s *AudioEvent) eventAudioStream() {} 888 889 // UnmarshalEvent unmarshals the EventStream Message into the AudioEvent value. 890 // This method is only used internally within the SDK's EventStream handling. 891 func (s *AudioEvent) UnmarshalEvent( 892 payloadUnmarshaler protocol.PayloadUnmarshaler, 893 msg eventstream.Message, 894 ) error { 895 s.AudioChunk = make([]byte, len(msg.Payload)) 896 copy(s.AudioChunk, msg.Payload) 897 return nil 898 } 899 900 // MarshalEvent marshals the type into an stream event value. This method 901 // should only used internally within the SDK's EventStream handling. 902 func (s *AudioEvent) MarshalEvent(pm protocol.PayloadMarshaler) (msg eventstream.Message, err error) { 903 msg.Headers.Set(eventstreamapi.MessageTypeHeader, eventstream.StringValue(eventstreamapi.EventMessageType)) 904 msg.Headers.Set(":content-type", eventstream.StringValue("application/octet-stream")) 905 msg.Payload = s.AudioChunk 906 return msg, err 907 } 908 909 // AudioStreamEvent groups together all EventStream 910 // events writes for AudioStream. 911 // 912 // These events are: 913 // 914 // * AudioEvent 915 type AudioStreamEvent interface { 916 eventAudioStream() 917 eventstreamapi.Marshaler 918 eventstreamapi.Unmarshaler 919 } 920 921 // AudioStreamWriter provides the interface for writing events to the stream. 922 // The default implementation for this interface will be AudioStream. 923 // 924 // The writer's Close method must allow multiple concurrent calls. 925 // 926 // These events are: 927 // 928 // * AudioEvent 929 type AudioStreamWriter interface { 930 // Sends writes events to the stream blocking until the event has been 931 // written. An error is returned if the write fails. 932 Send(aws.Context, AudioStreamEvent) error 933 934 // Close will stop the writer writing to the event stream. 935 Close() error 936 937 // Returns any error that has occurred while writing to the event stream. 938 Err() error 939 } 940 941 type writeAudioStream struct { 942 *eventstreamapi.StreamWriter 943 } 944 945 func (w *writeAudioStream) Send(ctx aws.Context, event AudioStreamEvent) error { 946 return w.StreamWriter.Send(ctx, event) 947 } 948 949 func eventTypeForAudioStreamEvent(event eventstreamapi.Marshaler) (string, error) { 950 switch event.(type) { 951 case *AudioEvent: 952 return "AudioEvent", nil 953 default: 954 return "", awserr.New( 955 request.ErrCodeSerialization, 956 fmt.Sprintf("unknown event type, %T, for AudioStream", event), 957 nil, 958 ) 959 } 960 } 961 962 // One or more arguments to the StartStreamTranscription or StartMedicalStreamTranscription 963 // operation was invalid. For example, MediaEncoding was not set to a valid 964 // encoding, or LanguageCode was not set to a valid code. Check the parameters 965 // and try your request again. 966 type BadRequestException struct { 967 _ struct{} `type:"structure"` 968 RespMetadata protocol.ResponseMetadata `json:"-" xml:"-"` 969 970 Message_ *string `locationName:"Message" type:"string"` 971 } 972 973 // String returns the string representation. 974 // 975 // API parameter values that are decorated as "sensitive" in the API will not 976 // be included in the string output. The member name will be present, but the 977 // value will be replaced with "sensitive". 978 func (s BadRequestException) String() string { 979 return awsutil.Prettify(s) 980 } 981 982 // GoString returns the string representation. 983 // 984 // API parameter values that are decorated as "sensitive" in the API will not 985 // be included in the string output. The member name will be present, but the 986 // value will be replaced with "sensitive". 987 func (s BadRequestException) GoString() string { 988 return s.String() 989 } 990 991 // The BadRequestException is and event in the MedicalTranscriptResultStream group of events. 992 func (s *BadRequestException) eventMedicalTranscriptResultStream() {} 993 994 // The BadRequestException is and event in the TranscriptResultStream group of events. 995 func (s *BadRequestException) eventTranscriptResultStream() {} 996 997 // UnmarshalEvent unmarshals the EventStream Message into the BadRequestException value. 998 // This method is only used internally within the SDK's EventStream handling. 999 func (s *BadRequestException) UnmarshalEvent( 1000 payloadUnmarshaler protocol.PayloadUnmarshaler, 1001 msg eventstream.Message, 1002 ) error { 1003 if err := payloadUnmarshaler.UnmarshalPayload( 1004 bytes.NewReader(msg.Payload), s, 1005 ); err != nil { 1006 return err 1007 } 1008 return nil 1009 } 1010 1011 // MarshalEvent marshals the type into an stream event value. This method 1012 // should only used internally within the SDK's EventStream handling. 1013 func (s *BadRequestException) MarshalEvent(pm protocol.PayloadMarshaler) (msg eventstream.Message, err error) { 1014 msg.Headers.Set(eventstreamapi.MessageTypeHeader, eventstream.StringValue(eventstreamapi.ExceptionMessageType)) 1015 var buf bytes.Buffer 1016 if err = pm.MarshalPayload(&buf, s); err != nil { 1017 return eventstream.Message{}, err 1018 } 1019 msg.Payload = buf.Bytes() 1020 return msg, err 1021 } 1022 1023 func newErrorBadRequestException(v protocol.ResponseMetadata) error { 1024 return &BadRequestException{ 1025 RespMetadata: v, 1026 } 1027 } 1028 1029 // Code returns the exception type name. 1030 func (s *BadRequestException) Code() string { 1031 return "BadRequestException" 1032 } 1033 1034 // Message returns the exception's message. 1035 func (s *BadRequestException) Message() string { 1036 if s.Message_ != nil { 1037 return *s.Message_ 1038 } 1039 return "" 1040 } 1041 1042 // OrigErr always returns nil, satisfies awserr.Error interface. 1043 func (s *BadRequestException) OrigErr() error { 1044 return nil 1045 } 1046 1047 func (s *BadRequestException) Error() string { 1048 return fmt.Sprintf("%s: %s", s.Code(), s.Message()) 1049 } 1050 1051 // Status code returns the HTTP status code for the request's response error. 1052 func (s *BadRequestException) StatusCode() int { 1053 return s.RespMetadata.StatusCode 1054 } 1055 1056 // RequestID returns the service's response RequestID for request. 1057 func (s *BadRequestException) RequestID() string { 1058 return s.RespMetadata.RequestID 1059 } 1060 1061 // A new stream started with the same session ID. The current stream has been 1062 // terminated. 1063 type ConflictException struct { 1064 _ struct{} `type:"structure"` 1065 RespMetadata protocol.ResponseMetadata `json:"-" xml:"-"` 1066 1067 Message_ *string `locationName:"Message" type:"string"` 1068 } 1069 1070 // String returns the string representation. 1071 // 1072 // API parameter values that are decorated as "sensitive" in the API will not 1073 // be included in the string output. The member name will be present, but the 1074 // value will be replaced with "sensitive". 1075 func (s ConflictException) String() string { 1076 return awsutil.Prettify(s) 1077 } 1078 1079 // GoString returns the string representation. 1080 // 1081 // API parameter values that are decorated as "sensitive" in the API will not 1082 // be included in the string output. The member name will be present, but the 1083 // value will be replaced with "sensitive". 1084 func (s ConflictException) GoString() string { 1085 return s.String() 1086 } 1087 1088 // The ConflictException is and event in the MedicalTranscriptResultStream group of events. 1089 func (s *ConflictException) eventMedicalTranscriptResultStream() {} 1090 1091 // The ConflictException is and event in the TranscriptResultStream group of events. 1092 func (s *ConflictException) eventTranscriptResultStream() {} 1093 1094 // UnmarshalEvent unmarshals the EventStream Message into the ConflictException value. 1095 // This method is only used internally within the SDK's EventStream handling. 1096 func (s *ConflictException) UnmarshalEvent( 1097 payloadUnmarshaler protocol.PayloadUnmarshaler, 1098 msg eventstream.Message, 1099 ) error { 1100 if err := payloadUnmarshaler.UnmarshalPayload( 1101 bytes.NewReader(msg.Payload), s, 1102 ); err != nil { 1103 return err 1104 } 1105 return nil 1106 } 1107 1108 // MarshalEvent marshals the type into an stream event value. This method 1109 // should only used internally within the SDK's EventStream handling. 1110 func (s *ConflictException) MarshalEvent(pm protocol.PayloadMarshaler) (msg eventstream.Message, err error) { 1111 msg.Headers.Set(eventstreamapi.MessageTypeHeader, eventstream.StringValue(eventstreamapi.ExceptionMessageType)) 1112 var buf bytes.Buffer 1113 if err = pm.MarshalPayload(&buf, s); err != nil { 1114 return eventstream.Message{}, err 1115 } 1116 msg.Payload = buf.Bytes() 1117 return msg, err 1118 } 1119 1120 func newErrorConflictException(v protocol.ResponseMetadata) error { 1121 return &ConflictException{ 1122 RespMetadata: v, 1123 } 1124 } 1125 1126 // Code returns the exception type name. 1127 func (s *ConflictException) Code() string { 1128 return "ConflictException" 1129 } 1130 1131 // Message returns the exception's message. 1132 func (s *ConflictException) Message() string { 1133 if s.Message_ != nil { 1134 return *s.Message_ 1135 } 1136 return "" 1137 } 1138 1139 // OrigErr always returns nil, satisfies awserr.Error interface. 1140 func (s *ConflictException) OrigErr() error { 1141 return nil 1142 } 1143 1144 func (s *ConflictException) Error() string { 1145 return fmt.Sprintf("%s: %s", s.Code(), s.Message()) 1146 } 1147 1148 // Status code returns the HTTP status code for the request's response error. 1149 func (s *ConflictException) StatusCode() int { 1150 return s.RespMetadata.StatusCode 1151 } 1152 1153 // RequestID returns the service's response RequestID for request. 1154 func (s *ConflictException) RequestID() string { 1155 return s.RespMetadata.RequestID 1156 } 1157 1158 // The entity identified as personally identifiable information (PII). 1159 type Entity struct { 1160 _ struct{} `type:"structure"` 1161 1162 // The category of of information identified in this entity; for example, PII. 1163 Category *string `type:"string"` 1164 1165 // A value between zero and one that Amazon Transcribe assigns to PII identified 1166 // in the source audio. Larger values indicate a higher confidence in PII identification. 1167 Confidence *float64 `type:"double"` 1168 1169 // The words in the transcription output that have been identified as a PII 1170 // entity. 1171 Content *string `type:"string"` 1172 1173 // The end time of speech that was identified as PII. 1174 EndTime *float64 `type:"double"` 1175 1176 // The start time of speech that was identified as PII. 1177 StartTime *float64 `type:"double"` 1178 1179 // The type of PII identified in this entity; for example, name or credit card 1180 // number. 1181 Type *string `type:"string"` 1182 } 1183 1184 // String returns the string representation. 1185 // 1186 // API parameter values that are decorated as "sensitive" in the API will not 1187 // be included in the string output. The member name will be present, but the 1188 // value will be replaced with "sensitive". 1189 func (s Entity) String() string { 1190 return awsutil.Prettify(s) 1191 } 1192 1193 // GoString returns the string representation. 1194 // 1195 // API parameter values that are decorated as "sensitive" in the API will not 1196 // be included in the string output. The member name will be present, but the 1197 // value will be replaced with "sensitive". 1198 func (s Entity) GoString() string { 1199 return s.String() 1200 } 1201 1202 // SetCategory sets the Category field's value. 1203 func (s *Entity) SetCategory(v string) *Entity { 1204 s.Category = &v 1205 return s 1206 } 1207 1208 // SetConfidence sets the Confidence field's value. 1209 func (s *Entity) SetConfidence(v float64) *Entity { 1210 s.Confidence = &v 1211 return s 1212 } 1213 1214 // SetContent sets the Content field's value. 1215 func (s *Entity) SetContent(v string) *Entity { 1216 s.Content = &v 1217 return s 1218 } 1219 1220 // SetEndTime sets the EndTime field's value. 1221 func (s *Entity) SetEndTime(v float64) *Entity { 1222 s.EndTime = &v 1223 return s 1224 } 1225 1226 // SetStartTime sets the StartTime field's value. 1227 func (s *Entity) SetStartTime(v float64) *Entity { 1228 s.StartTime = &v 1229 return s 1230 } 1231 1232 // SetType sets the Type field's value. 1233 func (s *Entity) SetType(v string) *Entity { 1234 s.Type = &v 1235 return s 1236 } 1237 1238 // A problem occurred while processing the audio. Amazon Transcribe or Amazon 1239 // Transcribe Medical terminated processing. Try your request again. 1240 type InternalFailureException struct { 1241 _ struct{} `type:"structure"` 1242 RespMetadata protocol.ResponseMetadata `json:"-" xml:"-"` 1243 1244 Message_ *string `locationName:"Message" type:"string"` 1245 } 1246 1247 // String returns the string representation. 1248 // 1249 // API parameter values that are decorated as "sensitive" in the API will not 1250 // be included in the string output. The member name will be present, but the 1251 // value will be replaced with "sensitive". 1252 func (s InternalFailureException) String() string { 1253 return awsutil.Prettify(s) 1254 } 1255 1256 // GoString returns the string representation. 1257 // 1258 // API parameter values that are decorated as "sensitive" in the API will not 1259 // be included in the string output. The member name will be present, but the 1260 // value will be replaced with "sensitive". 1261 func (s InternalFailureException) GoString() string { 1262 return s.String() 1263 } 1264 1265 // The InternalFailureException is and event in the MedicalTranscriptResultStream group of events. 1266 func (s *InternalFailureException) eventMedicalTranscriptResultStream() {} 1267 1268 // The InternalFailureException is and event in the TranscriptResultStream group of events. 1269 func (s *InternalFailureException) eventTranscriptResultStream() {} 1270 1271 // UnmarshalEvent unmarshals the EventStream Message into the InternalFailureException value. 1272 // This method is only used internally within the SDK's EventStream handling. 1273 func (s *InternalFailureException) UnmarshalEvent( 1274 payloadUnmarshaler protocol.PayloadUnmarshaler, 1275 msg eventstream.Message, 1276 ) error { 1277 if err := payloadUnmarshaler.UnmarshalPayload( 1278 bytes.NewReader(msg.Payload), s, 1279 ); err != nil { 1280 return err 1281 } 1282 return nil 1283 } 1284 1285 // MarshalEvent marshals the type into an stream event value. This method 1286 // should only used internally within the SDK's EventStream handling. 1287 func (s *InternalFailureException) MarshalEvent(pm protocol.PayloadMarshaler) (msg eventstream.Message, err error) { 1288 msg.Headers.Set(eventstreamapi.MessageTypeHeader, eventstream.StringValue(eventstreamapi.ExceptionMessageType)) 1289 var buf bytes.Buffer 1290 if err = pm.MarshalPayload(&buf, s); err != nil { 1291 return eventstream.Message{}, err 1292 } 1293 msg.Payload = buf.Bytes() 1294 return msg, err 1295 } 1296 1297 func newErrorInternalFailureException(v protocol.ResponseMetadata) error { 1298 return &InternalFailureException{ 1299 RespMetadata: v, 1300 } 1301 } 1302 1303 // Code returns the exception type name. 1304 func (s *InternalFailureException) Code() string { 1305 return "InternalFailureException" 1306 } 1307 1308 // Message returns the exception's message. 1309 func (s *InternalFailureException) Message() string { 1310 if s.Message_ != nil { 1311 return *s.Message_ 1312 } 1313 return "" 1314 } 1315 1316 // OrigErr always returns nil, satisfies awserr.Error interface. 1317 func (s *InternalFailureException) OrigErr() error { 1318 return nil 1319 } 1320 1321 func (s *InternalFailureException) Error() string { 1322 return fmt.Sprintf("%s: %s", s.Code(), s.Message()) 1323 } 1324 1325 // Status code returns the HTTP status code for the request's response error. 1326 func (s *InternalFailureException) StatusCode() int { 1327 return s.RespMetadata.StatusCode 1328 } 1329 1330 // RequestID returns the service's response RequestID for request. 1331 func (s *InternalFailureException) RequestID() string { 1332 return s.RespMetadata.RequestID 1333 } 1334 1335 // A word, phrase, or punctuation mark that is transcribed from the input audio. 1336 type Item struct { 1337 _ struct{} `type:"structure"` 1338 1339 // A value between 0 and 1 for an item that is a confidence score that Amazon 1340 // Transcribe assigns to each word or phrase that it transcribes. 1341 Confidence *float64 `type:"double"` 1342 1343 // The word or punctuation that was recognized in the input audio. 1344 Content *string `type:"string"` 1345 1346 // The offset from the beginning of the audio stream to the end of the audio 1347 // that resulted in the item. 1348 EndTime *float64 `type:"double"` 1349 1350 // If speaker identification is enabled, shows the speakers identified in the 1351 // real-time stream. 1352 Speaker *string `type:"string"` 1353 1354 // If partial result stabilization has been enabled, indicates whether the word 1355 // or phrase in the item is stable. If Stable is true, the result is stable. 1356 Stable *bool `type:"boolean"` 1357 1358 // The offset from the beginning of the audio stream to the beginning of the 1359 // audio that resulted in the item. 1360 StartTime *float64 `type:"double"` 1361 1362 // The type of the item. PRONUNCIATION indicates that the item is a word that 1363 // was recognized in the input audio. PUNCTUATION indicates that the item was 1364 // interpreted as a pause in the input audio. 1365 Type *string `type:"string" enum:"ItemType"` 1366 1367 // Indicates whether a word in the item matches a word in the vocabulary filter 1368 // you've chosen for your real-time stream. If true then a word in the item 1369 // matches your vocabulary filter. 1370 VocabularyFilterMatch *bool `type:"boolean"` 1371 } 1372 1373 // String returns the string representation. 1374 // 1375 // API parameter values that are decorated as "sensitive" in the API will not 1376 // be included in the string output. The member name will be present, but the 1377 // value will be replaced with "sensitive". 1378 func (s Item) String() string { 1379 return awsutil.Prettify(s) 1380 } 1381 1382 // GoString returns the string representation. 1383 // 1384 // API parameter values that are decorated as "sensitive" in the API will not 1385 // be included in the string output. The member name will be present, but the 1386 // value will be replaced with "sensitive". 1387 func (s Item) GoString() string { 1388 return s.String() 1389 } 1390 1391 // SetConfidence sets the Confidence field's value. 1392 func (s *Item) SetConfidence(v float64) *Item { 1393 s.Confidence = &v 1394 return s 1395 } 1396 1397 // SetContent sets the Content field's value. 1398 func (s *Item) SetContent(v string) *Item { 1399 s.Content = &v 1400 return s 1401 } 1402 1403 // SetEndTime sets the EndTime field's value. 1404 func (s *Item) SetEndTime(v float64) *Item { 1405 s.EndTime = &v 1406 return s 1407 } 1408 1409 // SetSpeaker sets the Speaker field's value. 1410 func (s *Item) SetSpeaker(v string) *Item { 1411 s.Speaker = &v 1412 return s 1413 } 1414 1415 // SetStable sets the Stable field's value. 1416 func (s *Item) SetStable(v bool) *Item { 1417 s.Stable = &v 1418 return s 1419 } 1420 1421 // SetStartTime sets the StartTime field's value. 1422 func (s *Item) SetStartTime(v float64) *Item { 1423 s.StartTime = &v 1424 return s 1425 } 1426 1427 // SetType sets the Type field's value. 1428 func (s *Item) SetType(v string) *Item { 1429 s.Type = &v 1430 return s 1431 } 1432 1433 // SetVocabularyFilterMatch sets the VocabularyFilterMatch field's value. 1434 func (s *Item) SetVocabularyFilterMatch(v bool) *Item { 1435 s.VocabularyFilterMatch = &v 1436 return s 1437 } 1438 1439 // You have exceeded the maximum number of concurrent transcription streams, 1440 // are starting transcription streams too quickly, or the maximum audio length 1441 // of 4 hours. Wait until a stream has finished processing, or break your audio 1442 // stream into smaller chunks and try your request again. 1443 type LimitExceededException struct { 1444 _ struct{} `type:"structure"` 1445 RespMetadata protocol.ResponseMetadata `json:"-" xml:"-"` 1446 1447 Message_ *string `locationName:"Message" type:"string"` 1448 } 1449 1450 // String returns the string representation. 1451 // 1452 // API parameter values that are decorated as "sensitive" in the API will not 1453 // be included in the string output. The member name will be present, but the 1454 // value will be replaced with "sensitive". 1455 func (s LimitExceededException) String() string { 1456 return awsutil.Prettify(s) 1457 } 1458 1459 // GoString returns the string representation. 1460 // 1461 // API parameter values that are decorated as "sensitive" in the API will not 1462 // be included in the string output. The member name will be present, but the 1463 // value will be replaced with "sensitive". 1464 func (s LimitExceededException) GoString() string { 1465 return s.String() 1466 } 1467 1468 // The LimitExceededException is and event in the MedicalTranscriptResultStream group of events. 1469 func (s *LimitExceededException) eventMedicalTranscriptResultStream() {} 1470 1471 // The LimitExceededException is and event in the TranscriptResultStream group of events. 1472 func (s *LimitExceededException) eventTranscriptResultStream() {} 1473 1474 // UnmarshalEvent unmarshals the EventStream Message into the LimitExceededException value. 1475 // This method is only used internally within the SDK's EventStream handling. 1476 func (s *LimitExceededException) UnmarshalEvent( 1477 payloadUnmarshaler protocol.PayloadUnmarshaler, 1478 msg eventstream.Message, 1479 ) error { 1480 if err := payloadUnmarshaler.UnmarshalPayload( 1481 bytes.NewReader(msg.Payload), s, 1482 ); err != nil { 1483 return err 1484 } 1485 return nil 1486 } 1487 1488 // MarshalEvent marshals the type into an stream event value. This method 1489 // should only used internally within the SDK's EventStream handling. 1490 func (s *LimitExceededException) MarshalEvent(pm protocol.PayloadMarshaler) (msg eventstream.Message, err error) { 1491 msg.Headers.Set(eventstreamapi.MessageTypeHeader, eventstream.StringValue(eventstreamapi.ExceptionMessageType)) 1492 var buf bytes.Buffer 1493 if err = pm.MarshalPayload(&buf, s); err != nil { 1494 return eventstream.Message{}, err 1495 } 1496 msg.Payload = buf.Bytes() 1497 return msg, err 1498 } 1499 1500 func newErrorLimitExceededException(v protocol.ResponseMetadata) error { 1501 return &LimitExceededException{ 1502 RespMetadata: v, 1503 } 1504 } 1505 1506 // Code returns the exception type name. 1507 func (s *LimitExceededException) Code() string { 1508 return "LimitExceededException" 1509 } 1510 1511 // Message returns the exception's message. 1512 func (s *LimitExceededException) Message() string { 1513 if s.Message_ != nil { 1514 return *s.Message_ 1515 } 1516 return "" 1517 } 1518 1519 // OrigErr always returns nil, satisfies awserr.Error interface. 1520 func (s *LimitExceededException) OrigErr() error { 1521 return nil 1522 } 1523 1524 func (s *LimitExceededException) Error() string { 1525 return fmt.Sprintf("%s: %s", s.Code(), s.Message()) 1526 } 1527 1528 // Status code returns the HTTP status code for the request's response error. 1529 func (s *LimitExceededException) StatusCode() int { 1530 return s.RespMetadata.StatusCode 1531 } 1532 1533 // RequestID returns the service's response RequestID for request. 1534 func (s *LimitExceededException) RequestID() string { 1535 return s.RespMetadata.RequestID 1536 } 1537 1538 // A list of possible transcriptions for the audio. 1539 type MedicalAlternative struct { 1540 _ struct{} `type:"structure"` 1541 1542 // Contains the medical entities identified as personal health information in 1543 // the transcription output. 1544 Entities []*MedicalEntity `type:"list"` 1545 1546 // A list of objects that contains words and punctuation marks that represents 1547 // one or more interpretations of the input audio. 1548 Items []*MedicalItem `type:"list"` 1549 1550 // The text that was transcribed from the audio. 1551 Transcript *string `type:"string"` 1552 } 1553 1554 // String returns the string representation. 1555 // 1556 // API parameter values that are decorated as "sensitive" in the API will not 1557 // be included in the string output. The member name will be present, but the 1558 // value will be replaced with "sensitive". 1559 func (s MedicalAlternative) String() string { 1560 return awsutil.Prettify(s) 1561 } 1562 1563 // GoString returns the string representation. 1564 // 1565 // API parameter values that are decorated as "sensitive" in the API will not 1566 // be included in the string output. The member name will be present, but the 1567 // value will be replaced with "sensitive". 1568 func (s MedicalAlternative) GoString() string { 1569 return s.String() 1570 } 1571 1572 // SetEntities sets the Entities field's value. 1573 func (s *MedicalAlternative) SetEntities(v []*MedicalEntity) *MedicalAlternative { 1574 s.Entities = v 1575 return s 1576 } 1577 1578 // SetItems sets the Items field's value. 1579 func (s *MedicalAlternative) SetItems(v []*MedicalItem) *MedicalAlternative { 1580 s.Items = v 1581 return s 1582 } 1583 1584 // SetTranscript sets the Transcript field's value. 1585 func (s *MedicalAlternative) SetTranscript(v string) *MedicalAlternative { 1586 s.Transcript = &v 1587 return s 1588 } 1589 1590 // The medical entity identified as personal health information. 1591 type MedicalEntity struct { 1592 _ struct{} `type:"structure"` 1593 1594 // The type of personal health information of the medical entity. 1595 Category *string `type:"string"` 1596 1597 // A value between zero and one that Amazon Transcribe Medical assigned to the 1598 // personal health information that it identified in the source audio. Larger 1599 // values indicate that Amazon Transcribe Medical has higher confidence in the 1600 // personal health information that it identified. 1601 Confidence *float64 `type:"double"` 1602 1603 // The word or words in the transcription output that have been identified as 1604 // a medical entity. 1605 Content *string `type:"string"` 1606 1607 // The end time of the speech that was identified as a medical entity. 1608 EndTime *float64 `type:"double"` 1609 1610 // The start time of the speech that was identified as a medical entity. 1611 StartTime *float64 `type:"double"` 1612 } 1613 1614 // String returns the string representation. 1615 // 1616 // API parameter values that are decorated as "sensitive" in the API will not 1617 // be included in the string output. The member name will be present, but the 1618 // value will be replaced with "sensitive". 1619 func (s MedicalEntity) String() string { 1620 return awsutil.Prettify(s) 1621 } 1622 1623 // GoString returns the string representation. 1624 // 1625 // API parameter values that are decorated as "sensitive" in the API will not 1626 // be included in the string output. The member name will be present, but the 1627 // value will be replaced with "sensitive". 1628 func (s MedicalEntity) GoString() string { 1629 return s.String() 1630 } 1631 1632 // SetCategory sets the Category field's value. 1633 func (s *MedicalEntity) SetCategory(v string) *MedicalEntity { 1634 s.Category = &v 1635 return s 1636 } 1637 1638 // SetConfidence sets the Confidence field's value. 1639 func (s *MedicalEntity) SetConfidence(v float64) *MedicalEntity { 1640 s.Confidence = &v 1641 return s 1642 } 1643 1644 // SetContent sets the Content field's value. 1645 func (s *MedicalEntity) SetContent(v string) *MedicalEntity { 1646 s.Content = &v 1647 return s 1648 } 1649 1650 // SetEndTime sets the EndTime field's value. 1651 func (s *MedicalEntity) SetEndTime(v float64) *MedicalEntity { 1652 s.EndTime = &v 1653 return s 1654 } 1655 1656 // SetStartTime sets the StartTime field's value. 1657 func (s *MedicalEntity) SetStartTime(v float64) *MedicalEntity { 1658 s.StartTime = &v 1659 return s 1660 } 1661 1662 // A word, phrase, or punctuation mark that is transcribed from the input audio. 1663 type MedicalItem struct { 1664 _ struct{} `type:"structure"` 1665 1666 // A value between 0 and 1 for an item that is a confidence score that Amazon 1667 // Transcribe Medical assigns to each word that it transcribes. 1668 Confidence *float64 `type:"double"` 1669 1670 // The word or punctuation mark that was recognized in the input audio. 1671 Content *string `type:"string"` 1672 1673 // The number of seconds into an audio stream that indicates the creation time 1674 // of an item. 1675 EndTime *float64 `type:"double"` 1676 1677 // If speaker identification is enabled, shows the integer values that correspond 1678 // to the different speakers identified in the stream. For example, if the value 1679 // of Speaker in the stream is either a 0 or a 1, that indicates that Amazon 1680 // Transcribe Medical has identified two speakers in the stream. The value of 1681 // 0 corresponds to one speaker and the value of 1 corresponds to the other 1682 // speaker. 1683 Speaker *string `type:"string"` 1684 1685 // The number of seconds into an audio stream that indicates the creation time 1686 // of an item. 1687 StartTime *float64 `type:"double"` 1688 1689 // The type of the item. PRONUNCIATION indicates that the item is a word that 1690 // was recognized in the input audio. PUNCTUATION indicates that the item was 1691 // interpreted as a pause in the input audio, such as a period to indicate the 1692 // end of a sentence. 1693 Type *string `type:"string" enum:"ItemType"` 1694 } 1695 1696 // String returns the string representation. 1697 // 1698 // API parameter values that are decorated as "sensitive" in the API will not 1699 // be included in the string output. The member name will be present, but the 1700 // value will be replaced with "sensitive". 1701 func (s MedicalItem) String() string { 1702 return awsutil.Prettify(s) 1703 } 1704 1705 // GoString returns the string representation. 1706 // 1707 // API parameter values that are decorated as "sensitive" in the API will not 1708 // be included in the string output. The member name will be present, but the 1709 // value will be replaced with "sensitive". 1710 func (s MedicalItem) GoString() string { 1711 return s.String() 1712 } 1713 1714 // SetConfidence sets the Confidence field's value. 1715 func (s *MedicalItem) SetConfidence(v float64) *MedicalItem { 1716 s.Confidence = &v 1717 return s 1718 } 1719 1720 // SetContent sets the Content field's value. 1721 func (s *MedicalItem) SetContent(v string) *MedicalItem { 1722 s.Content = &v 1723 return s 1724 } 1725 1726 // SetEndTime sets the EndTime field's value. 1727 func (s *MedicalItem) SetEndTime(v float64) *MedicalItem { 1728 s.EndTime = &v 1729 return s 1730 } 1731 1732 // SetSpeaker sets the Speaker field's value. 1733 func (s *MedicalItem) SetSpeaker(v string) *MedicalItem { 1734 s.Speaker = &v 1735 return s 1736 } 1737 1738 // SetStartTime sets the StartTime field's value. 1739 func (s *MedicalItem) SetStartTime(v float64) *MedicalItem { 1740 s.StartTime = &v 1741 return s 1742 } 1743 1744 // SetType sets the Type field's value. 1745 func (s *MedicalItem) SetType(v string) *MedicalItem { 1746 s.Type = &v 1747 return s 1748 } 1749 1750 // The results of transcribing a portion of the input audio stream. 1751 type MedicalResult struct { 1752 _ struct{} `type:"structure"` 1753 1754 // A list of possible transcriptions of the audio. Each alternative typically 1755 // contains one Item that contains the result of the transcription. 1756 Alternatives []*MedicalAlternative `type:"list"` 1757 1758 // When channel identification is enabled, Amazon Transcribe Medical transcribes 1759 // the speech from each audio channel separately. 1760 // 1761 // You can use ChannelId to retrieve the transcription results for a single 1762 // channel in your audio stream. 1763 ChannelId *string `type:"string"` 1764 1765 // The time, in seconds, from the beginning of the audio stream to the end of 1766 // the result. 1767 EndTime *float64 `type:"double"` 1768 1769 // Amazon Transcribe Medical divides the incoming audio stream into segments 1770 // at natural points in the audio. Transcription results are returned based 1771 // on these segments. 1772 // 1773 // The IsPartial field is true to indicate that Amazon Transcribe Medical has 1774 // additional transcription data to send. The IsPartial field is false to indicate 1775 // that this is the last transcription result for the segment. 1776 IsPartial *bool `type:"boolean"` 1777 1778 // A unique identifier for the result. 1779 ResultId *string `type:"string"` 1780 1781 // The time, in seconds, from the beginning of the audio stream to the beginning 1782 // of the result. 1783 StartTime *float64 `type:"double"` 1784 } 1785 1786 // String returns the string representation. 1787 // 1788 // API parameter values that are decorated as "sensitive" in the API will not 1789 // be included in the string output. The member name will be present, but the 1790 // value will be replaced with "sensitive". 1791 func (s MedicalResult) String() string { 1792 return awsutil.Prettify(s) 1793 } 1794 1795 // GoString returns the string representation. 1796 // 1797 // API parameter values that are decorated as "sensitive" in the API will not 1798 // be included in the string output. The member name will be present, but the 1799 // value will be replaced with "sensitive". 1800 func (s MedicalResult) GoString() string { 1801 return s.String() 1802 } 1803 1804 // SetAlternatives sets the Alternatives field's value. 1805 func (s *MedicalResult) SetAlternatives(v []*MedicalAlternative) *MedicalResult { 1806 s.Alternatives = v 1807 return s 1808 } 1809 1810 // SetChannelId sets the ChannelId field's value. 1811 func (s *MedicalResult) SetChannelId(v string) *MedicalResult { 1812 s.ChannelId = &v 1813 return s 1814 } 1815 1816 // SetEndTime sets the EndTime field's value. 1817 func (s *MedicalResult) SetEndTime(v float64) *MedicalResult { 1818 s.EndTime = &v 1819 return s 1820 } 1821 1822 // SetIsPartial sets the IsPartial field's value. 1823 func (s *MedicalResult) SetIsPartial(v bool) *MedicalResult { 1824 s.IsPartial = &v 1825 return s 1826 } 1827 1828 // SetResultId sets the ResultId field's value. 1829 func (s *MedicalResult) SetResultId(v string) *MedicalResult { 1830 s.ResultId = &v 1831 return s 1832 } 1833 1834 // SetStartTime sets the StartTime field's value. 1835 func (s *MedicalResult) SetStartTime(v float64) *MedicalResult { 1836 s.StartTime = &v 1837 return s 1838 } 1839 1840 // The medical transcript in a MedicalTranscriptEvent. 1841 type MedicalTranscript struct { 1842 _ struct{} `type:"structure"` 1843 1844 // MedicalResult objects that contain the results of transcribing a portion 1845 // of the input audio stream. The array can be empty. 1846 Results []*MedicalResult `type:"list"` 1847 } 1848 1849 // String returns the string representation. 1850 // 1851 // API parameter values that are decorated as "sensitive" in the API will not 1852 // be included in the string output. The member name will be present, but the 1853 // value will be replaced with "sensitive". 1854 func (s MedicalTranscript) String() string { 1855 return awsutil.Prettify(s) 1856 } 1857 1858 // GoString returns the string representation. 1859 // 1860 // API parameter values that are decorated as "sensitive" in the API will not 1861 // be included in the string output. The member name will be present, but the 1862 // value will be replaced with "sensitive". 1863 func (s MedicalTranscript) GoString() string { 1864 return s.String() 1865 } 1866 1867 // SetResults sets the Results field's value. 1868 func (s *MedicalTranscript) SetResults(v []*MedicalResult) *MedicalTranscript { 1869 s.Results = v 1870 return s 1871 } 1872 1873 // Represents a set of transcription results from the server to the client. 1874 // It contains one or more segments of the transcription. 1875 type MedicalTranscriptEvent struct { 1876 _ struct{} `type:"structure"` 1877 1878 // The transcription of the audio stream. The transcription is composed of all 1879 // of the items in the results list. 1880 Transcript *MedicalTranscript `type:"structure"` 1881 } 1882 1883 // String returns the string representation. 1884 // 1885 // API parameter values that are decorated as "sensitive" in the API will not 1886 // be included in the string output. The member name will be present, but the 1887 // value will be replaced with "sensitive". 1888 func (s MedicalTranscriptEvent) String() string { 1889 return awsutil.Prettify(s) 1890 } 1891 1892 // GoString returns the string representation. 1893 // 1894 // API parameter values that are decorated as "sensitive" in the API will not 1895 // be included in the string output. The member name will be present, but the 1896 // value will be replaced with "sensitive". 1897 func (s MedicalTranscriptEvent) GoString() string { 1898 return s.String() 1899 } 1900 1901 // SetTranscript sets the Transcript field's value. 1902 func (s *MedicalTranscriptEvent) SetTranscript(v *MedicalTranscript) *MedicalTranscriptEvent { 1903 s.Transcript = v 1904 return s 1905 } 1906 1907 // The MedicalTranscriptEvent is and event in the MedicalTranscriptResultStream group of events. 1908 func (s *MedicalTranscriptEvent) eventMedicalTranscriptResultStream() {} 1909 1910 // UnmarshalEvent unmarshals the EventStream Message into the MedicalTranscriptEvent value. 1911 // This method is only used internally within the SDK's EventStream handling. 1912 func (s *MedicalTranscriptEvent) UnmarshalEvent( 1913 payloadUnmarshaler protocol.PayloadUnmarshaler, 1914 msg eventstream.Message, 1915 ) error { 1916 if err := payloadUnmarshaler.UnmarshalPayload( 1917 bytes.NewReader(msg.Payload), s, 1918 ); err != nil { 1919 return err 1920 } 1921 return nil 1922 } 1923 1924 // MarshalEvent marshals the type into an stream event value. This method 1925 // should only used internally within the SDK's EventStream handling. 1926 func (s *MedicalTranscriptEvent) MarshalEvent(pm protocol.PayloadMarshaler) (msg eventstream.Message, err error) { 1927 msg.Headers.Set(eventstreamapi.MessageTypeHeader, eventstream.StringValue(eventstreamapi.EventMessageType)) 1928 var buf bytes.Buffer 1929 if err = pm.MarshalPayload(&buf, s); err != nil { 1930 return eventstream.Message{}, err 1931 } 1932 msg.Payload = buf.Bytes() 1933 return msg, err 1934 } 1935 1936 // MedicalTranscriptResultStreamEvent groups together all EventStream 1937 // events writes for MedicalTranscriptResultStream. 1938 // 1939 // These events are: 1940 // 1941 // * MedicalTranscriptEvent 1942 type MedicalTranscriptResultStreamEvent interface { 1943 eventMedicalTranscriptResultStream() 1944 eventstreamapi.Marshaler 1945 eventstreamapi.Unmarshaler 1946 } 1947 1948 // MedicalTranscriptResultStreamReader provides the interface for reading to the stream. The 1949 // default implementation for this interface will be MedicalTranscriptResultStream. 1950 // 1951 // The reader's Close method must allow multiple concurrent calls. 1952 // 1953 // These events are: 1954 // 1955 // * MedicalTranscriptEvent 1956 // * MedicalTranscriptResultStreamUnknownEvent 1957 type MedicalTranscriptResultStreamReader interface { 1958 // Returns a channel of events as they are read from the event stream. 1959 Events() <-chan MedicalTranscriptResultStreamEvent 1960 1961 // Close will stop the reader reading events from the stream. 1962 Close() error 1963 1964 // Returns any error that has occurred while reading from the event stream. 1965 Err() error 1966 } 1967 1968 type readMedicalTranscriptResultStream struct { 1969 eventReader *eventstreamapi.EventReader 1970 stream chan MedicalTranscriptResultStreamEvent 1971 err *eventstreamapi.OnceError 1972 1973 done chan struct{} 1974 closeOnce sync.Once 1975 } 1976 1977 func newReadMedicalTranscriptResultStream(eventReader *eventstreamapi.EventReader) *readMedicalTranscriptResultStream { 1978 r := &readMedicalTranscriptResultStream{ 1979 eventReader: eventReader, 1980 stream: make(chan MedicalTranscriptResultStreamEvent), 1981 done: make(chan struct{}), 1982 err: eventstreamapi.NewOnceError(), 1983 } 1984 go r.readEventStream() 1985 1986 return r 1987 } 1988 1989 // Close will close the underlying event stream reader. 1990 func (r *readMedicalTranscriptResultStream) Close() error { 1991 r.closeOnce.Do(r.safeClose) 1992 return r.Err() 1993 } 1994 1995 func (r *readMedicalTranscriptResultStream) ErrorSet() <-chan struct{} { 1996 return r.err.ErrorSet() 1997 } 1998 1999 func (r *readMedicalTranscriptResultStream) Closed() <-chan struct{} { 2000 return r.done 2001 } 2002 2003 func (r *readMedicalTranscriptResultStream) safeClose() { 2004 close(r.done) 2005 } 2006 2007 func (r *readMedicalTranscriptResultStream) Err() error { 2008 return r.err.Err() 2009 } 2010 2011 func (r *readMedicalTranscriptResultStream) Events() <-chan MedicalTranscriptResultStreamEvent { 2012 return r.stream 2013 } 2014 2015 func (r *readMedicalTranscriptResultStream) readEventStream() { 2016 defer r.Close() 2017 defer close(r.stream) 2018 2019 for { 2020 event, err := r.eventReader.ReadEvent() 2021 if err != nil { 2022 if err == io.EOF { 2023 return 2024 } 2025 select { 2026 case <-r.done: 2027 // If closed already ignore the error 2028 return 2029 default: 2030 } 2031 if _, ok := err.(*eventstreamapi.UnknownMessageTypeError); ok { 2032 continue 2033 } 2034 r.err.SetError(err) 2035 return 2036 } 2037 2038 select { 2039 case r.stream <- event.(MedicalTranscriptResultStreamEvent): 2040 case <-r.done: 2041 return 2042 } 2043 } 2044 } 2045 2046 type unmarshalerForMedicalTranscriptResultStreamEvent struct { 2047 metadata protocol.ResponseMetadata 2048 } 2049 2050 func (u unmarshalerForMedicalTranscriptResultStreamEvent) UnmarshalerForEventName(eventType string) (eventstreamapi.Unmarshaler, error) { 2051 switch eventType { 2052 case "TranscriptEvent": 2053 return &MedicalTranscriptEvent{}, nil 2054 case "BadRequestException": 2055 return newErrorBadRequestException(u.metadata).(eventstreamapi.Unmarshaler), nil 2056 case "ConflictException": 2057 return newErrorConflictException(u.metadata).(eventstreamapi.Unmarshaler), nil 2058 case "InternalFailureException": 2059 return newErrorInternalFailureException(u.metadata).(eventstreamapi.Unmarshaler), nil 2060 case "LimitExceededException": 2061 return newErrorLimitExceededException(u.metadata).(eventstreamapi.Unmarshaler), nil 2062 case "ServiceUnavailableException": 2063 return newErrorServiceUnavailableException(u.metadata).(eventstreamapi.Unmarshaler), nil 2064 default: 2065 return &MedicalTranscriptResultStreamUnknownEvent{Type: eventType}, nil 2066 } 2067 } 2068 2069 // MedicalTranscriptResultStreamUnknownEvent provides a failsafe event for the 2070 // MedicalTranscriptResultStream group of events when an unknown event is received. 2071 type MedicalTranscriptResultStreamUnknownEvent struct { 2072 Type string 2073 Message eventstream.Message 2074 } 2075 2076 // The MedicalTranscriptResultStreamUnknownEvent is and event in the MedicalTranscriptResultStream 2077 // group of events. 2078 func (s *MedicalTranscriptResultStreamUnknownEvent) eventMedicalTranscriptResultStream() {} 2079 2080 // MarshalEvent marshals the type into an stream event value. This method 2081 // should only used internally within the SDK's EventStream handling. 2082 func (e *MedicalTranscriptResultStreamUnknownEvent) MarshalEvent(pm protocol.PayloadMarshaler) ( 2083 msg eventstream.Message, err error, 2084 ) { 2085 return e.Message.Clone(), nil 2086 } 2087 2088 // UnmarshalEvent unmarshals the EventStream Message into the MedicalTranscriptResultStream value. 2089 // This method is only used internally within the SDK's EventStream handling. 2090 func (e *MedicalTranscriptResultStreamUnknownEvent) UnmarshalEvent( 2091 payloadUnmarshaler protocol.PayloadUnmarshaler, 2092 msg eventstream.Message, 2093 ) error { 2094 e.Message = msg.Clone() 2095 return nil 2096 } 2097 2098 // The result of transcribing a portion of the input audio stream. 2099 type Result struct { 2100 _ struct{} `type:"structure"` 2101 2102 // A list of possible transcriptions for the audio. Each alternative typically 2103 // contains one item that contains the result of the transcription. 2104 Alternatives []*Alternative `type:"list"` 2105 2106 // When channel identification is enabled, Amazon Transcribe transcribes the 2107 // speech from each audio channel separately. 2108 // 2109 // You can use ChannelId to retrieve the transcription results for a single 2110 // channel in your audio stream. 2111 ChannelId *string `type:"string"` 2112 2113 // The offset in seconds from the beginning of the audio stream to the end of 2114 // the result. 2115 EndTime *float64 `type:"double"` 2116 2117 // Amazon Transcribe divides the incoming audio stream into segments at natural 2118 // points in the audio. Transcription results are returned based on these segments. 2119 // 2120 // The IsPartial field is true to indicate that Amazon Transcribe has additional 2121 // transcription data to send, false to indicate that this is the last transcription 2122 // result for the segment. 2123 IsPartial *bool `type:"boolean"` 2124 2125 // A unique identifier for the result. 2126 ResultId *string `type:"string"` 2127 2128 // The offset in seconds from the beginning of the audio stream to the beginning 2129 // of the result. 2130 StartTime *float64 `type:"double"` 2131 } 2132 2133 // String returns the string representation. 2134 // 2135 // API parameter values that are decorated as "sensitive" in the API will not 2136 // be included in the string output. The member name will be present, but the 2137 // value will be replaced with "sensitive". 2138 func (s Result) String() string { 2139 return awsutil.Prettify(s) 2140 } 2141 2142 // GoString returns the string representation. 2143 // 2144 // API parameter values that are decorated as "sensitive" in the API will not 2145 // be included in the string output. The member name will be present, but the 2146 // value will be replaced with "sensitive". 2147 func (s Result) GoString() string { 2148 return s.String() 2149 } 2150 2151 // SetAlternatives sets the Alternatives field's value. 2152 func (s *Result) SetAlternatives(v []*Alternative) *Result { 2153 s.Alternatives = v 2154 return s 2155 } 2156 2157 // SetChannelId sets the ChannelId field's value. 2158 func (s *Result) SetChannelId(v string) *Result { 2159 s.ChannelId = &v 2160 return s 2161 } 2162 2163 // SetEndTime sets the EndTime field's value. 2164 func (s *Result) SetEndTime(v float64) *Result { 2165 s.EndTime = &v 2166 return s 2167 } 2168 2169 // SetIsPartial sets the IsPartial field's value. 2170 func (s *Result) SetIsPartial(v bool) *Result { 2171 s.IsPartial = &v 2172 return s 2173 } 2174 2175 // SetResultId sets the ResultId field's value. 2176 func (s *Result) SetResultId(v string) *Result { 2177 s.ResultId = &v 2178 return s 2179 } 2180 2181 // SetStartTime sets the StartTime field's value. 2182 func (s *Result) SetStartTime(v float64) *Result { 2183 s.StartTime = &v 2184 return s 2185 } 2186 2187 // Service is currently unavailable. Try your request later. 2188 type ServiceUnavailableException struct { 2189 _ struct{} `type:"structure"` 2190 RespMetadata protocol.ResponseMetadata `json:"-" xml:"-"` 2191 2192 Message_ *string `locationName:"Message" type:"string"` 2193 } 2194 2195 // String returns the string representation. 2196 // 2197 // API parameter values that are decorated as "sensitive" in the API will not 2198 // be included in the string output. The member name will be present, but the 2199 // value will be replaced with "sensitive". 2200 func (s ServiceUnavailableException) String() string { 2201 return awsutil.Prettify(s) 2202 } 2203 2204 // GoString returns the string representation. 2205 // 2206 // API parameter values that are decorated as "sensitive" in the API will not 2207 // be included in the string output. The member name will be present, but the 2208 // value will be replaced with "sensitive". 2209 func (s ServiceUnavailableException) GoString() string { 2210 return s.String() 2211 } 2212 2213 // The ServiceUnavailableException is and event in the MedicalTranscriptResultStream group of events. 2214 func (s *ServiceUnavailableException) eventMedicalTranscriptResultStream() {} 2215 2216 // The ServiceUnavailableException is and event in the TranscriptResultStream group of events. 2217 func (s *ServiceUnavailableException) eventTranscriptResultStream() {} 2218 2219 // UnmarshalEvent unmarshals the EventStream Message into the ServiceUnavailableException value. 2220 // This method is only used internally within the SDK's EventStream handling. 2221 func (s *ServiceUnavailableException) UnmarshalEvent( 2222 payloadUnmarshaler protocol.PayloadUnmarshaler, 2223 msg eventstream.Message, 2224 ) error { 2225 if err := payloadUnmarshaler.UnmarshalPayload( 2226 bytes.NewReader(msg.Payload), s, 2227 ); err != nil { 2228 return err 2229 } 2230 return nil 2231 } 2232 2233 // MarshalEvent marshals the type into an stream event value. This method 2234 // should only used internally within the SDK's EventStream handling. 2235 func (s *ServiceUnavailableException) MarshalEvent(pm protocol.PayloadMarshaler) (msg eventstream.Message, err error) { 2236 msg.Headers.Set(eventstreamapi.MessageTypeHeader, eventstream.StringValue(eventstreamapi.ExceptionMessageType)) 2237 var buf bytes.Buffer 2238 if err = pm.MarshalPayload(&buf, s); err != nil { 2239 return eventstream.Message{}, err 2240 } 2241 msg.Payload = buf.Bytes() 2242 return msg, err 2243 } 2244 2245 func newErrorServiceUnavailableException(v protocol.ResponseMetadata) error { 2246 return &ServiceUnavailableException{ 2247 RespMetadata: v, 2248 } 2249 } 2250 2251 // Code returns the exception type name. 2252 func (s *ServiceUnavailableException) Code() string { 2253 return "ServiceUnavailableException" 2254 } 2255 2256 // Message returns the exception's message. 2257 func (s *ServiceUnavailableException) Message() string { 2258 if s.Message_ != nil { 2259 return *s.Message_ 2260 } 2261 return "" 2262 } 2263 2264 // OrigErr always returns nil, satisfies awserr.Error interface. 2265 func (s *ServiceUnavailableException) OrigErr() error { 2266 return nil 2267 } 2268 2269 func (s *ServiceUnavailableException) Error() string { 2270 return fmt.Sprintf("%s: %s", s.Code(), s.Message()) 2271 } 2272 2273 // Status code returns the HTTP status code for the request's response error. 2274 func (s *ServiceUnavailableException) StatusCode() int { 2275 return s.RespMetadata.StatusCode 2276 } 2277 2278 // RequestID returns the service's response RequestID for request. 2279 func (s *ServiceUnavailableException) RequestID() string { 2280 return s.RespMetadata.RequestID 2281 } 2282 2283 type StartMedicalStreamTranscriptionInput struct { 2284 _ struct{} `type:"structure" payload:"AudioStream"` 2285 2286 // Set this field to PHI to identify personal health information in the transcription 2287 // output. 2288 ContentIdentificationType *string `location:"header" locationName:"x-amzn-transcribe-content-identification-type" type:"string" enum:"MedicalContentIdentificationType"` 2289 2290 // When true, instructs Amazon Transcribe Medical to process each audio channel 2291 // separately and then merge the transcription output of each channel into a 2292 // single transcription. 2293 // 2294 // Amazon Transcribe Medical also produces a transcription of each item. An 2295 // item includes the start time, end time, and any alternative transcriptions. 2296 // 2297 // You can't set both ShowSpeakerLabel and EnableChannelIdentification in the 2298 // same request. If you set both, your request returns a BadRequestException. 2299 EnableChannelIdentification *bool `location:"header" locationName:"x-amzn-transcribe-enable-channel-identification" type:"boolean"` 2300 2301 // Indicates the source language used in the input audio stream. For Amazon 2302 // Transcribe Medical, this is US English (en-US). 2303 // 2304 // LanguageCode is a required field 2305 LanguageCode *string `location:"header" locationName:"x-amzn-transcribe-language-code" type:"string" required:"true" enum:"LanguageCode"` 2306 2307 // The encoding used for the input audio. 2308 // 2309 // MediaEncoding is a required field 2310 MediaEncoding *string `location:"header" locationName:"x-amzn-transcribe-media-encoding" type:"string" required:"true" enum:"MediaEncoding"` 2311 2312 // The sample rate of the input audio in Hertz. 2313 // 2314 // MediaSampleRateHertz is a required field 2315 MediaSampleRateHertz *int64 `location:"header" locationName:"x-amzn-transcribe-sample-rate" min:"8000" type:"integer" required:"true"` 2316 2317 // The number of channels that are in your audio stream. 2318 NumberOfChannels *int64 `location:"header" locationName:"x-amzn-transcribe-number-of-channels" min:"2" type:"integer"` 2319 2320 // Optional. An identifier for the transcription session. If you don't provide 2321 // a session ID, Amazon Transcribe generates one for you and returns it in the 2322 // response. 2323 SessionId *string `location:"header" locationName:"x-amzn-transcribe-session-id" min:"36" type:"string"` 2324 2325 // When true, enables speaker identification in your real-time stream. 2326 ShowSpeakerLabel *bool `location:"header" locationName:"x-amzn-transcribe-show-speaker-label" type:"boolean"` 2327 2328 // The medical specialty of the clinician or provider. 2329 // 2330 // Specialty is a required field 2331 Specialty *string `location:"header" locationName:"x-amzn-transcribe-specialty" type:"string" required:"true" enum:"Specialty"` 2332 2333 // The type of input audio. Choose DICTATION for a provider dictating patient 2334 // notes. Choose CONVERSATION for a dialogue between a patient and one or more 2335 // medical professionanls. 2336 // 2337 // Type is a required field 2338 Type *string `location:"header" locationName:"x-amzn-transcribe-type" type:"string" required:"true" enum:"Type"` 2339 2340 // The name of the medical custom vocabulary to use when processing the real-time 2341 // stream. 2342 VocabularyName *string `location:"header" locationName:"x-amzn-transcribe-vocabulary-name" min:"1" type:"string"` 2343 } 2344 2345 // String returns the string representation. 2346 // 2347 // API parameter values that are decorated as "sensitive" in the API will not 2348 // be included in the string output. The member name will be present, but the 2349 // value will be replaced with "sensitive". 2350 func (s StartMedicalStreamTranscriptionInput) String() string { 2351 return awsutil.Prettify(s) 2352 } 2353 2354 // GoString returns the string representation. 2355 // 2356 // API parameter values that are decorated as "sensitive" in the API will not 2357 // be included in the string output. The member name will be present, but the 2358 // value will be replaced with "sensitive". 2359 func (s StartMedicalStreamTranscriptionInput) GoString() string { 2360 return s.String() 2361 } 2362 2363 // Validate inspects the fields of the type to determine if they are valid. 2364 func (s *StartMedicalStreamTranscriptionInput) Validate() error { 2365 invalidParams := request.ErrInvalidParams{Context: "StartMedicalStreamTranscriptionInput"} 2366 if s.LanguageCode == nil { 2367 invalidParams.Add(request.NewErrParamRequired("LanguageCode")) 2368 } 2369 if s.MediaEncoding == nil { 2370 invalidParams.Add(request.NewErrParamRequired("MediaEncoding")) 2371 } 2372 if s.MediaSampleRateHertz == nil { 2373 invalidParams.Add(request.NewErrParamRequired("MediaSampleRateHertz")) 2374 } 2375 if s.MediaSampleRateHertz != nil && *s.MediaSampleRateHertz < 8000 { 2376 invalidParams.Add(request.NewErrParamMinValue("MediaSampleRateHertz", 8000)) 2377 } 2378 if s.NumberOfChannels != nil && *s.NumberOfChannels < 2 { 2379 invalidParams.Add(request.NewErrParamMinValue("NumberOfChannels", 2)) 2380 } 2381 if s.SessionId != nil && len(*s.SessionId) < 36 { 2382 invalidParams.Add(request.NewErrParamMinLen("SessionId", 36)) 2383 } 2384 if s.Specialty == nil { 2385 invalidParams.Add(request.NewErrParamRequired("Specialty")) 2386 } 2387 if s.Type == nil { 2388 invalidParams.Add(request.NewErrParamRequired("Type")) 2389 } 2390 if s.VocabularyName != nil && len(*s.VocabularyName) < 1 { 2391 invalidParams.Add(request.NewErrParamMinLen("VocabularyName", 1)) 2392 } 2393 2394 if invalidParams.Len() > 0 { 2395 return invalidParams 2396 } 2397 return nil 2398 } 2399 2400 // SetContentIdentificationType sets the ContentIdentificationType field's value. 2401 func (s *StartMedicalStreamTranscriptionInput) SetContentIdentificationType(v string) *StartMedicalStreamTranscriptionInput { 2402 s.ContentIdentificationType = &v 2403 return s 2404 } 2405 2406 // SetEnableChannelIdentification sets the EnableChannelIdentification field's value. 2407 func (s *StartMedicalStreamTranscriptionInput) SetEnableChannelIdentification(v bool) *StartMedicalStreamTranscriptionInput { 2408 s.EnableChannelIdentification = &v 2409 return s 2410 } 2411 2412 // SetLanguageCode sets the LanguageCode field's value. 2413 func (s *StartMedicalStreamTranscriptionInput) SetLanguageCode(v string) *StartMedicalStreamTranscriptionInput { 2414 s.LanguageCode = &v 2415 return s 2416 } 2417 2418 // SetMediaEncoding sets the MediaEncoding field's value. 2419 func (s *StartMedicalStreamTranscriptionInput) SetMediaEncoding(v string) *StartMedicalStreamTranscriptionInput { 2420 s.MediaEncoding = &v 2421 return s 2422 } 2423 2424 // SetMediaSampleRateHertz sets the MediaSampleRateHertz field's value. 2425 func (s *StartMedicalStreamTranscriptionInput) SetMediaSampleRateHertz(v int64) *StartMedicalStreamTranscriptionInput { 2426 s.MediaSampleRateHertz = &v 2427 return s 2428 } 2429 2430 // SetNumberOfChannels sets the NumberOfChannels field's value. 2431 func (s *StartMedicalStreamTranscriptionInput) SetNumberOfChannels(v int64) *StartMedicalStreamTranscriptionInput { 2432 s.NumberOfChannels = &v 2433 return s 2434 } 2435 2436 // SetSessionId sets the SessionId field's value. 2437 func (s *StartMedicalStreamTranscriptionInput) SetSessionId(v string) *StartMedicalStreamTranscriptionInput { 2438 s.SessionId = &v 2439 return s 2440 } 2441 2442 // SetShowSpeakerLabel sets the ShowSpeakerLabel field's value. 2443 func (s *StartMedicalStreamTranscriptionInput) SetShowSpeakerLabel(v bool) *StartMedicalStreamTranscriptionInput { 2444 s.ShowSpeakerLabel = &v 2445 return s 2446 } 2447 2448 // SetSpecialty sets the Specialty field's value. 2449 func (s *StartMedicalStreamTranscriptionInput) SetSpecialty(v string) *StartMedicalStreamTranscriptionInput { 2450 s.Specialty = &v 2451 return s 2452 } 2453 2454 // SetType sets the Type field's value. 2455 func (s *StartMedicalStreamTranscriptionInput) SetType(v string) *StartMedicalStreamTranscriptionInput { 2456 s.Type = &v 2457 return s 2458 } 2459 2460 // SetVocabularyName sets the VocabularyName field's value. 2461 func (s *StartMedicalStreamTranscriptionInput) SetVocabularyName(v string) *StartMedicalStreamTranscriptionInput { 2462 s.VocabularyName = &v 2463 return s 2464 } 2465 2466 type StartMedicalStreamTranscriptionOutput struct { 2467 _ struct{} `type:"structure" payload:"TranscriptResultStream"` 2468 2469 eventStream *StartMedicalStreamTranscriptionEventStream 2470 2471 // If the value is PHI, indicates that you've configured your stream to identify 2472 // personal health information. 2473 ContentIdentificationType *string `location:"header" locationName:"x-amzn-transcribe-content-identification-type" type:"string" enum:"MedicalContentIdentificationType"` 2474 2475 // Shows whether channel identification has been enabled in the stream. 2476 EnableChannelIdentification *bool `location:"header" locationName:"x-amzn-transcribe-enable-channel-identification" type:"boolean"` 2477 2478 // The language code for the response transcript. For Amazon Transcribe Medical, 2479 // this is US English (en-US). 2480 LanguageCode *string `location:"header" locationName:"x-amzn-transcribe-language-code" type:"string" enum:"LanguageCode"` 2481 2482 // The encoding used for the input audio stream. 2483 MediaEncoding *string `location:"header" locationName:"x-amzn-transcribe-media-encoding" type:"string" enum:"MediaEncoding"` 2484 2485 // The sample rate of the input audio in Hertz. 2486 MediaSampleRateHertz *int64 `location:"header" locationName:"x-amzn-transcribe-sample-rate" min:"8000" type:"integer"` 2487 2488 // The number of channels identified in the stream. 2489 NumberOfChannels *int64 `location:"header" locationName:"x-amzn-transcribe-number-of-channels" min:"2" type:"integer"` 2490 2491 // An identifier for the streaming transcription. 2492 RequestId *string `location:"header" locationName:"x-amzn-request-id" type:"string"` 2493 2494 // Optional. An identifier for the transcription session. If you don't provide 2495 // a session ID, Amazon Transcribe generates one for you and returns it in the 2496 // response. 2497 SessionId *string `location:"header" locationName:"x-amzn-transcribe-session-id" min:"36" type:"string"` 2498 2499 // Shows whether speaker identification was enabled in the stream. 2500 ShowSpeakerLabel *bool `location:"header" locationName:"x-amzn-transcribe-show-speaker-label" type:"boolean"` 2501 2502 // The specialty in the medical domain. 2503 Specialty *string `location:"header" locationName:"x-amzn-transcribe-specialty" type:"string" enum:"Specialty"` 2504 2505 // The type of audio that was transcribed. 2506 Type *string `location:"header" locationName:"x-amzn-transcribe-type" type:"string" enum:"Type"` 2507 2508 // The name of the vocabulary used when processing the stream. 2509 VocabularyName *string `location:"header" locationName:"x-amzn-transcribe-vocabulary-name" min:"1" type:"string"` 2510 } 2511 2512 // String returns the string representation. 2513 // 2514 // API parameter values that are decorated as "sensitive" in the API will not 2515 // be included in the string output. The member name will be present, but the 2516 // value will be replaced with "sensitive". 2517 func (s StartMedicalStreamTranscriptionOutput) String() string { 2518 return awsutil.Prettify(s) 2519 } 2520 2521 // GoString returns the string representation. 2522 // 2523 // API parameter values that are decorated as "sensitive" in the API will not 2524 // be included in the string output. The member name will be present, but the 2525 // value will be replaced with "sensitive". 2526 func (s StartMedicalStreamTranscriptionOutput) GoString() string { 2527 return s.String() 2528 } 2529 2530 // SetContentIdentificationType sets the ContentIdentificationType field's value. 2531 func (s *StartMedicalStreamTranscriptionOutput) SetContentIdentificationType(v string) *StartMedicalStreamTranscriptionOutput { 2532 s.ContentIdentificationType = &v 2533 return s 2534 } 2535 2536 // SetEnableChannelIdentification sets the EnableChannelIdentification field's value. 2537 func (s *StartMedicalStreamTranscriptionOutput) SetEnableChannelIdentification(v bool) *StartMedicalStreamTranscriptionOutput { 2538 s.EnableChannelIdentification = &v 2539 return s 2540 } 2541 2542 // SetLanguageCode sets the LanguageCode field's value. 2543 func (s *StartMedicalStreamTranscriptionOutput) SetLanguageCode(v string) *StartMedicalStreamTranscriptionOutput { 2544 s.LanguageCode = &v 2545 return s 2546 } 2547 2548 // SetMediaEncoding sets the MediaEncoding field's value. 2549 func (s *StartMedicalStreamTranscriptionOutput) SetMediaEncoding(v string) *StartMedicalStreamTranscriptionOutput { 2550 s.MediaEncoding = &v 2551 return s 2552 } 2553 2554 // SetMediaSampleRateHertz sets the MediaSampleRateHertz field's value. 2555 func (s *StartMedicalStreamTranscriptionOutput) SetMediaSampleRateHertz(v int64) *StartMedicalStreamTranscriptionOutput { 2556 s.MediaSampleRateHertz = &v 2557 return s 2558 } 2559 2560 // SetNumberOfChannels sets the NumberOfChannels field's value. 2561 func (s *StartMedicalStreamTranscriptionOutput) SetNumberOfChannels(v int64) *StartMedicalStreamTranscriptionOutput { 2562 s.NumberOfChannels = &v 2563 return s 2564 } 2565 2566 // SetRequestId sets the RequestId field's value. 2567 func (s *StartMedicalStreamTranscriptionOutput) SetRequestId(v string) *StartMedicalStreamTranscriptionOutput { 2568 s.RequestId = &v 2569 return s 2570 } 2571 2572 // SetSessionId sets the SessionId field's value. 2573 func (s *StartMedicalStreamTranscriptionOutput) SetSessionId(v string) *StartMedicalStreamTranscriptionOutput { 2574 s.SessionId = &v 2575 return s 2576 } 2577 2578 // SetShowSpeakerLabel sets the ShowSpeakerLabel field's value. 2579 func (s *StartMedicalStreamTranscriptionOutput) SetShowSpeakerLabel(v bool) *StartMedicalStreamTranscriptionOutput { 2580 s.ShowSpeakerLabel = &v 2581 return s 2582 } 2583 2584 // SetSpecialty sets the Specialty field's value. 2585 func (s *StartMedicalStreamTranscriptionOutput) SetSpecialty(v string) *StartMedicalStreamTranscriptionOutput { 2586 s.Specialty = &v 2587 return s 2588 } 2589 2590 // SetType sets the Type field's value. 2591 func (s *StartMedicalStreamTranscriptionOutput) SetType(v string) *StartMedicalStreamTranscriptionOutput { 2592 s.Type = &v 2593 return s 2594 } 2595 2596 // SetVocabularyName sets the VocabularyName field's value. 2597 func (s *StartMedicalStreamTranscriptionOutput) SetVocabularyName(v string) *StartMedicalStreamTranscriptionOutput { 2598 s.VocabularyName = &v 2599 return s 2600 } 2601 2602 // GetStream returns the type to interact with the event stream. 2603 func (s *StartMedicalStreamTranscriptionOutput) GetStream() *StartMedicalStreamTranscriptionEventStream { 2604 return s.eventStream 2605 } 2606 2607 type StartStreamTranscriptionInput struct { 2608 _ struct{} `type:"structure" payload:"AudioStream"` 2609 2610 // Set this field to PII to identify personally identifiable information (PII) 2611 // in the transcription output. Content identification is performed only upon 2612 // complete transcription of the audio segments. 2613 // 2614 // You can’t set both ContentIdentificationType and ContentRedactionType in 2615 // the same request. If you set both, your request returns a BadRequestException. 2616 ContentIdentificationType *string `location:"header" locationName:"x-amzn-transcribe-content-identification-type" type:"string" enum:"ContentIdentificationType"` 2617 2618 // Set this field to PII to redact personally identifiable information (PII) 2619 // in the transcription output. Content redaction is performed only upon complete 2620 // transcription of the audio segments. 2621 // 2622 // You can’t set both ContentRedactionType and ContentIdentificationType in 2623 // the same request. If you set both, your request returns a BadRequestException. 2624 ContentRedactionType *string `location:"header" locationName:"x-amzn-transcribe-content-redaction-type" type:"string" enum:"ContentRedactionType"` 2625 2626 // When true, instructs Amazon Transcribe to process each audio channel separately 2627 // and then merge the transcription output of each channel into a single transcription. 2628 // 2629 // Amazon Transcribe also produces a transcription of each item. An item includes 2630 // the start time, end time, and any alternative transcriptions. 2631 // 2632 // You can't set both ShowSpeakerLabel and EnableChannelIdentification in the 2633 // same request. If you set both, your request returns a BadRequestException. 2634 EnableChannelIdentification *bool `location:"header" locationName:"x-amzn-transcribe-enable-channel-identification" type:"boolean"` 2635 2636 // When true, instructs Amazon Transcribe to present transcription results that 2637 // have the partial results stabilized. Normally, any word or phrase from one 2638 // partial result can change in a subsequent partial result. With partial results 2639 // stabilization enabled, only the last few words of one partial result can 2640 // change in another partial result. 2641 EnablePartialResultsStabilization *bool `location:"header" locationName:"x-amzn-transcribe-enable-partial-results-stabilization" type:"boolean"` 2642 2643 // Indicates the source language used in the input audio stream. 2644 // 2645 // LanguageCode is a required field 2646 LanguageCode *string `location:"header" locationName:"x-amzn-transcribe-language-code" type:"string" required:"true" enum:"LanguageCode"` 2647 2648 // The encoding used for the input audio. 2649 // 2650 // MediaEncoding is a required field 2651 MediaEncoding *string `location:"header" locationName:"x-amzn-transcribe-media-encoding" type:"string" required:"true" enum:"MediaEncoding"` 2652 2653 // The sample rate, in Hertz, of the input audio. We suggest that you use 8,000 2654 // Hz for low quality audio and 16,000 Hz for high quality audio. 2655 // 2656 // MediaSampleRateHertz is a required field 2657 MediaSampleRateHertz *int64 `location:"header" locationName:"x-amzn-transcribe-sample-rate" min:"8000" type:"integer" required:"true"` 2658 2659 // The number of channels that are in your audio stream. 2660 NumberOfChannels *int64 `location:"header" locationName:"x-amzn-transcribe-number-of-channels" min:"2" type:"integer"` 2661 2662 // You can use this field to set the stability level of the transcription results. 2663 // A higher stability level means that the transcription results are less likely 2664 // to change. Higher stability levels can come with lower overall transcription 2665 // accuracy. 2666 PartialResultsStability *string `location:"header" locationName:"x-amzn-transcribe-partial-results-stability" type:"string" enum:"PartialResultsStability"` 2667 2668 // List the PII entity types you want to identify or redact. In order to specify 2669 // entity types, you must have either ContentIdentificationType or ContentRedactionType 2670 // enabled. 2671 // 2672 // PIIEntityTypes must be comma-separated; the available values are: BANK_ACCOUNT_NUMBER, 2673 // BANK_ROUTING, CREDIT_DEBIT_NUMBER, CREDIT_DEBIT_CVV, CREDIT_DEBIT_EXPIRY, 2674 // PIN, EMAIL, ADDRESS, NAME, PHONE, SSN, and ALL. 2675 // 2676 // PiiEntityTypes is an optional parameter with a default value of ALL. 2677 PiiEntityTypes *string `location:"header" locationName:"x-amzn-transcribe-pii-entity-types" min:"1" type:"string"` 2678 2679 // A identifier for the transcription session. Use this parameter when you want 2680 // to retry a session. If you don't provide a session ID, Amazon Transcribe 2681 // will generate one for you and return it in the response. 2682 SessionId *string `location:"header" locationName:"x-amzn-transcribe-session-id" min:"36" type:"string"` 2683 2684 // When true, enables speaker identification in your real-time stream. 2685 ShowSpeakerLabel *bool `location:"header" locationName:"x-amzn-transcribe-show-speaker-label" type:"boolean"` 2686 2687 // The manner in which you use your vocabulary filter to filter words in your 2688 // transcript. Remove removes filtered words from your transcription results. 2689 // Mask masks filtered words with a *** in your transcription results. Tag keeps 2690 // the filtered words in your transcription results and tags them. The tag appears 2691 // as VocabularyFilterMatch equal to True 2692 VocabularyFilterMethod *string `location:"header" locationName:"x-amzn-transcribe-vocabulary-filter-method" type:"string" enum:"VocabularyFilterMethod"` 2693 2694 // The name of the vocabulary filter you've created that is unique to your account. 2695 // Provide the name in this field to successfully use it in a stream. 2696 VocabularyFilterName *string `location:"header" locationName:"x-amzn-transcribe-vocabulary-filter-name" min:"1" type:"string"` 2697 2698 // The name of the vocabulary to use when processing the transcription job. 2699 VocabularyName *string `location:"header" locationName:"x-amzn-transcribe-vocabulary-name" min:"1" type:"string"` 2700 } 2701 2702 // String returns the string representation. 2703 // 2704 // API parameter values that are decorated as "sensitive" in the API will not 2705 // be included in the string output. The member name will be present, but the 2706 // value will be replaced with "sensitive". 2707 func (s StartStreamTranscriptionInput) String() string { 2708 return awsutil.Prettify(s) 2709 } 2710 2711 // GoString returns the string representation. 2712 // 2713 // API parameter values that are decorated as "sensitive" in the API will not 2714 // be included in the string output. The member name will be present, but the 2715 // value will be replaced with "sensitive". 2716 func (s StartStreamTranscriptionInput) GoString() string { 2717 return s.String() 2718 } 2719 2720 // Validate inspects the fields of the type to determine if they are valid. 2721 func (s *StartStreamTranscriptionInput) Validate() error { 2722 invalidParams := request.ErrInvalidParams{Context: "StartStreamTranscriptionInput"} 2723 if s.LanguageCode == nil { 2724 invalidParams.Add(request.NewErrParamRequired("LanguageCode")) 2725 } 2726 if s.MediaEncoding == nil { 2727 invalidParams.Add(request.NewErrParamRequired("MediaEncoding")) 2728 } 2729 if s.MediaSampleRateHertz == nil { 2730 invalidParams.Add(request.NewErrParamRequired("MediaSampleRateHertz")) 2731 } 2732 if s.MediaSampleRateHertz != nil && *s.MediaSampleRateHertz < 8000 { 2733 invalidParams.Add(request.NewErrParamMinValue("MediaSampleRateHertz", 8000)) 2734 } 2735 if s.NumberOfChannels != nil && *s.NumberOfChannels < 2 { 2736 invalidParams.Add(request.NewErrParamMinValue("NumberOfChannels", 2)) 2737 } 2738 if s.PiiEntityTypes != nil && len(*s.PiiEntityTypes) < 1 { 2739 invalidParams.Add(request.NewErrParamMinLen("PiiEntityTypes", 1)) 2740 } 2741 if s.SessionId != nil && len(*s.SessionId) < 36 { 2742 invalidParams.Add(request.NewErrParamMinLen("SessionId", 36)) 2743 } 2744 if s.VocabularyFilterName != nil && len(*s.VocabularyFilterName) < 1 { 2745 invalidParams.Add(request.NewErrParamMinLen("VocabularyFilterName", 1)) 2746 } 2747 if s.VocabularyName != nil && len(*s.VocabularyName) < 1 { 2748 invalidParams.Add(request.NewErrParamMinLen("VocabularyName", 1)) 2749 } 2750 2751 if invalidParams.Len() > 0 { 2752 return invalidParams 2753 } 2754 return nil 2755 } 2756 2757 // SetContentIdentificationType sets the ContentIdentificationType field's value. 2758 func (s *StartStreamTranscriptionInput) SetContentIdentificationType(v string) *StartStreamTranscriptionInput { 2759 s.ContentIdentificationType = &v 2760 return s 2761 } 2762 2763 // SetContentRedactionType sets the ContentRedactionType field's value. 2764 func (s *StartStreamTranscriptionInput) SetContentRedactionType(v string) *StartStreamTranscriptionInput { 2765 s.ContentRedactionType = &v 2766 return s 2767 } 2768 2769 // SetEnableChannelIdentification sets the EnableChannelIdentification field's value. 2770 func (s *StartStreamTranscriptionInput) SetEnableChannelIdentification(v bool) *StartStreamTranscriptionInput { 2771 s.EnableChannelIdentification = &v 2772 return s 2773 } 2774 2775 // SetEnablePartialResultsStabilization sets the EnablePartialResultsStabilization field's value. 2776 func (s *StartStreamTranscriptionInput) SetEnablePartialResultsStabilization(v bool) *StartStreamTranscriptionInput { 2777 s.EnablePartialResultsStabilization = &v 2778 return s 2779 } 2780 2781 // SetLanguageCode sets the LanguageCode field's value. 2782 func (s *StartStreamTranscriptionInput) SetLanguageCode(v string) *StartStreamTranscriptionInput { 2783 s.LanguageCode = &v 2784 return s 2785 } 2786 2787 // SetMediaEncoding sets the MediaEncoding field's value. 2788 func (s *StartStreamTranscriptionInput) SetMediaEncoding(v string) *StartStreamTranscriptionInput { 2789 s.MediaEncoding = &v 2790 return s 2791 } 2792 2793 // SetMediaSampleRateHertz sets the MediaSampleRateHertz field's value. 2794 func (s *StartStreamTranscriptionInput) SetMediaSampleRateHertz(v int64) *StartStreamTranscriptionInput { 2795 s.MediaSampleRateHertz = &v 2796 return s 2797 } 2798 2799 // SetNumberOfChannels sets the NumberOfChannels field's value. 2800 func (s *StartStreamTranscriptionInput) SetNumberOfChannels(v int64) *StartStreamTranscriptionInput { 2801 s.NumberOfChannels = &v 2802 return s 2803 } 2804 2805 // SetPartialResultsStability sets the PartialResultsStability field's value. 2806 func (s *StartStreamTranscriptionInput) SetPartialResultsStability(v string) *StartStreamTranscriptionInput { 2807 s.PartialResultsStability = &v 2808 return s 2809 } 2810 2811 // SetPiiEntityTypes sets the PiiEntityTypes field's value. 2812 func (s *StartStreamTranscriptionInput) SetPiiEntityTypes(v string) *StartStreamTranscriptionInput { 2813 s.PiiEntityTypes = &v 2814 return s 2815 } 2816 2817 // SetSessionId sets the SessionId field's value. 2818 func (s *StartStreamTranscriptionInput) SetSessionId(v string) *StartStreamTranscriptionInput { 2819 s.SessionId = &v 2820 return s 2821 } 2822 2823 // SetShowSpeakerLabel sets the ShowSpeakerLabel field's value. 2824 func (s *StartStreamTranscriptionInput) SetShowSpeakerLabel(v bool) *StartStreamTranscriptionInput { 2825 s.ShowSpeakerLabel = &v 2826 return s 2827 } 2828 2829 // SetVocabularyFilterMethod sets the VocabularyFilterMethod field's value. 2830 func (s *StartStreamTranscriptionInput) SetVocabularyFilterMethod(v string) *StartStreamTranscriptionInput { 2831 s.VocabularyFilterMethod = &v 2832 return s 2833 } 2834 2835 // SetVocabularyFilterName sets the VocabularyFilterName field's value. 2836 func (s *StartStreamTranscriptionInput) SetVocabularyFilterName(v string) *StartStreamTranscriptionInput { 2837 s.VocabularyFilterName = &v 2838 return s 2839 } 2840 2841 // SetVocabularyName sets the VocabularyName field's value. 2842 func (s *StartStreamTranscriptionInput) SetVocabularyName(v string) *StartStreamTranscriptionInput { 2843 s.VocabularyName = &v 2844 return s 2845 } 2846 2847 type StartStreamTranscriptionOutput struct { 2848 _ struct{} `type:"structure" payload:"TranscriptResultStream"` 2849 2850 eventStream *StartStreamTranscriptionEventStream 2851 2852 // Shows whether content identification was enabled in this stream. 2853 ContentIdentificationType *string `location:"header" locationName:"x-amzn-transcribe-content-identification-type" type:"string" enum:"ContentIdentificationType"` 2854 2855 // Shows whether content redaction was enabled in this stream. 2856 ContentRedactionType *string `location:"header" locationName:"x-amzn-transcribe-content-redaction-type" type:"string" enum:"ContentRedactionType"` 2857 2858 // Shows whether channel identification has been enabled in the stream. 2859 EnableChannelIdentification *bool `location:"header" locationName:"x-amzn-transcribe-enable-channel-identification" type:"boolean"` 2860 2861 // Shows whether partial results stabilization has been enabled in the stream. 2862 EnablePartialResultsStabilization *bool `location:"header" locationName:"x-amzn-transcribe-enable-partial-results-stabilization" type:"boolean"` 2863 2864 // The language code for the input audio stream. 2865 LanguageCode *string `location:"header" locationName:"x-amzn-transcribe-language-code" type:"string" enum:"LanguageCode"` 2866 2867 // The encoding used for the input audio stream. 2868 MediaEncoding *string `location:"header" locationName:"x-amzn-transcribe-media-encoding" type:"string" enum:"MediaEncoding"` 2869 2870 // The sample rate for the input audio stream. Use 8,000 Hz for low quality 2871 // audio and 16,000 Hz for high quality audio. 2872 MediaSampleRateHertz *int64 `location:"header" locationName:"x-amzn-transcribe-sample-rate" min:"8000" type:"integer"` 2873 2874 // The number of channels identified in the stream. 2875 NumberOfChannels *int64 `location:"header" locationName:"x-amzn-transcribe-number-of-channels" min:"2" type:"integer"` 2876 2877 // If partial results stabilization has been enabled in the stream, shows the 2878 // stability level. 2879 PartialResultsStability *string `location:"header" locationName:"x-amzn-transcribe-partial-results-stability" type:"string" enum:"PartialResultsStability"` 2880 2881 // Lists the PII entity types you specified in your request. 2882 PiiEntityTypes *string `location:"header" locationName:"x-amzn-transcribe-pii-entity-types" min:"1" type:"string"` 2883 2884 // An identifier for the streaming transcription. 2885 RequestId *string `location:"header" locationName:"x-amzn-request-id" type:"string"` 2886 2887 // An identifier for a specific transcription session. 2888 SessionId *string `location:"header" locationName:"x-amzn-transcribe-session-id" min:"36" type:"string"` 2889 2890 // Shows whether speaker identification was enabled in the stream. 2891 ShowSpeakerLabel *bool `location:"header" locationName:"x-amzn-transcribe-show-speaker-label" type:"boolean"` 2892 2893 // The vocabulary filtering method used in the real-time stream. 2894 VocabularyFilterMethod *string `location:"header" locationName:"x-amzn-transcribe-vocabulary-filter-method" type:"string" enum:"VocabularyFilterMethod"` 2895 2896 // The name of the vocabulary filter used in your real-time stream. 2897 VocabularyFilterName *string `location:"header" locationName:"x-amzn-transcribe-vocabulary-filter-name" min:"1" type:"string"` 2898 2899 // The name of the vocabulary used when processing the stream. 2900 VocabularyName *string `location:"header" locationName:"x-amzn-transcribe-vocabulary-name" min:"1" type:"string"` 2901 } 2902 2903 // String returns the string representation. 2904 // 2905 // API parameter values that are decorated as "sensitive" in the API will not 2906 // be included in the string output. The member name will be present, but the 2907 // value will be replaced with "sensitive". 2908 func (s StartStreamTranscriptionOutput) String() string { 2909 return awsutil.Prettify(s) 2910 } 2911 2912 // GoString returns the string representation. 2913 // 2914 // API parameter values that are decorated as "sensitive" in the API will not 2915 // be included in the string output. The member name will be present, but the 2916 // value will be replaced with "sensitive". 2917 func (s StartStreamTranscriptionOutput) GoString() string { 2918 return s.String() 2919 } 2920 2921 // SetContentIdentificationType sets the ContentIdentificationType field's value. 2922 func (s *StartStreamTranscriptionOutput) SetContentIdentificationType(v string) *StartStreamTranscriptionOutput { 2923 s.ContentIdentificationType = &v 2924 return s 2925 } 2926 2927 // SetContentRedactionType sets the ContentRedactionType field's value. 2928 func (s *StartStreamTranscriptionOutput) SetContentRedactionType(v string) *StartStreamTranscriptionOutput { 2929 s.ContentRedactionType = &v 2930 return s 2931 } 2932 2933 // SetEnableChannelIdentification sets the EnableChannelIdentification field's value. 2934 func (s *StartStreamTranscriptionOutput) SetEnableChannelIdentification(v bool) *StartStreamTranscriptionOutput { 2935 s.EnableChannelIdentification = &v 2936 return s 2937 } 2938 2939 // SetEnablePartialResultsStabilization sets the EnablePartialResultsStabilization field's value. 2940 func (s *StartStreamTranscriptionOutput) SetEnablePartialResultsStabilization(v bool) *StartStreamTranscriptionOutput { 2941 s.EnablePartialResultsStabilization = &v 2942 return s 2943 } 2944 2945 // SetLanguageCode sets the LanguageCode field's value. 2946 func (s *StartStreamTranscriptionOutput) SetLanguageCode(v string) *StartStreamTranscriptionOutput { 2947 s.LanguageCode = &v 2948 return s 2949 } 2950 2951 // SetMediaEncoding sets the MediaEncoding field's value. 2952 func (s *StartStreamTranscriptionOutput) SetMediaEncoding(v string) *StartStreamTranscriptionOutput { 2953 s.MediaEncoding = &v 2954 return s 2955 } 2956 2957 // SetMediaSampleRateHertz sets the MediaSampleRateHertz field's value. 2958 func (s *StartStreamTranscriptionOutput) SetMediaSampleRateHertz(v int64) *StartStreamTranscriptionOutput { 2959 s.MediaSampleRateHertz = &v 2960 return s 2961 } 2962 2963 // SetNumberOfChannels sets the NumberOfChannels field's value. 2964 func (s *StartStreamTranscriptionOutput) SetNumberOfChannels(v int64) *StartStreamTranscriptionOutput { 2965 s.NumberOfChannels = &v 2966 return s 2967 } 2968 2969 // SetPartialResultsStability sets the PartialResultsStability field's value. 2970 func (s *StartStreamTranscriptionOutput) SetPartialResultsStability(v string) *StartStreamTranscriptionOutput { 2971 s.PartialResultsStability = &v 2972 return s 2973 } 2974 2975 // SetPiiEntityTypes sets the PiiEntityTypes field's value. 2976 func (s *StartStreamTranscriptionOutput) SetPiiEntityTypes(v string) *StartStreamTranscriptionOutput { 2977 s.PiiEntityTypes = &v 2978 return s 2979 } 2980 2981 // SetRequestId sets the RequestId field's value. 2982 func (s *StartStreamTranscriptionOutput) SetRequestId(v string) *StartStreamTranscriptionOutput { 2983 s.RequestId = &v 2984 return s 2985 } 2986 2987 // SetSessionId sets the SessionId field's value. 2988 func (s *StartStreamTranscriptionOutput) SetSessionId(v string) *StartStreamTranscriptionOutput { 2989 s.SessionId = &v 2990 return s 2991 } 2992 2993 // SetShowSpeakerLabel sets the ShowSpeakerLabel field's value. 2994 func (s *StartStreamTranscriptionOutput) SetShowSpeakerLabel(v bool) *StartStreamTranscriptionOutput { 2995 s.ShowSpeakerLabel = &v 2996 return s 2997 } 2998 2999 // SetVocabularyFilterMethod sets the VocabularyFilterMethod field's value. 3000 func (s *StartStreamTranscriptionOutput) SetVocabularyFilterMethod(v string) *StartStreamTranscriptionOutput { 3001 s.VocabularyFilterMethod = &v 3002 return s 3003 } 3004 3005 // SetVocabularyFilterName sets the VocabularyFilterName field's value. 3006 func (s *StartStreamTranscriptionOutput) SetVocabularyFilterName(v string) *StartStreamTranscriptionOutput { 3007 s.VocabularyFilterName = &v 3008 return s 3009 } 3010 3011 // SetVocabularyName sets the VocabularyName field's value. 3012 func (s *StartStreamTranscriptionOutput) SetVocabularyName(v string) *StartStreamTranscriptionOutput { 3013 s.VocabularyName = &v 3014 return s 3015 } 3016 3017 // GetStream returns the type to interact with the event stream. 3018 func (s *StartStreamTranscriptionOutput) GetStream() *StartStreamTranscriptionEventStream { 3019 return s.eventStream 3020 } 3021 3022 // The transcription in a TranscriptEvent. 3023 type Transcript struct { 3024 _ struct{} `type:"structure"` 3025 3026 // Result objects that contain the results of transcribing a portion of the 3027 // input audio stream. The array can be empty. 3028 Results []*Result `type:"list"` 3029 } 3030 3031 // String returns the string representation. 3032 // 3033 // API parameter values that are decorated as "sensitive" in the API will not 3034 // be included in the string output. The member name will be present, but the 3035 // value will be replaced with "sensitive". 3036 func (s Transcript) String() string { 3037 return awsutil.Prettify(s) 3038 } 3039 3040 // GoString returns the string representation. 3041 // 3042 // API parameter values that are decorated as "sensitive" in the API will not 3043 // be included in the string output. The member name will be present, but the 3044 // value will be replaced with "sensitive". 3045 func (s Transcript) GoString() string { 3046 return s.String() 3047 } 3048 3049 // SetResults sets the Results field's value. 3050 func (s *Transcript) SetResults(v []*Result) *Transcript { 3051 s.Results = v 3052 return s 3053 } 3054 3055 // Represents a set of transcription results from the server to the client. 3056 // It contains one or more segments of the transcription. 3057 type TranscriptEvent struct { 3058 _ struct{} `type:"structure"` 3059 3060 // The transcription of the audio stream. The transcription is composed of all 3061 // of the items in the results list. 3062 Transcript *Transcript `type:"structure"` 3063 } 3064 3065 // String returns the string representation. 3066 // 3067 // API parameter values that are decorated as "sensitive" in the API will not 3068 // be included in the string output. The member name will be present, but the 3069 // value will be replaced with "sensitive". 3070 func (s TranscriptEvent) String() string { 3071 return awsutil.Prettify(s) 3072 } 3073 3074 // GoString returns the string representation. 3075 // 3076 // API parameter values that are decorated as "sensitive" in the API will not 3077 // be included in the string output. The member name will be present, but the 3078 // value will be replaced with "sensitive". 3079 func (s TranscriptEvent) GoString() string { 3080 return s.String() 3081 } 3082 3083 // SetTranscript sets the Transcript field's value. 3084 func (s *TranscriptEvent) SetTranscript(v *Transcript) *TranscriptEvent { 3085 s.Transcript = v 3086 return s 3087 } 3088 3089 // The TranscriptEvent is and event in the TranscriptResultStream group of events. 3090 func (s *TranscriptEvent) eventTranscriptResultStream() {} 3091 3092 // UnmarshalEvent unmarshals the EventStream Message into the TranscriptEvent value. 3093 // This method is only used internally within the SDK's EventStream handling. 3094 func (s *TranscriptEvent) UnmarshalEvent( 3095 payloadUnmarshaler protocol.PayloadUnmarshaler, 3096 msg eventstream.Message, 3097 ) error { 3098 if err := payloadUnmarshaler.UnmarshalPayload( 3099 bytes.NewReader(msg.Payload), s, 3100 ); err != nil { 3101 return err 3102 } 3103 return nil 3104 } 3105 3106 // MarshalEvent marshals the type into an stream event value. This method 3107 // should only used internally within the SDK's EventStream handling. 3108 func (s *TranscriptEvent) MarshalEvent(pm protocol.PayloadMarshaler) (msg eventstream.Message, err error) { 3109 msg.Headers.Set(eventstreamapi.MessageTypeHeader, eventstream.StringValue(eventstreamapi.EventMessageType)) 3110 var buf bytes.Buffer 3111 if err = pm.MarshalPayload(&buf, s); err != nil { 3112 return eventstream.Message{}, err 3113 } 3114 msg.Payload = buf.Bytes() 3115 return msg, err 3116 } 3117 3118 // TranscriptResultStreamEvent groups together all EventStream 3119 // events writes for TranscriptResultStream. 3120 // 3121 // These events are: 3122 // 3123 // * TranscriptEvent 3124 type TranscriptResultStreamEvent interface { 3125 eventTranscriptResultStream() 3126 eventstreamapi.Marshaler 3127 eventstreamapi.Unmarshaler 3128 } 3129 3130 // TranscriptResultStreamReader provides the interface for reading to the stream. The 3131 // default implementation for this interface will be TranscriptResultStream. 3132 // 3133 // The reader's Close method must allow multiple concurrent calls. 3134 // 3135 // These events are: 3136 // 3137 // * TranscriptEvent 3138 // * TranscriptResultStreamUnknownEvent 3139 type TranscriptResultStreamReader interface { 3140 // Returns a channel of events as they are read from the event stream. 3141 Events() <-chan TranscriptResultStreamEvent 3142 3143 // Close will stop the reader reading events from the stream. 3144 Close() error 3145 3146 // Returns any error that has occurred while reading from the event stream. 3147 Err() error 3148 } 3149 3150 type readTranscriptResultStream struct { 3151 eventReader *eventstreamapi.EventReader 3152 stream chan TranscriptResultStreamEvent 3153 err *eventstreamapi.OnceError 3154 3155 done chan struct{} 3156 closeOnce sync.Once 3157 } 3158 3159 func newReadTranscriptResultStream(eventReader *eventstreamapi.EventReader) *readTranscriptResultStream { 3160 r := &readTranscriptResultStream{ 3161 eventReader: eventReader, 3162 stream: make(chan TranscriptResultStreamEvent), 3163 done: make(chan struct{}), 3164 err: eventstreamapi.NewOnceError(), 3165 } 3166 go r.readEventStream() 3167 3168 return r 3169 } 3170 3171 // Close will close the underlying event stream reader. 3172 func (r *readTranscriptResultStream) Close() error { 3173 r.closeOnce.Do(r.safeClose) 3174 return r.Err() 3175 } 3176 3177 func (r *readTranscriptResultStream) ErrorSet() <-chan struct{} { 3178 return r.err.ErrorSet() 3179 } 3180 3181 func (r *readTranscriptResultStream) Closed() <-chan struct{} { 3182 return r.done 3183 } 3184 3185 func (r *readTranscriptResultStream) safeClose() { 3186 close(r.done) 3187 } 3188 3189 func (r *readTranscriptResultStream) Err() error { 3190 return r.err.Err() 3191 } 3192 3193 func (r *readTranscriptResultStream) Events() <-chan TranscriptResultStreamEvent { 3194 return r.stream 3195 } 3196 3197 func (r *readTranscriptResultStream) readEventStream() { 3198 defer r.Close() 3199 defer close(r.stream) 3200 3201 for { 3202 event, err := r.eventReader.ReadEvent() 3203 if err != nil { 3204 if err == io.EOF { 3205 return 3206 } 3207 select { 3208 case <-r.done: 3209 // If closed already ignore the error 3210 return 3211 default: 3212 } 3213 if _, ok := err.(*eventstreamapi.UnknownMessageTypeError); ok { 3214 continue 3215 } 3216 r.err.SetError(err) 3217 return 3218 } 3219 3220 select { 3221 case r.stream <- event.(TranscriptResultStreamEvent): 3222 case <-r.done: 3223 return 3224 } 3225 } 3226 } 3227 3228 type unmarshalerForTranscriptResultStreamEvent struct { 3229 metadata protocol.ResponseMetadata 3230 } 3231 3232 func (u unmarshalerForTranscriptResultStreamEvent) UnmarshalerForEventName(eventType string) (eventstreamapi.Unmarshaler, error) { 3233 switch eventType { 3234 case "TranscriptEvent": 3235 return &TranscriptEvent{}, nil 3236 case "BadRequestException": 3237 return newErrorBadRequestException(u.metadata).(eventstreamapi.Unmarshaler), nil 3238 case "ConflictException": 3239 return newErrorConflictException(u.metadata).(eventstreamapi.Unmarshaler), nil 3240 case "InternalFailureException": 3241 return newErrorInternalFailureException(u.metadata).(eventstreamapi.Unmarshaler), nil 3242 case "LimitExceededException": 3243 return newErrorLimitExceededException(u.metadata).(eventstreamapi.Unmarshaler), nil 3244 case "ServiceUnavailableException": 3245 return newErrorServiceUnavailableException(u.metadata).(eventstreamapi.Unmarshaler), nil 3246 default: 3247 return &TranscriptResultStreamUnknownEvent{Type: eventType}, nil 3248 } 3249 } 3250 3251 // TranscriptResultStreamUnknownEvent provides a failsafe event for the 3252 // TranscriptResultStream group of events when an unknown event is received. 3253 type TranscriptResultStreamUnknownEvent struct { 3254 Type string 3255 Message eventstream.Message 3256 } 3257 3258 // The TranscriptResultStreamUnknownEvent is and event in the TranscriptResultStream 3259 // group of events. 3260 func (s *TranscriptResultStreamUnknownEvent) eventTranscriptResultStream() {} 3261 3262 // MarshalEvent marshals the type into an stream event value. This method 3263 // should only used internally within the SDK's EventStream handling. 3264 func (e *TranscriptResultStreamUnknownEvent) MarshalEvent(pm protocol.PayloadMarshaler) ( 3265 msg eventstream.Message, err error, 3266 ) { 3267 return e.Message.Clone(), nil 3268 } 3269 3270 // UnmarshalEvent unmarshals the EventStream Message into the TranscriptResultStream value. 3271 // This method is only used internally within the SDK's EventStream handling. 3272 func (e *TranscriptResultStreamUnknownEvent) UnmarshalEvent( 3273 payloadUnmarshaler protocol.PayloadUnmarshaler, 3274 msg eventstream.Message, 3275 ) error { 3276 e.Message = msg.Clone() 3277 return nil 3278 } 3279 3280 const ( 3281 // ContentIdentificationTypePii is a ContentIdentificationType enum value 3282 ContentIdentificationTypePii = "PII" 3283 ) 3284 3285 // ContentIdentificationType_Values returns all elements of the ContentIdentificationType enum 3286 func ContentIdentificationType_Values() []string { 3287 return []string{ 3288 ContentIdentificationTypePii, 3289 } 3290 } 3291 3292 const ( 3293 // ContentRedactionTypePii is a ContentRedactionType enum value 3294 ContentRedactionTypePii = "PII" 3295 ) 3296 3297 // ContentRedactionType_Values returns all elements of the ContentRedactionType enum 3298 func ContentRedactionType_Values() []string { 3299 return []string{ 3300 ContentRedactionTypePii, 3301 } 3302 } 3303 3304 const ( 3305 // ItemTypePronunciation is a ItemType enum value 3306 ItemTypePronunciation = "pronunciation" 3307 3308 // ItemTypePunctuation is a ItemType enum value 3309 ItemTypePunctuation = "punctuation" 3310 ) 3311 3312 // ItemType_Values returns all elements of the ItemType enum 3313 func ItemType_Values() []string { 3314 return []string{ 3315 ItemTypePronunciation, 3316 ItemTypePunctuation, 3317 } 3318 } 3319 3320 const ( 3321 // LanguageCodeEnUs is a LanguageCode enum value 3322 LanguageCodeEnUs = "en-US" 3323 3324 // LanguageCodeEnGb is a LanguageCode enum value 3325 LanguageCodeEnGb = "en-GB" 3326 3327 // LanguageCodeEsUs is a LanguageCode enum value 3328 LanguageCodeEsUs = "es-US" 3329 3330 // LanguageCodeFrCa is a LanguageCode enum value 3331 LanguageCodeFrCa = "fr-CA" 3332 3333 // LanguageCodeFrFr is a LanguageCode enum value 3334 LanguageCodeFrFr = "fr-FR" 3335 3336 // LanguageCodeEnAu is a LanguageCode enum value 3337 LanguageCodeEnAu = "en-AU" 3338 3339 // LanguageCodeItIt is a LanguageCode enum value 3340 LanguageCodeItIt = "it-IT" 3341 3342 // LanguageCodeDeDe is a LanguageCode enum value 3343 LanguageCodeDeDe = "de-DE" 3344 3345 // LanguageCodePtBr is a LanguageCode enum value 3346 LanguageCodePtBr = "pt-BR" 3347 3348 // LanguageCodeJaJp is a LanguageCode enum value 3349 LanguageCodeJaJp = "ja-JP" 3350 3351 // LanguageCodeKoKr is a LanguageCode enum value 3352 LanguageCodeKoKr = "ko-KR" 3353 3354 // LanguageCodeZhCn is a LanguageCode enum value 3355 LanguageCodeZhCn = "zh-CN" 3356 ) 3357 3358 // LanguageCode_Values returns all elements of the LanguageCode enum 3359 func LanguageCode_Values() []string { 3360 return []string{ 3361 LanguageCodeEnUs, 3362 LanguageCodeEnGb, 3363 LanguageCodeEsUs, 3364 LanguageCodeFrCa, 3365 LanguageCodeFrFr, 3366 LanguageCodeEnAu, 3367 LanguageCodeItIt, 3368 LanguageCodeDeDe, 3369 LanguageCodePtBr, 3370 LanguageCodeJaJp, 3371 LanguageCodeKoKr, 3372 LanguageCodeZhCn, 3373 } 3374 } 3375 3376 const ( 3377 // MediaEncodingPcm is a MediaEncoding enum value 3378 MediaEncodingPcm = "pcm" 3379 3380 // MediaEncodingOggOpus is a MediaEncoding enum value 3381 MediaEncodingOggOpus = "ogg-opus" 3382 3383 // MediaEncodingFlac is a MediaEncoding enum value 3384 MediaEncodingFlac = "flac" 3385 ) 3386 3387 // MediaEncoding_Values returns all elements of the MediaEncoding enum 3388 func MediaEncoding_Values() []string { 3389 return []string{ 3390 MediaEncodingPcm, 3391 MediaEncodingOggOpus, 3392 MediaEncodingFlac, 3393 } 3394 } 3395 3396 const ( 3397 // MedicalContentIdentificationTypePhi is a MedicalContentIdentificationType enum value 3398 MedicalContentIdentificationTypePhi = "PHI" 3399 ) 3400 3401 // MedicalContentIdentificationType_Values returns all elements of the MedicalContentIdentificationType enum 3402 func MedicalContentIdentificationType_Values() []string { 3403 return []string{ 3404 MedicalContentIdentificationTypePhi, 3405 } 3406 } 3407 3408 const ( 3409 // PartialResultsStabilityHigh is a PartialResultsStability enum value 3410 PartialResultsStabilityHigh = "high" 3411 3412 // PartialResultsStabilityMedium is a PartialResultsStability enum value 3413 PartialResultsStabilityMedium = "medium" 3414 3415 // PartialResultsStabilityLow is a PartialResultsStability enum value 3416 PartialResultsStabilityLow = "low" 3417 ) 3418 3419 // PartialResultsStability_Values returns all elements of the PartialResultsStability enum 3420 func PartialResultsStability_Values() []string { 3421 return []string{ 3422 PartialResultsStabilityHigh, 3423 PartialResultsStabilityMedium, 3424 PartialResultsStabilityLow, 3425 } 3426 } 3427 3428 const ( 3429 // SpecialtyPrimarycare is a Specialty enum value 3430 SpecialtyPrimarycare = "PRIMARYCARE" 3431 3432 // SpecialtyCardiology is a Specialty enum value 3433 SpecialtyCardiology = "CARDIOLOGY" 3434 3435 // SpecialtyNeurology is a Specialty enum value 3436 SpecialtyNeurology = "NEUROLOGY" 3437 3438 // SpecialtyOncology is a Specialty enum value 3439 SpecialtyOncology = "ONCOLOGY" 3440 3441 // SpecialtyRadiology is a Specialty enum value 3442 SpecialtyRadiology = "RADIOLOGY" 3443 3444 // SpecialtyUrology is a Specialty enum value 3445 SpecialtyUrology = "UROLOGY" 3446 ) 3447 3448 // Specialty_Values returns all elements of the Specialty enum 3449 func Specialty_Values() []string { 3450 return []string{ 3451 SpecialtyPrimarycare, 3452 SpecialtyCardiology, 3453 SpecialtyNeurology, 3454 SpecialtyOncology, 3455 SpecialtyRadiology, 3456 SpecialtyUrology, 3457 } 3458 } 3459 3460 const ( 3461 // TypeConversation is a Type enum value 3462 TypeConversation = "CONVERSATION" 3463 3464 // TypeDictation is a Type enum value 3465 TypeDictation = "DICTATION" 3466 ) 3467 3468 // Type_Values returns all elements of the Type enum 3469 func Type_Values() []string { 3470 return []string{ 3471 TypeConversation, 3472 TypeDictation, 3473 } 3474 } 3475 3476 const ( 3477 // VocabularyFilterMethodRemove is a VocabularyFilterMethod enum value 3478 VocabularyFilterMethodRemove = "remove" 3479 3480 // VocabularyFilterMethodMask is a VocabularyFilterMethod enum value 3481 VocabularyFilterMethodMask = "mask" 3482 3483 // VocabularyFilterMethodTag is a VocabularyFilterMethod enum value 3484 VocabularyFilterMethodTag = "tag" 3485 ) 3486 3487 // VocabularyFilterMethod_Values returns all elements of the VocabularyFilterMethod enum 3488 func VocabularyFilterMethod_Values() []string { 3489 return []string{ 3490 VocabularyFilterMethodRemove, 3491 VocabularyFilterMethodMask, 3492 VocabularyFilterMethodTag, 3493 } 3494 }