label-studio icon indicating copy to clipboard operation
label-studio copied to clipboard

Bug with audio region pre-annotation

Open LamDang opened this issue 6 years ago • 7 comments

Hello, I encountered the following bug trying to setup audio region transcription with pre-annotation. Thanks for your helps.

## How to reproduce:

  • Plateforme: https://app.labelstud.io/
  • Label config: Transcript per region - default
  • Tasks: Import the following task twice
{
  "data": {
    "audio": "/static/samples/game.wav"
  },
  "predictions": [
    {"result": [
      {
        "from_name": "labels",
        "to_name": "audio",
        "source": "$audio",
        "type": "labels",
        "parent_id": null,
        "original_length": 3.77437641723356,
        "value": {
          "start": 0.009810311552919447,
          "end": 0.3562157953525578,
          "labels": [
            "Speaker 1"
          ]
        }
      },
      {
        "from_name": "transcription",
        "to_name": "audio",
        "source": "$audio",
        "type": "textarea",
        "parent_id": null,
        "original_length": 3.77437641723356,
        "value": {
          "start": 0.009810311552919447,
          "end": 0.3562157953525578,
          "text": [
            "abc"
          ]
        }
      },
      {
        "from_name": "labels",
        "to_name": "audio",
        "source": "$audio",
        "type": "labels",
        "parent_id": null,
        "original_length": 3.77437641723356,
        "value": {
          "start": 0.8974743637894927,
          "end": 1.5469846459138148,
          "labels": [
            "Speaker 2"
          ]
        }
      },
      {
        "from_name": "transcription",
        "to_name": "audio",
        "source": "$audio",
        "type": "textarea",
        "parent_id": null,
        "original_length": 3.77437641723356,
        "value": {
          "start": 0.8974743637894927,
          "end": 1.5469846459138148,
          "text": [
            "def"
          ]
        }
      }
    ]}
  ]
}

Bug description

If only 1 task left, then no error. If more than 1 task left, when Submit labelling, the interface hangs and Chrome (Version 84.0.4147.105 (Official Build) (64-bit)) console show following error

AudioRegion.js:131 Uncaught (in promise) TypeError: e._ws_region.remove is not a function
    at Object.beforeDestroy (AudioRegion.js:131)
    at ge (mobx.module.js:914)
    at r (mobx.module.js:901)
    at mobx-state-tree.module.js:2564
    at K (mobx-state-tree.module.js:2427)
    at Object.r (mobx-state-tree.module.js:2454)
    at mobx-state-tree.module.js:1429
    at xe (mobx.module.js:998)
    at t.fireHook (mobx-state-tree.module.js:1428)
    at t.e.baseAboutToDie (mobx-state-tree.module.js:1122)
    at t.aboutToDie (mobx-state-tree.module.js:1620)
    at mobx-state-tree.module.js:1616
    at Array.forEach (<anonymous>)
    at t.aboutToDie (mobx-state-tree.module.js:1615)
    at mobx-state-tree.module.js:1616
    at Array.forEach (<anonymous>)
    at t.aboutToDie (mobx-state-tree.module.js:1615)
    at mobx-state-tree.module.js:1616
    at Array.forEach (<anonymous>)
    at t.aboutToDie (mobx-state-tree.module.js:1615)
    at mobx-state-tree.module.js:1616
    at Array.forEach (<anonymous>)
    at t.aboutToDie (mobx-state-tree.module.js:1615)
    at mobx-state-tree.module.js:1616
    at Array.forEach (<anonymous>)
    at t.aboutToDie (mobx-state-tree.module.js:1615)
    at mobx-state-tree.module.js:1616
    at Array.forEach (<anonymous>)
    at t.aboutToDie (mobx-state-tree.module.js:1615)
    at mobx-state-tree.module.js:1616
    at Array.forEach (<anonymous>)
    at t.aboutToDie (mobx-state-tree.module.js:1615)
    at t.die (mobx-state-tree.module.js:1608)
    at ge (mobx.module.js:914)
    at t.r (mobx.module.js:901)
    at t.reconcile (mobx-state-tree.module.js:1917)
    at t.reconcile (mobx-state-tree.module.js:5460)
    at Array.t.willChange (mobx-state-tree.module.js:4807)
    at Nt (mobx.module.js:2992)
    at e.write (mobx.module.js:4006)
    at Object.set [as completionStore] (mobx.module.js:4239)
    at Object.resetState (AppStore.js:277)
    at ge (mobx.module.js:914)
    at r (mobx.module.js:901)
    at mobx-state-tree.module.js:2564
    at K (mobx-state-tree.module.js:2427)
    at Object.r (mobx-state-tree.module.js:2454)
    at lsf-sdk.js:113

