AWS Transcribe Streaming: including config event in AudioStream causes BadRequest error. JS SDK

0

Hello, I am trying to turn on postcall analytics. My understanding is that the configuration event must be included as the first event in the audio stream. However, when I include the configuration event, I receive the following error:

error BadRequestException: Could not decode the audio stream that you provided. Check that the audio stream is valid and try your request again.

When I do not include the configuration event, the streaming transcription works just fine.

I am using the JS SDK for this. Here is my code:

// Parameters for AWS Transcribe
const LANGUAGE_CODE = "en-US";
const MEDIA_ENCODING = "ogg-opus";
const MEDIA_SAMPLE_RATE_HERTZ = 16000;
const AWS_REGION = "us-east-1";
const DATA_ACCESS_ROLE_ARN = <redacted>
const S3_OUTPUT_LOCATION =<redacted>

    const client = new TranscribeStreamingClient({
      region: AWS_REGION,
      credentials,
    });

    const configurationEvent: AudioStream.ConfigurationEventMember = {
      ConfigurationEvent: {
        PostCallAnalyticsSettings: {
          DataAccessRoleArn: DATA_ACCESS_ROLE_ARN,
          OutputLocation: S3_OUTPUT_LOCATION,
        },
      },
    };

   const audioParams: StartMedicalStreamTranscriptionCommandInput = {
      Specialty: "PRIMARYCARE",
      Type: "CONVERSATION",
      LanguageCode: LANGUAGE_CODE,
      MediaEncoding: MEDIA_ENCODING,
      MediaSampleRateHertz: MEDIA_SAMPLE_RATE_HERTZ,
      ShowSpeakerLabel: true,
      AudioStream: (async function* () {
        yield await Promise.resolve(configurationEvent);
        for await (const chunk of stream) {  // "stream" is a MediaStreamTrack
          yield {
            AudioEvent: { AudioChunk: chunk },
          };
        }
      })(),
    };

    const response = await client.send(
      new StartMedicalStreamTranscriptionCommand(audioParams),
    );

    try {
      for await (const event of response.TranscriptResultStream || []) {
           ... read transcriptions
Bryce
asked 9 months ago76 views
No Answers

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions