aws / amazon-chime-sdk-js

A JavaScript client library for integrating multi-party communications powered by the Amazon Chime service.
Apache License 2.0
704 stars 475 forks source link

Live transcription implementation on ReactJS app #1994

Closed Brenerss closed 2 years ago

Brenerss commented 2 years ago

What happened and what did you expect to happen?

I'm currently needing to implement a feature that will show the entire transcript during the meeting. I completed the first step which would be "Creating a Service-Linked Role for Amazon Chime Live Transcription" from this url (https://docs.aws.amazon.com/chime/latest/ag/using-service-linked-roles-transcription.html)

after that, as soon as the meeting starts I call this url -> meetings/${meetingIdFromAWS}/transcription?operation=start that meetingIdFromAWS is MeetingId returned from join?title=meetingId&name=name&regionregion

First problem: in my local computer this url returns 404 not found meetings/${meetingIdFromAWS}/transcription?operation=start, only on production this url works

Second problem: even in production when I call this url and it returns 200(OK), the class Transcript of this import always returns empty

import { Transcript } from 'amazon-chime-sdk-js';

const transcript = new Transcript();
console.log('transcript', transcript);

I'm kind of confused about the documentation, what would be the correct way to use this transcription feature

Have you reviewed our existing documentation?

Reproduction steps

npm run start

Amazon Chime SDK for JavaScript version

^2.17.0

What browsers are you seeing the problem on?

Chrome

Browser version

97.0.4692.99 64 bits

Meeting and Attendee ID Information.

No response

Browser console logs

none

xuesichao commented 2 years ago

@Brenerss Are you following this guide? https://docs.aws.amazon.com/chime/latest/dg/meeting-transcription.html

For your first question:

in my local computer this url returns 404 not found meetings/${meetingIdFromAWS}/transcription?operation=start, only on production this url works

You need to have a serverless deployment to create new AWS Lambda endpoints for live transcription. AWS Lambda endpoints for live transcription does not exist when running locally.

Brenerss commented 2 years ago

Yes, im following this guide and ok i will try create this

xuesichao commented 2 years ago

@Brenerss For your second question:

even in production when I call this url and it returns 200(OK), the class Transcript of this import always returns empty

According to our doc:

OK (200) with empty body, if you successfully apply the TranscriptionConfiguration to the meeting.

You got the response 200, basically it means you started the transcription service successfully. I assume the cause here is you used the wrong way to receive the transcription result.

According to our demo App implementation and the AWS doc:

You need to implement a transcript event dandler, and subscribe to transcript event:

transcriptEventHandler = (transcriptEvent: TranscriptEvent): void => {
  // `transcriptEvent` could be either a `Transcript` or `TranscriptionStatus`
  // if it is `Transcript`, then it should contain transcription results
  // else you need to handle the logic of `TranscriptionStatus` changes (start/ stop/ ...)

  if (transcriptEvent instanceof TranscriptionStatus) {
    // Print Transcript Status, could be `STARTED`, `INTERRUPTED`, `RESUMED`, `STOPPED` or `FAILED`
    console.log(transcriptEvent.type);
  } else if (transcriptEvent instanceof Transcript) {
    // Print Transcript result collection
    console.log(transcriptEvent.results);
  }
};

this.audioVideo.transcriptionController?.subscribeToTranscriptEvent(this.transcriptEventHandler);

No problem, please refer to our demo App implementation. This should be most useful.

Brenerss commented 2 years ago

I used this function, the call to api returned 200 but no console.log of this function referring to the transcript event is shown as I speak

I'm not sure if I'm getting the MeetingId from the right place

endpoint of fetchMeeting is join?title=meetingId&name=name&region=region

const { JoinInfo } = await handleAPICall(() => AWSServices.fetchMeeting({ 
        meetingId,
        name: participantName,
        region: appRegion,
 }));

and JoinInfo retuns JoinInfo.Meeting.MeetingId and it is this value that I am passing to the request meetings/${meetingIdFromAWS}/transcription?operation=start

xuesichao commented 2 years ago

@Brenerss I assume you were using the HTTP request to start the transcription service following this doc: https://docs.aws.amazon.com/chime/latest/dg/initiate-transcription.html

I'm not familiar with this part. However I checked our browser demo where it calls StartMeetingTranscription API to start the transcription service.

Could you please follow below steps to start the transcription service and see if it helps?

  1. Use either of the chime or chimeSDKMeetings client. https://github.com/aws/amazon-chime-sdk-js/blob/db36d8a4191ad6fe58af68d51008c12a5b1286a9/demos/browser/server.js#L28-L38

  2. Use the above client to call startMeetingTranscription() API.

Brenerss commented 2 years ago

Its works, but when i tested on prod retuns this. I'm using root access key

{
    "errorType": "Forbidden",
    "errorMessage": "AWS authorization failed",
    "code": "Forbidden",
    "message": "AWS authorization failed",
    "time": "2022-03-07T14:38:26.070Z",
    "requestId": "5bba27fb-e456-4509-a27b-3c1d9db81e28",
    "statusCode": 403,
    "retryable": false,
    "retryDelay": 27.326964869587588,
    "stack": [
        "Forbidden: AWS authorization failed",
        "    at Object.extractError (/var/runtime/node_modules/aws-sdk/lib/protocol/json.js:52:27)",
        "    at Request.extractError (/var/runtime/node_modules/aws-sdk/lib/protocol/rest_json.js:49:8)",
        "    at Request.callListeners (/var/runtime/node_modules/aws-sdk/lib/sequential_executor.js:106:20)",
        "    at Request.emit (/var/runtime/node_modules/aws-sdk/lib/sequential_executor.js:78:10)",
        "    at Request.emit (/var/runtime/node_modules/aws-sdk/lib/request.js:686:14)",
        "    at Request.transition (/var/runtime/node_modules/aws-sdk/lib/request.js:22:10)",
        "    at AcceptorStateMachine.runTo (/var/runtime/node_modules/aws-sdk/lib/state_machine.js:14:12)",
        "    at /var/runtime/node_modules/aws-sdk/lib/state_machine.js:26:10",
        "    at Request.<anonymous> (/var/runtime/node_modules/aws-sdk/lib/request.js:38:9)",
        "    at Request.<anonymous> (/var/runtime/node_modules/aws-sdk/lib/request.js:688:12)"
    ]
}
LeviSklaroff commented 2 years ago

I noticed in this #2085 you are not passing a region, if the region is not specified it uses the same region as the meeting, which can sometimes not support transcription and you will receive this error. You can Use "region = 'auto'" to have Amazon Chime use Amazon Transcribe in a nearby region if it is not available in the meeting region. https://docs.aws.amazon.com/chime/latest/APIReference/API_StartMeetingTranscription.html

This can also occur if you are hosting a meeting in an "opt in" region (eu-south-1, af-south-1), then you must "enable" those regions for your AWS account for Amazon Chime to invoke Amazon Transcribe from that region (regardless of the region of Amazon Transcribe) https://docs.aws.amazon.com/chime/latest/dg/transcription-options.html#choose-region