Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

suggestions for PR bbc#144 #1

Draft
wants to merge 22 commits into
base: update-timestamps-diff
Choose a base branch
from

Conversation

pietrop
Copy link

@pietrop pietrop commented Jun 23, 2019

Is your Pull Request request related to another issue in this repository ?

bbc#144

Describe what the PR does

some changes to show suggestions for PR bbc#144 around edge case of trying to preserve block level time-codes and speaker informations when user paste accurate text into the editor.

State whether the PR is ready for review or whether it needs extra work

Ready for review

Additional context

Just to demonstrate, show, and discuss ideas.

@pietrop pietrop changed the title some changes to show sudgestions for PR some changes to show sudgestions for PR bbc#144 Jun 23, 2019
@pietrop pietrop changed the title some changes to show sudgestions for PR bbc#144 suggestions for PR bbc#144 Jun 23, 2019
@pietrop
Copy link
Author

pietrop commented Jun 23, 2019

Handling edge case: pasting accurate text in editor

This PR shows a possible way for handling edge case when pasting text for retaining paragraph timecode and speaker name

  • handling timecode at paragraph level when corrected text is pasted into the editor
  • handling speaker names at paragraph level by using default UKN speaker label, which is good if replacing everything, not so good if replacing a line inside a paragraph by pasting in the correct text (as we might want to keep the speaker name in that case).

speaker name


If you export draftJs json from the demo app, you can see that in the paragraph block there is a data.speaker attribute.



    {
      "key": "129ia",
      "text": "he'd ordered and I was really excited about it because I've always loved about this one has really caught technical features. It had more orders and touch sensors. It had an infra red camera and one of the things that had was a tilt sensor so it. Knew what direction. It was facing. If and when you held it upside down.",
      "type": "paragraph",
      "depth": 0,
      "inlineStyleRanges": [],
      "entityRanges": [
        {
          "offset": 0,
          "length": 4,
          "key": 29
        },
..
      ],
      "data": {
        "speaker": "F_S12",
        "words": [
          {
            "start": 24.65,
            "confidence": 0.59,
            "end": 24.84,
            "word": "he'd",
            "punct": "he'd",
            "index": 29,
            "speaker": "F_S12"
          },

in createEntity (or a bit cleaner, in another function as a second pass) you might need to add speaker names so that you can access it in createContentFromEntityList

Not sure if start is under block.data.start in createContentFromEntityList

TL;DR: See the diffs in this PR for some suggestions around possible ways to handle edge case when user pastes text for retaining paragraph timecode and speaker name.

@pietrop
Copy link
Author

pietrop commented Jun 23, 2019

Another possible solution is to catch the pasted text further upstream and to use handlePastedText also mentioned in this article about race condition as well as this comment.

The hunch being that when you paste some text into the editor, it is missing the entities so draftjs does not identify it as words, and therefore speaker and time info are missing.

Pietro Passarelli - News Labs and others added 13 commits July 13, 2019 18:00
Co-Authored-By: Pietro <pietro.passarelli@gmail.com>
Co-Authored-By: Pietro <pietro.passarelli@gmail.com>
Co-Authored-By: Pietro <pietro.passarelli@gmail.com>
Adding speech to text adapter for Google cloud platform
* moved header into a component

with shouldComponentUopdate false to avoid unecessary re-renders - test

* moved Header component into separate file

+removed unused styling, commented out for now in case it's needed, eg in mobile view?

* moved playback_rates const into separate file

* optimised re-render of playback rate

* optimise re-render for VideoPlayer

* added some notes - draft

on how to prevent uncessary re-renders in React

* Added some comments

* small note in docs

about using console.log in render to measure performance

* ammend to notes

* Update 2019-05-16-prevent-unnecessary-re-renders-in-react.md

* notes update

* notes fix

* trying out why-did-you-update

* updated MediaPlayer and subcomponents

* made ToolTip 'how does this work' into it's own component

* updated Demo app to reduce unecessary re-renders

* added react-visibility-sensor

* refactor settings

* removed unecessary attributes from state of components + WrapperBlock performance tweak using react-visibility-sensor
* Added timestamp update via diff tool

* Added missing function

* Commited intermediate state

* Rewrote timestamp alignment and differ to be integrated in each other instead of doing a 2-step process.

* Update Timestamps now works correctly.

* Fixed errors from rebase, removed debug code

* Moved UpdateTimestamp into its own folder.

* added updateTimestampsSSTAlign which updates the timestamps with the sst-align code

* Added documentation

* Merged timer for updating the timestamps and local save.

* Selection state is now kept across updates to timestamps

* Fixed bug where words with punctuation always are considered as new words. Timestamp update function now also uses the alignWords function directly instead of alignJSONText, removing some overhead.

* Fixed small bug which raised an error if an empty block was present during timestamp update

* Changed time of timestamp-update. Now re-calculates the timestamps after 5 seconds if the transcript has been edited or if the user saves the transcript manually with the save button

* Code cleanup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants