react-transcript-editor icon indicating copy to clipboard operation
react-transcript-editor copied to clipboard

Speechmatics adapter throws error if empty speechmatics transcript is provided

Open murezzda opened this issue 6 years ago • 5 comments

Describe the bug If speechmatics api returns a transcript with no text, the speechmatics adapter throws an TypeError: Cannot read property 'children' of undefined error.

To Reproduce Steps to reproduce the behavior:

  1. Create transcript from audio with no spoken content in speechmatics.
  2. Load the transcript.

Expected behavior A empty transcript is shown in the editor and no error is thrown.

murezzda avatar Apr 08 '19 07:04 murezzda

@murezzda do you have any thoughts on a workaround for this?

It might be a good edge case to add to the tests, and that we'd have to check the other STT adapters are handling as well.

pietrop avatar Apr 08 '19 14:04 pietrop

@pietrop I haven't yet looked at it, but I plan on fixing this soon. Regarding other STT adapters I did not do any testing. I would also recommend to add them to the tests, as an empty transcript will occur from time to time in a productive environment (wrong/bad file or quality of audio).

murezzda avatar Apr 09 '19 06:04 murezzda

I found two options for solving this problem:

  • Handling empty transcripts in the adapters themselves.
  • Handling the error in TimedTextEditor's setEditorContentState method, plus some handling in the WrapperBlock class to ensure a valid timestamp is shown.

Depending on wether this is a speechmatics specific problem or not I would either opt for the first or the second option. Has someone tried to reproduce the problem with other stt vendors?

murezzda avatar Apr 10 '19 10:04 murezzda

Thanks @murezzda,

Yeah, I was thinking about the first option. Seemed the most straight forward and easier to test. altho a lot of "logic repetition" across the adapters.

The second one could also be a good fix that works across adapters, but each adapter should still handle the "empty transcript conversion".


For option one, if an STT adapter gets an "empty transcript" if it returns this draftJS json like this one below

{
  "blocks": [
    {
      "key": "67dlg",
      "text": "",
      "type": "paragraph",
      "depth": 0,
      "inlineStyleRanges": [],
      "entityRanges": [],
      "data": {
        "speaker": "UKN",
        "words": [],
        "start": 0
      }
    }
  ],
  "entityMap": {}
}

then it would be shown like this

Screen Shot 2019-04-10 at 12 17 20

you can try it in the demo app by importing draftJs json

But a user might not be clear on what to do next. eg start typing text, re-do the transcript etc..

However there might be a number of reasons why the transcript is empty. And I guess the choice to make is, if there's an empty transcript, should we just display an error message to say something went wrong and there's no automated transcript to correct?

It also feels like this might be something the parent app needs to handle? either fully or partially?

Happy to think it through a bit more and discuss

pietrop avatar Apr 10 '19 11:04 pietrop

Ok, here's a proposed solution, feel free to disagree.

  • Parent app is generally responsible to check if transcript is valid or not empty before passing it to the component.
  • in case that fails, or dev forgets to implement it, it be good to have a fallback, that displays a message saying, the "The transcript does not contain any text" or something like that.
  • The STT adapters can return a draftJS json similar to the one mentioned in the comment above.
  • TimedTextEditor can display the error message instead of the DraftJs Editor if there is only one block and the entityRanges is an empty array and if text attribute of the block is an empty string. (could also check for entityMap to be empty)

What do you think?

pietrop avatar Apr 10 '19 12:04 pietrop