LamDang avatar Oct 06 '20 20:10 LamDang

I also tested with speaker diarization config and it is the same issue. Looks like it impacts all config with audio region. Whole audio transcription works fine

LamDang avatar Oct 06 '20 20:10 LamDang

@LamDang Try to add ids to the each result, e.g.:

{
        ==> "id": "random-id-1", <==
        "from_name": "labels",
        "to_name": "audio",
        "source": "$audio",
        "type": "labels",
        "parent_id": null,
        "original_length": 3.77437641723356,
        "value": {
          "start": 0.009810311552919447,
          "end": 0.3562157953525578,
          "labels": [
            "Speaker 1"
          ]
        }
      },

makseq avatar Oct 07 '20 17:10 makseq

And there is important thing about ids and perRegion labeling: id of labeled result and perRegion result should be the same. This helps to connect them. Like:

[
  { "id": "jtptr", "type": "labels", "value": { "labels": ["Speaker 1"] } },
  { "id": "jtptr", "type": "textarea", "value": { "text": ["abc"] } },
  { "id": "4Bnfe", "type": "labels", "value": { "labels": ["Speaker 2"] } },
  { "id": "4Bnfe", "type": "textarea", "value": { "text": ["def"] } },
]

hlomzik avatar Oct 07 '20 18:10 hlomzik

Hello,

@makseq @hlomzik Thank you for your answers. However I tried as you suggest and still have the bug. Here is the export to show that my predictions do have ids and the completions are created ok.

It is just the transition to the next task that is buggy it seems.

2020-10-07-20-01-53.zip

LamDang avatar Oct 07 '20 20:10 LamDang

Oh, that was a very important thing! I investigated it deeply and found not obvious bug when you create completion from prediction containing per-region labeling. Fixed it in LSF master and pushed fix to release/0.7.5 branch, try it out! Anyway you have to add ids to prediction or you'll end up with broken non-labeled grey regions on audio. Thank you for this bug report, @LamDang!

hlomzik avatar Oct 07 '20 21:10 hlomzik

That bug is actually still alive.

The error is the following:

instrument.ts:129 Error: [mobx-state-tree] You are trying to read or write to an object that is no longer part of a state tree. (Object type: 'TextModel', Path upon death: '/completionStore/root/children/0', Subpath: '', Action: '/completionStore/root/children/0.setRef()'). Either detach nodes first, or don't use objects after removing / replacing them in the tree.
    at Ct (mobx-state-tree.module.js:3427)
    at t.assertAlive (mobx-state-tree.module.js:1510)
    at ke (mobx-state-tree.module.js:2447)
    at Object.r (mobx-state-tree.module.js:2483)
    at ref (Text.js:526)
    at ts (react-dom.production.min.js:209)
    at as (react-dom.production.min.js:214)
    at us (react-dom.production.min.js:220)
    at pl (react-dom.production.min.js:253)
    at t.unstable_runWithPriority (scheduler.production.min.js:19)
    at Ho (react-dom.production.min.js:122)
    at dl (react-dom.production.min.js:248)
    at Zs (react-dom.production.min.js:239)
    at react-dom.production.min.js:123
    at t.unstable_runWithPriority (scheduler.production.min.js:19)
    at Ho (react-dom.production.min.js:122)
    at Yo (react-dom.production.min.js:123)
    at Go (react-dom.production.min.js:122)
    at el (react-dom.production.min.js:240)
    at Ue (mobx.module.js:1919)
    at He (mobx.module.js:1895)
    at Fe (mobx.module.js:1595)
    at mobx.module.js:981
    at be (mobx.module.js:935)
    at r (mobx.module.js:915)
    at mobx-state-tree.module.js:2593
    at ke (mobx-state-tree.module.js:2456)
    at Object.r (mobx-state-tree.module.js:2483)
    at lsf-sdk.js:113

fearless-lark avatar Dec 09 '20 00:12 fearless-lark

@OlehYashchuk Thank you for your report, I've created a ticket in our backlog about it.

makseq avatar Dec 12 '20 19:12 makseq