startMedicalScribeStream method
Starts a bidirectional HTTP/2 stream, where audio is streamed to Amazon Web Services HealthScribe and the transcription results are streamed to your application.
When you start a stream, you first specify the stream configuration in a
MedicalScribeConfigurationEvent. This event includes channel
definitions, encryption settings, medical scribe context, and post-stream
analytics settings, such as the output configuration for aggregated
transcript and clinical note generation. These are additional streaming
session configurations beyond those provided in your initial start request
headers. Whether you are starting a new session or resuming an existing
session, your first event must be a
MedicalScribeConfigurationEvent.
After you send a MedicalScribeConfigurationEvent, you start
AudioEvents and Amazon Web Services HealthScribe responds
with real-time transcription results. When you are finished, to start
processing the results with the post-stream analytics, send a
MedicalScribeSessionControlEvent with a Type of
END_OF_SESSION and Amazon Web Services HealthScribe starts
the analytics.
You can pause or resume streaming. To pause streaming, complete the input
stream without sending the MedicalScribeSessionControlEvent.
To resume streaming, call the StartMedicalScribeStream and
specify the same SessionId you used to start the stream.
The following parameters are required:
-
language-code -
media-encoding -
media-sample-rate-hertz
For more information on streaming with Amazon Web Services HealthScribe, see Amazon Web Services HealthScribe.
May throw BadRequestException.
May throw ConflictException.
May throw InternalFailureException.
May throw LimitExceededException.
May throw ServiceUnavailableException.
Parameter inputStream :
Specify the input stream where you will send events in real time.
The first element of the input stream must be a
MedicalScribeConfigurationEvent.
Parameter languageCode :
Specify the language code for your HealthScribe streaming session.
Parameter mediaEncoding :
Specify the encoding used for the input audio.
Supported formats are:
- FLAC
- OPUS-encoded audio in an Ogg container
- PCM (only signed 16-bit little-endian audio formats, which does not include WAV)
Parameter mediaSampleRateHertz :
Specify the sample rate of the input audio (in hertz). Amazon Web Services
HealthScribe supports a range from 16,000 Hz to 48,000 Hz. The sample rate
you specify must match that of your audio.
Parameter sessionId :
Specify an identifier for your streaming session (in UUID format). If you
don't include a SessionId in your request, Amazon Web Services
HealthScribe generates an ID and returns it in the response.
Implementation
Future<StartMedicalScribeStreamResponse> startMedicalScribeStream({
required MedicalScribeInputStream inputStream,
required MedicalScribeLanguageCode languageCode,
required MedicalScribeMediaEncoding mediaEncoding,
required int mediaSampleRateHertz,
String? sessionId,
}) async {
_s.validateNumRange(
'mediaSampleRateHertz',
mediaSampleRateHertz,
16000,
48000,
isRequired: true,
);
final headers = <String, String>{
'x-amzn-transcribe-language-code': languageCode.value,
'x-amzn-transcribe-media-encoding': mediaEncoding.value,
'x-amzn-transcribe-sample-rate': mediaSampleRateHertz.toString(),
if (sessionId != null)
'x-amzn-transcribe-session-id': sessionId.toString(),
};
final response = await _protocol.sendRaw(
payload: inputStream,
method: 'POST',
requestUri: '/medical-scribe-stream',
headers: headers,
exceptionFnMap: _exceptionFns,
);
final $json = await _s.jsonFromResponse(response);
return StartMedicalScribeStreamResponse(
resultStream: MedicalScribeResultStream.fromJson($json),
languageCode: _s
.extractHeaderStringValue(
response.headers, 'x-amzn-transcribe-language-code')
?.let(MedicalScribeLanguageCode.fromString),
mediaEncoding: _s
.extractHeaderStringValue(
response.headers, 'x-amzn-transcribe-media-encoding')
?.let(MedicalScribeMediaEncoding.fromString),
mediaSampleRateHertz: _s.extractHeaderIntValue(
response.headers, 'x-amzn-transcribe-sample-rate'),
requestId:
_s.extractHeaderStringValue(response.headers, 'x-amzn-request-id'),
sessionId: _s.extractHeaderStringValue(
response.headers, 'x-amzn-transcribe-session-id'),
);
}