0

When AWS Transcribe is still streaming, the isPartial flag will be set to True. I want to stop the streaming once the isPartial flag is set to False How to do it?

Did anyone do it?

https://docs.aws.amazon.com/transcribe/latest/dg/transcribe-dg.pdf#streaming

Here is the Json :

{
  "TranscriptResultStream": {
    "TranscriptEvent": {
      "Transcript": {
        "Results": [
          {
            "Alternatives": [
              {
                "Items": [
                  {
                    "Content": "the",
                    "EndTime": 0.3799375,
                    "StartTime": 0.0299375,
                    "Type": "pronunciation"
                  },
                  {
                    "Content": "amazon",
                    "EndTime": 0.5899375,
                    "StartTime": 0.3899375,
                    "Type": "pronunciation"
                  },
                  {
                    "Content": "is",
                    "EndTime": 0.7899375,
                    "StartTime": 0.5999375,
                    "Type": "pronunciation"
                  },
                  {
                    "Content": "the",
                    "EndTime": 0.9199375,
                    "StartTime": 0.7999375,
                    "Type": "pronunciation"
                  },
                  {
                    "Content": "largest",
                    "EndTime": 1.0199375,
                    "StartTime": 0.9299375,
                    "Type": "pronunciation"
                  }
                ],
                "Transcrip`enter code here`t": "the amazon is the largest"
              }
            ],
            "EndTime": 1.02,
            "IsPartial": true,
            "ResultId": "2db76dc8-d728-11e8-9f8b-f2801f1b9fd1",
            "StartTime": 0.0199375
          }
        ]
      }
    }
  }
}

1 Answers1

0

Empty audio frame signals end-of-stream. As specified in the document: "To end the audio data stream, send an empty audio chunk in an event-stream-encoded message".

Ruoyu Huang
  • 111
  • 4
  • I am not sure how to send the emtpy audio stream event to stop transcribing. Here is the piece of code i have. '}).subscriber(event -> { List results = ((TranscriptEvent) event).transcript().results(); if (results.size() > 0) { if (!results.get(0).alternatives().get(0).transcript().isEmpty()) { System.out.println(results.get(0).alternatives().get(0).transcript()); } } }).build(); Not sure how to send empty audio event when the mic is on – invisibleCoder Apr 14 '20 at 15:30
  • if you use Java SDK (Http2), you can call .close() method to close a connection. Java SDK will handle it. If you use custom WebSocket client, you need to send an empty audio frame. empty audio frame contains empty byteBuffer. – Ruoyu Huang Apr 19 '20 at 07:03