Git Product home page Git Product logo

bbc / react-transcript-editor Goto Github PK

View Code? Open in Web Editor NEW
548.0 34.0 167.0 21.74 MB

A React component to make correcting automated transcriptions of audio and video easier and faster. By BBC News Labs. - Work in progress

Home Page: https://bbc.github.io/react-transcript-editor

License: Other

JavaScript 99.62% CSS 0.23% SCSS 0.15%
bbc-news-labs news-labs transcript transcription transcript-editor stt kaldi react textav

react-transcript-editor's Introduction

React Transcript Editor

A React component to make transcribing audio and video easier and faster.


The project uses [this github project boards to organise and the co-ordinate development](https://github.com/bbc/react-transcript-editor/projects). _--> Work in progress <--_

Development env

Node version is set in node version manager .nvmrc

Setup

  1. Fork this repository
  2. Clone this repository to a directory of your choice
  3. Run npm i to install dependencies

Usage - development

We use a tool called storybook to run the components locally. To start the Storybook, run:

npm start

Running that command should open the locally hosted Storybook, but if it doesn't, visit http://localhost:6006

Usage - production

In order to use a published version of react-transcript-editor, install the published module @bbc/react-transcript-editor by running:

npm install @bbc/react-transcript-editor
import TranscriptEditor from "@bbc/react-transcript-editor";

Basic use case

<TranscriptEditor
  transcriptData={someJsonFile}
  mediaUrl={"https://download.ted.com/talks/KateDarling_2018S-950k.mp4"}
/>

transcriptData and mediaUrl are non-optional props to use TranscriptEditor. See the full list of options here.

Advanced use case

<TranscriptEditor
  transcriptData={someJsonFile}
  mediaUrl={"https://download.ted.com/talks/KateDarling_2018S-950k.mp4"}
  handleAutoSaveChanges={this.handleAutoSaveChanges}
  autoSaveContentType={"digitalpaperedit"}
  isEditable={true}
  spellCheck={false}
  sttJsonType={"bbckaldi"}
  handleAnalyticsEvents={this.handleAnalyticsEvents}
  fileName={"ted-talk.mp4"}
  title={"Ted Talk"}
  ref={this.transcriptEditorRef}
  mediaType={"video"}
/>

TranscriptEditor Props List

Props Description required type default
transcriptData Transcript JSON yes JSON
mediaUrl URL to media (audio or video) file yes String
handleAutoSaveChanges Function to handle the content of transcription after a change no Function
autoSaveContentType Specify the file format for data returned by handleAutoSaveChanges no String falls back to sttJsonType, if set, or draftjs
isEditable Set to true to have the ability to edit the text no Boolean False
spellCheck Set to true to spell-check the transcript no Boolean False
sttJsonType The data model type of your transcriptData no String draftjs
handleAnalyticsEvents if you want to collect analytics events. no Function false
fileName used for saving and retrieving local storage blob files no, but disables the local save feature String
title defaults to empty string no String
ref If you want to have access to internal functions such as retrieving content from the editor. eg to save to a server/db. no React ref
mediaType Can be audio or video. Changes the look of the UI based on media type. no String if not provided the component uses the medialUrl to determine the media type

See ./demo/app.js demo as a more detailed example usage of the component.

Local save

fileName is optional but it's needed if working with user uploaded local media in the browser, to be able to save and retrieve from local storage. For instance if you are passing a blob url to mediaUrl using createObjectURL this url is randomly re-generated on every page refresh so you wouldn't be able to restore a session, as mediaUrl is used as the local storage key. See demo app for more detail example of this./src/index.js_

Typescript projects

If using in a parent project where typescript is being used you might need to add //@ts-ignore before the import statment like this

//@ts-ignore
import { TranscriptEditor } from "@bbc/react-transcript-editor";

Internal components

Direct imports

You can also import some of the underlying React components directly. See the storybook for each component details on optional and required attributes.

  • TranscriptEditor
  • TimedTextEditor
  • MediaPlayer
  • VideoPlayer
  • Settings
  • KeyboardShortcuts
  • ProgressBar
  • PlaybackRate
  • PlayerControls
  • RollBack
  • Select

To import the components you can do as follows

import TimedTextEditor from "@bbc/react-transcript-editor/TimedTextEditor";
import { TimedTextEditor } from "@bbc/react-transcript-editor";
Import recommendation

However if you are not using TranscriptEditor it is recommended to follow the second option and import individual components like: @bbc/react-transcript-editor/TimedTextEditor rather than the entire library. Doing so pulls in only the specific components that you use, which can significantly reduce the amount of code you end up sending to the client. (Similarly to how react-bootstrap works)

Other Node Modules (non-react)

Some of these node modules can be used as standalone imports.

Export Adapter

Converts from draftJs json format to other formats

import exportAdapter from "@bbc/react-transcript-editor/exportAdapter";
STT JSON Adapter

Converts various stt json formats to draftJs

import sttJsonAdapter from "@bbc/react-transcript-editor/sttJsonAdapter";
Conversion modules to/from Timecodes

Some modules to convert to and from timecodes

import {
  secondsToTimecode,
  timecodeToSeconds,
  shortTimecode,
} from "@bbc/react-transcript-editor/timecodeConverter";

System Architecture

Documentation

There's a docs folder in this repository, which contains subdirectories to keep:

ADR

An architectural decision record (ADR) is a document that captures an important architectural decision made along with its context and consequences.

We are using this template for ADR

QA

There also QA testing docs to manual test the component before a major release, (QA testing does not require any technical knowledge).

Build

To transpile ./packages and create a build in the ./dist folder, run:

npm run build:component

To understand the build process, have a read through this.

Demo & storybook

To run locally, see setup.

Build - storybook

To build the storybook as a static site, run:

npm run build:storybook

This will produce a build folder containing the static site of the demo. To serve the build folder locally, run:

npm run build:storybook:serve

Publishing to a web page

Github Pages

We use github pages to host the storybook and the demo of the component. Make sure to add your changes to git, and push to origin master to ensure the code in master is reflective of what's online on Github Pages. When you are ready, re-publish the Storybook by running:

npm run deploy:ghpages

Tests

We are using jest for the testing framework. To run tests, run:

npm run test

For convenience, during development you can use:

npm run test:watch

and watch the test be re-run at every save.

Travis CI

On commit this repo uses the .travis.yml config to run the automated test on travis CI.

Publish to NPM

To publish to npm - @bbc/react-transcript-editor run:

npm publish:public

This runs npm run build:component and npm publish --access public under the hood, building the component and publishing to NPM.

Note that only README.md and the dist folders are published to npm.

Contributing

See CONTRIBUTING.md guidelines and CODE_OF_CONDUCT.md guidelines.

Licence

See LICENCE

Legal Disclaimer

Despite using React and DraftJs, the BBC is not promoting any Facebook products or other commercial interest.

react-transcript-editor's People

Contributors

bevand10 avatar chrisbaume avatar dependabot[bot] avatar emettely avatar jamesdools avatar laurian avatar murezzda avatar philmcmahon avatar pietrop avatar ranaharoni avatar sarahrainbow avatar shea12 avatar sshniro avatar terite avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

react-transcript-editor's Issues

Fast forward/rewind - bug

Describe the bug
Expecting Fast forward/rewind button to keep fast forwarding or rewinding if user keeps pressed.

To Reproduce
Steps to reproduce the behavior:

  1. Go to https://bbc.github.io/react-transcript-editor
  2. Click on Load Demo
  3. Click on ▶▶ and keep pressed on it
  4. See error - does not skip forward until you release

Expected behavior
if you keep pressed it should continue to skip forward (eg 10 sec increment) until you release, then it should stop

Screenshots
NA

Desktop (please complete the following information):

  • OS: Mac Os X High Sierrra
  • Browser : Chrome
  • Version: Version 70.0.3538.102 (Official Build) (64-bit)

Additional context
Might need the use of a timer to detect that the key is still pressed?

Note, that this works fine when calling fast forward/rewind with keyboard shortcuts.

Start video at text-cursor

Is your feature request related to a problem? Please describe.
In conjunction with #97, it would be great if the player can be started from the current word at the cursor position. This would allow for rapid navigation inside the video via keyboard.

Describe the solution you'd like
If the user starts the video via the alt+k shortcut, the video starts from the current cursor position instead of the current video position.

Additional context
As this feature alters the behaviour of the alt+k shortcut significantly, it might be good to put an option in the option menu to enable/disable this behaviour. Alternatively, another shortcut could be introduced for this feature, but I think this might increase the complexity of the application too much.

Integration with Speechmatics

The editor looks great. Thanks for this. I am looking for Speechmatics integration in this. Any plans to add that one? if not, some documentation on how to integrate it into this editor will be helpful. Thanks in advance.

Scroll Sync

A way to keep current word in view.
With toggle on/off.

Eg if you click on progress bar and the corresponding text is not on screen it should move the text to that point.

Eg As the media is playing the current corresponding line/word should stay in screen

Could this component work for Live use cases?

Is your feature request related to a problem? Please describe.
Low priority,

Could this component work getting as input

  • a live stream of audio or video for the media
  • and interim results for the STT

eg there are some provider like IBM, Speechmatics, AWS, etc.. that can return realtime STT results.

What would it take for this component to be able to handle this use case?
Or is it too much of a stretch and better of leaving that use case for another component that perhaps re-uses some of the logic etc..?

Describe the solution you'd like

The interim results could be appended at the end of the transcript?

Describe alternatives you've considered
Considering this outside of the scope of this component, and have a separate one to hanlde this use case.

Additional context
Low priority, just flagging it in case there's interest around this.

If initialising component with Transcript first and then Media local storage save/retrieve does not work

Describe the bug
A clear and concise description of what the bug is.

The component at a minimum needs two params to function properly and to be able to save to local storage:

  • media mediaUrl
  • transcript transcriptData (+ type)

as background saving to local storage uses the media url as a key.

  • Providing both at the same time <-- works

  • Providing first media then transcript <-- works

  • First transcript then media <-- breaks

To Reproduce
Steps to reproduce the behavior:

  1. Go to https://bbc.github.io/react-transcript-editor/
  2. Click on 'choose file' next to 'open Transcript Json'
  3. Click on 'choose file' Load Local Media'
  4. Click on text and edit, (add more then 5 char)
  5. refresh page
  6. repeat 1-5 and see the text added in step 4 is present
  7. if not, then this is the error

Expected behavior
A clear and concise description of what you expected to happen.

It would be preferable if the component could handle local storage save even if transcript is provided before the media is passed to it.

Additional context
Add any other context about the problem here.

Possible solution if Media not defined then transcript should wait to load until media is. Binding TranscriptEditor component to only work if both are present. this would also address #85

Mobile Responsive

It be great if the desktop layout could be mobile responsive

controls

Here's one possible view for mobile. with the 4 main blocks stacked in this order

  • Video Preview
  • Player Controls
  • Progress bar
  • TimedTextEditor

mobile

  • To be decided, is whether to have video preview element as fixed, and a toggle in settings to hide display of preview to gain more space for text on small screen.

Why not using a UI framework

Why don't we adopt a good framework like Semantic UI?

This change would address #28, #49 and #73, which I wasn't able to reproduce but it's a CSS thing so, yeah… 💯

It has pretty much all we need in terms of components:

Another option is to go with something like bootstrap, but either way, using an entire framework is a good idea in terms of UI consistency.

Both CSS frameworks can be made smaller by not including CSS rules of unused components.

Semantic UI Bootstrap 4
Framework size 91.8 KB 22.5 KB
Properly documented
Preprocessor Less Sass
Theming
React implementation ⚠️ unofficial package
Includes Icons

Suggested Layout change

Just a suggestion on layout change to maximise space of text. Pending discussion. And low priority.

Current layout as of PR #46

controls

The thinking here is that there is a fair bit of space between the player controls and the transcript title, that is essentially due to the height of the video preview element. And it's taking up space that could be used to increase the height of the TimedTextEditor.

So the suggestion to be discussed, would be to move the video player next to the TimedTexEditor, and below the player controls. As well as the progress bar over the player controls. - see balsamiq sketch below.

controls layout change

On a 15 inch Mac this might not make much of a difference, but on smaller size laptops or tablets(?) this change could be a bit more significant.

auto saving only on every 5 key strokes might lead to users loosing data

Describe the bug
A clear and concise description of what the bug is.

Expected behavior
A clear and concise description of what you expected to happen.

To save everything.

Additional context
Add any other context about the problem here.

Eg use a timer of a few seconds, that resets itself if the user keeps typing. and once they stop execute function to save to local storage.

Issue excluding files in bundle

As mentioned in these notes having some problem excluding files like test, sample etc.. from the build of the component. This means that the bundle size is bigger then it should be. This seems to be a babel 7 issue (?)

Raising it here as in issue in case someone has a nice workaround to sort this out.

`esc` key - shortcut for play/pause - crashes app

Describe the bug
Clicking on play/pause shortcut esc key crashes the app.

On PR - #18

To Reproduce
Steps to reproduce the behavior:

  1. Go to 'localhost:3006'
  2. Click on 'load demo'
  3. press key 'esc'
  4. See error - app should crash if error is still there

Expected behavior
Expecting esc to act shortcut for play/pause key.

Desktop (please complete the following information):

  • OS: Mac Os X High Sierrra
  • Browser : Chrome
  • Version: Version 70.0.3538.102 (Official Build) (64-bit)

Additional context
Add any other context about the problem here.

In the keyboard shortcut the function is called as self.playMedia();
src/lib/TranscriptEditor/MediaPlayer/defaultHotKeys.js#L5

However PlayMedia at /src/lib/TranscriptEditor/MediaPlayer/index.js#L167 needs some refactoring, as it's trying to accommodate for receiving input from TimedText Editor to pause and play for plause while typing functionality as well as for when clicking on play/pause button to pause if playing, and play if paused.

Clarification on how to create an Adapter for AWS Transcribe

I've forked the repo and I'm trying to create a new Adapter for AWS Transcribe formats but I'm having trouble understanding the recommended steps here https://github.com/bbc/react-transcript-editor/blob/master/docs/guides/adapters.md

The recommended steps are:

  1. Create a folder with the name of the STT service - eg speechmatics
  2. add a adapters/${sttServiceName}/sample folder
  3. add a sample json file from the STT service in this last folder - this will be useful for testing.
  4. Name it ${name of the stt service}.sample.json
  5. add option in adapters/index.js

I can see an adapters folder in the project here src/lib/Util/adapters .

Is this where we should begin with step 1? I'm assuming yes, but just want to make sure this is right.

Keyboard shortcut for changing playback rate "shift + up" - selects text

Describe the bug
Keyboard shortcut for changing playback rate shift + up arrow - selects text

To Reproduce

  • Go on demo app
  • click load demo
  • click in the Text editor
  • press shift + up arrow
  • you should see that it starts to select the text above, as well as increasing playback rate

Expected behavior
Not to select text, and to just increase playback rate

Screenshots
Pressing shift+up with cursor in text.

bug-playback-rate-shortcut

Desktop (please complete the following information):

  • OS: OSX
  • Browser Chrome and Firefox

Additional context

  • this also happens with shift + down when decreasing playback rate
  • Probably best solution is to change the keyboard shortcut combination (?) rather then disable the default behaviour of text selection

when saving to local storage -> double cliking on word does not play media when coming back

Describe the bug
when saving to local storage (after 5 key strokes).
doubleclik on word does not play media when coming back

To Reproduce
Steps to reproduce the behavior:

  1. load demo
  2. double click on word
  3. see it jump to corresponding point in media
  4. pause media
  5. type more then 5 char
  6. reload page
  7. load demo
  8. double click on a word
  9. does it jump to the corresponding point in the media? - if it doesn't there's the error.

Expected behavior
Expect that double clicking on word jumps to media, always.

Screenshots
NA
Desktop (please complete the following information):

  • OS: Mac Os X High Sierrra
  • Browser : Chrome
  • Version: Version 70.0.3538.102 (Official Build) (64-bit)

Additional context
There is a chance this might be a problem with how the data is exported from draftJs and saved into local storage and then re-imported into the component on the new visit.

Not able to save text on edit

Describe the bug
Not able to save text on edit

To Reproduce
Steps to reproduce the behaviour:

  1. Go to Demo page, http://localhost:3000/
  2. Click on 'load demo'
  3. Edit some incorrect text.
  4. double click on word before that text
  5. See error: when media plays over text you corrected it resets it back to before correction

Expected behavior
I'd expect the text changes to be preserved even when playing media.
Perhaps an issue with state/and draftjs in TimedTextEditor component ?

Screenshots

See gif for demonstration of error in action

draftjs-timed-text-not-saving-changes

Desktop (please complete the following information):

  • OS: Mac OS X 10.13.6
  • Browser: Chrome - Version 70.0.3538.77 (Official Build) (64-bit)
  • Version: 0.1.0

Word highlight only works with Kaldi

TL;DR: In the current implementation word highlight only works with Kaldi, and we have "lost" compatibility with importing other STT Json formats.

See line 168 in TimedTextEditor

const wordsArray = this.state.transcriptData.retval.words;

As explanation,

  • this.state.transcriptData can be different type of STT json.
  • we then use the adapter module to convert to draftJs data model
  • from then on we should reference draftJS data model to ensure compatibility with various formats
  • eg usingthis.state.editorState instead of this.state.transcriptData

Sudgestion is to re-write that function to pull out same data this.state.editorState content eg using getCurrentContent().
Might need to be converted with convertToRaw or there might be a better way to get the same data.

Mobile layout in parent component

Making a quick note, that when installing current version0.3.0 in a parent app that uses react-bootstrap the PlayerControls display: 'flex'; seems to be breaking the mobile view.

  • Mobile change: issue #49
  • and layout change: Issue #50 - PR #70

screen shot 2019-03-05 at 18 45 27

Zooming out reveals that the the PlayerControls width is effecting the overall layout.

screen shot 2019-03-05 at 18 45 36

When removing flex from PlayerControls, it seems to display "ok" , altho needs thinking through and grouping the elements.

screen shot 2019-03-05 at 18 47 55

Anyway, just a note to remember to revisit after PR #70 to see if after that layout change the problem is fixed

Restructuring the repo for easier componentisation

Hi all. I had a great chat with @pietrop today about this project, as I'm keen to contribute and use it at The Times. A few things came up, particularly around making the sub-components of the app available for re-use (as I'll want to bring a lot of my own UI and other logic for our use case, but would like to share the common bits). This issue is to discuss an approach to doing this.

Is your feature request related to a problem? Please describe.
As above, I'd like to make the sub-components of this app available for re-use. At present, it's pretty hard to only take the text editor, or the media player, without bringing the entire rest of the application.

Describe the solution you'd like
To achieve this, I'm proposing we transition the repo to a monorepo (powered by Lerna and Yarn Workspaces) with a small number of sub-packages, each of which can be pushed to NPM (or equivalent) as independent React components. This would allow for a consuming app (like mine) to install the components it needs, and bring it's own for the areas where either:
a) it needs something bespoke (e.g. user authentication, custom settings UI)
a) bbc/react-transcript-editor doesn't provide that feature, and it doesn't make sense for the overall roadmap
c) I want to replace a component for a one-off use case

Having tinkered with this, I roughly imagine we'd have the following packages in the monorepo:

  • @bbc-transcript-editor/app: A fully composed version of the app, which can be rendered in a standard create-react-app and allow someone with little-to-no desire the customise the app to get started
  • @bbc-transcript-editor/media-player: The media player, including all play/pause controls etc.
  • @bbc-transcript-editor/settings: The settings modal
  • @bbc-transcript-editor/timed-text-editor: The core DraftJS-based transcript editor
  • @bbc-transcript-editor/adapter-{FROM}-{TO}: A standardised set of adapters, replacing the existing adapter / converter logic (e.g. BBC Kaldi to DraftJS, or DraftJS to SRT).
  • @bbc-transcript-editor/context: A React.Context wrapper, the root of all instances of the Editor, which provides default global config options, allows developers to register active adapters, and handles the globally-utilised analytics callbacks. (To do this, all components would need to be updated so they were context-aware. This would be done more easily if we upgraded to React 16.8, as we would have access to the useContext hook).
  • @bbc-transcript-editor/util-{UTILITY_NAME}: A set of utility packages that are used across the app. (These could be a single utility package, depending on the extent of shared code)

Alongside this monorepo, I propose we use Storybook to provide a simple UI for exploring the available components, and a convenient development environment.

Describe alternatives you've considered
There are a number of possible blockers to a monorepo, including:

  • The BBC unable to namespace packages under @bbc-transcript-editor on NPM (would require senior signoff)
  • Unwillingness to use a monorepo solution. In this case, we could explore using a set of modular named exports, or sub-folders from one very large NPM package. These options do come with downsides

Equally, there are alternative tools to Storybook, a good example would be React Styleguidist.

Additional context
In the interest of getting some initial thoughts on this, I have forked bbc/react-transcript-editor and put together a very basic monorepo + Storybook app so contributors can get a feel for how it might look / work. All the details for that (screenshot + setup commands) can be found on this PR: chrishutchinson#1

Note: The above was thrown together in about an hour, so there are lots of rough edges, lazy copy-pastes, and temporary names. It's all for the purposes of the demo, a proper monorepo approach would tidy all of this up! 😄

alt+space keyboard shortcut for pause+play also adds a space

Describe the bug
alt+space is the current keyboard shortcut for pause+play.
when clicking alt+space if the cursor is in the text area it also adds a space

To Reproduce
Steps to reproduce the behavior:

  1. Go to https://bbc.github.io/react-transcript-editor/
  2. Click on load demo
  3. click / add cursor to text editing area
  4. click alt+space
  5. See error: there's an extra space beeing added

Expected behavior
if cursor in text editor area not to add a space when using alt + space

Screenshots

bug-alt-space-play-pause

Desktop (please complete the following information):

  • OS: OSX
  • Browser: Chrome

Additional context
Might be linked to #75 and #76 as possible solution

Foreign Language Support

Hello, thanks for this great project.

I was wondering if there is currently/if there are plans for foreign language support for this project? I saw there is an idea to support RTL languages, but I'm having a hard time finding where language support in general is. Thanks!

Unable to re-import draftJS content

Describe the bug
If I export the draftJS content as a json with blocks and entity maps using

To Reproduce
Steps to reproduce the behavior:

  1. npm start + Go to http://localhost:3006
  2. Click on 'Load Demo'
  3. change select to 'draftJs'
  4. Click on 'get Data from editor'
  5. get json --> You should get a json similar to this
{
"blocks": [
    {
      "key": "45ank",
      "text": "There is a day.",
      "type": "paragraph",
      "depth": 0,
      "inlineStyleRanges": [],
      "entityRanges": [
        {
          "offset": 0,
          "length": 1,
          "key": 0
        },
        {
          "offset": 5,
          "length": 2,
          "key": 1
        },
        {
          "offset": 8,
          "length": 1,
          "key": 2
        },
        {
          "offset": 10,
          "length": 4,
          "key": 3
        }
      ],
      "data": {
        "speaker": "TBC"
      }
    },

   ...

  ],
"entityMap": {
    "0": {
      "type": "WORD",
      "mutability": "MUTABLE",
      "data": {
        "offset": 0,
        "length": 1,
        "key": 0
      }
    },
    "1": {
      "type": "WORD",
      "mutability": "MUTABLE",
      "data": {
        "offset": 5,
        "length": 2,
        "key": 1
      }
    },
    "2": {
      "type": "WORD",
      "mutability": "MUTABLE",
      "data": {
        "offset": 8,
        "length": 1,
        "key": 2
      }
    },
    "3": {
      "type": "WORD",
      "mutability": "MUTABLE",
      "data": {
        "offset": 10,
        "length": 4,
        "key": 3
      }
    },
    "4": {
      "type": "WORD",
      "mutability": "MUTABLE",
      "data": {
        "offset": 0,
        "length": 5,
        "key": 4
      }
}
  1. if you then reload the page
  2. change select to 'draftjs'
  3. load the draft js json exported in step 5
  4. load a local video
  5. double click on word, you'd expect to jump to corresponding point it media. it doesn't

Expected behavior

as mentioned in point 11 when exporting and re-importing a draftJS json, double click on word, you'd expect to jump to corresponding point it media. it doesn't.

Screenshots
NA

Desktop (please complete the following information):

  • OS: Mac Os X High Sierrra
  • Browser : Chrome
  • Version: Version 70.0.3538.102 (Official Build) (64-bit)

Additional info*
see draftjs json exported from component example in attachment
blob_http___localhost_3006_5435b359-cc34-4d0f-b22d-d1c242846169.json.txt

Windows does not recognize the "PORT=3006" command in package.json

Describe the bug
If the project is currently startet under Windows 7, the following error occurs (error is in german because of OS language):

Der Befehl "PORT" ist entweder falsch geschrieben oder
konnte nicht gefunden werden.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @bbc/[email protected] start: "PORT=3006 react-scripts start"
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @bbc/[email protected] start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! [path_to_log_file]

To Reproduce

  1. Use Windows as OS.
  2. Run 'npm start' in the project folder.

Additional context
Using set PORT=3006 && react-scripts start instead of PORT=3006 react-scripts start in package.json fixes the problem for Windows, but might not work on UNIX Systems. Alternatively, environment variables could be stored in a .env file instead in package.json.

See also the following discussion: https://stackoverflow.com/questions/40714583/how-to-specify-a-port-to-run-a-create-react-app-based-project

How does this work - Tooltip

Is your feature request related to a problem? Please describe.
Users are not always clear that double clicking on a word plays the corresponding media.

Describe the solution you'd like
A help sheet/tooltip could help getting this accros.

Describe alternatives you've considered
There might be some other UX that is more immediate, but this will do as quick fix to test out for now.

Additional context
Here's the copy text and wireframe

screen shot 2018-12-21 at 16 56 17

Double click on a word or timestamp to jump to that point in the video.
Start typing to edit text.
You can add and change names of speakers in your transcript.
Jump to the time by typing in a new time.
Use keyboard shortcuts for quick control.
Save & export to get a copy to your desktop.

In context

screen shot 2018-12-21 at 17 11 33

Element ref was specified as a string (timedTextEditor) but no owner was set.

Describe the bug

I'm playing around with this awesome editor, and in one of my first tests was to import it into an existing project. I immediately got the following error:

Element ref was specified as a string (timedTextEditor) but no owner was set. This could happen for one of the following reasons:

  1. You may be adding a ref to a function component
  2. You may be adding a ref to a component that was not created inside a component's render method
  3. You have multiple copies of React loaded
    See https://fb.me/react-refs-must-have-owner for more information

I removed ref={ 'timedTextEditor' } within lib/TranscriptTextEditor/ line 274 and the error went away. Not sure if there's another underlying issue or if that's the correct solution.

To Reproduce
Import it into a new React Project

Expected behavior
No errors :)

Optional Speaker info using BBC kaldi diarization/segmentation info

Is your feature request related to a problem? Please describe.

At the moment speaker labels for BBC kaldi transcript are done on line break. This can add extra work when editing a transcript. Taking into account kaldi speaker diarization info the segmentation and speaker label could be more meaningful.

connected but separate feature from this project card

Describe the solution you'd like
When choosing BBC Kaldi adding optional Speaker info using BBC kaldi diarization/segmentation info.
If speaker info is provided in transcript json then use that info to add speaker label and group text.

Describe alternatives you've considered
NA

Additional context

  • speaker and transcript are produced by BBC kaldi as two separate json.

  • should be optional in case module is used with transcript from kaldi that does not have speaker labels, and then defaults to punctuation to break paragraphs.

  • BBC Kaldi segmentation example

{
	"metadata": {
		"version": "0.0.10"
	},
	"@type": "AudioFile",
	"speakers": [
		{
			"@id": "S0",
			"gender": "M"
		},
		{
			"@id": "S4",
			"gender": "M"
		},
		{
			"@id": "S7",
			"gender": "M"
		},
		{
			"@id": "S8",
			"gender": "F"
		}
	],
	"segments": [
		{
			"@type": "Segment",
			"start": 0.0,
			"duration": 15.57,
			"bandwidth": "S",
			"speaker": {
				"@id": "S0",
				"gender": "M"
			}
		},
		{
			"@type": "Segment",
			"start": 15.58,
			"duration": 11.73,
			"bandwidth": "S",
			"speaker": {
				"@id": "S0",
				"gender": "M"
			}
		},
		{
			"@type": "Segment",
			"start": 27.98,
			"duration": 8.43,
			"bandwidth": "S",
			"speaker": {
				"@id": "S4",
				"gender": "M"
			}
		},
		{
			"@type": "Segment",
			"start": 37.8,
			"duration": 4.12,
			"bandwidth": "S",
			"speaker": {
				"@id": "S4",
				"gender": "M"
			}
		},
		{
			"@type": "Segment",
			"start": 42.52,
			"duration": 4.2,
			"bandwidth": "S",
			"speaker": {
				"@id": "S7",
				"gender": "M"
			}
		},
		{
			"@type": "Segment",
			"start": 48.24,
			"duration": 11.79,
			"bandwidth": "S",
			"speaker": {
				"@id": "S8",
				"gender": "F"
			}
		}
	]
}
  • example of interpolating speaker with transcript in php by @bevand10 that can be used as starting point for node module
<?
function _KaldiToHtml($data, $timecode=false)
{
    $td=$data->commaSegments->transcription;
    $sd=$data->commaSegments->segmentation;

    # short out if we're just delivering the text
    if (!$timecode) return $td->punct;

    $spos=0;
    $kconfidence=0;
    $kword=0;
    $h='';
    $word=[];
    $speaker=_getspeaker($sd, $spos);
    $currentspeaker=$speaker->id;

    $h.=_newspeaker($speaker, $timecode);

    for ($i=0; $i<count($td->words); $i++) {

        $word=$td->words[$i];

        #if($i==0)file_put_contents('/tmp/djb1', serialize($word));

        $kword++;

        $kconfidence+=$word->confidence;

        if ($word->start < $speaker->to) {
            $h.=_formatword($word);
        } else {
            $spos++;
            $speaker=_getspeaker($sd, $spos);
            if ($currentspeaker!=$speaker->id) {
                $h.=_newspeaker($speaker, $timecode);
                $currentspeaker=$speaker->id;
            }
            $h.=_formatword($word);
        }
    }

    return array($h, $kword, sprintf("%0.2f", 100*($kconfidence/$kword)));
}

function _getspeaker($segments, $spos)
{
    $seg=$segments->segments[$spos];
    return (object)array(
        "from"=>$seg->start,
        "to"=>$seg->start + $seg->duration,
        "id"=>((array)$seg->speaker)['@id'],
    );
}

function _newspeaker($speaker, $timecode)
{
    $h="\n<p></p><div>";
    if ($timecode) {
        $h.="<a class=oj-tc data-from="
        .$speaker->from
        .">"
        .bbc::seconds2timecode($speaker->from)
        ." &nbsp; "
        .str_replace('S', 'Speaker: ', $speaker->id)
        ."</a>";
    }
    return "$h</div>\n";
}

function _formatword($word)
{
    $begin="<span data-st=\"".$word->start."\" data-en=\"".$word->end."\"";

    if ($word->confidence < 0.8)
    {
        return $begin." class=\"oj-lo\">".$word->punct."</span> ";
    }
    else
    {
        return $begin.">".$word->punct."</span> ";
    }
}
?>

Todo

  • get speaker diarization segments for Ted Talk Example
  • add optional speaker diarization and keep fallback on punctuation if not present to break paragraphs
  • add logic to interpolate paragraphs with speaker segments
  • test in demo app

When done

  • update version number
  • publish npm
  • update github pages demo

Moving cursor in text puts focus on timestamp and speaker labels

Is your feature request related to a problem? Please describe.
When the cursor is moved via arrow keys in the editor-box, it is not possible to quickly move between paragraphs, as the cursor will first move to the timestamp and the speaker label, both which cannot be edited. This hinders quick movement inside the text via keyboard.

Describe the solution you'd like
Timestamps and speaker labels will no longer come into focus if the curser is moved inside the text area.

Additional context
This feature would help make the editor better usable only via keyboard.

Issue when building component

After running build:component and importing this package as a local module to a create-react-app app, my app fails to compile and I get the following error after I try to import it as
import { TranscriptEditor } from '../libs/TranscriptEditor';

/src/libs/TranscriptEditor/TranscriptEditor/Settings/Shortcuts.js
Line 1: Expected an assignment or function call and instead saw an expression no-unused-expressions
Line 1: Expected an assignment or function call and instead saw an expression no-unused-expressions
Line 1: Expected an assignment or function call and instead saw an expression no-unused-expressions

I've been going around in circles about this issue.

I've removed a bunch of features, hence the need to use a local module instead. I've been doing dev using npm link and building component from the editor dev project but once built I'm failing to import it.

Any guidance would be appreciated. Thanks!

Set timecode offset

Describe the bug
When setting a timecode offset, you'd expect that when you click Jump to timecode it should take into account the offset.

To Reproduce
Steps to reproduce the behavior:

  1. Go to https://bbc.github.io/react-transcript-editor
  2. Click on Load Demo
  3. Click on Set Timecode Offset and type01:01:00:00
  4. Click on Jump To Timecode and type 2.3 (equivalent to 00:02:03:00)
  5. You expect to see 01:03:03:00(00:02:03:00 + 01:01:00:00)

Expected behavior
it should take into account the timecode offset.

Screenshots
After jumping to timecode expecting to see this
screen shot 2018-11-19 at 17 40 43

Desktop (please complete the following information):

  • OS: Mac Os X High Sierrra
  • Browser : Chrome
  • Version: Version 70.0.3538.102 (Official Build) (64-bit)

Player controls & settings panel - distinction

Proposed distinction of what functionalities to put under Player controls which once under the settings panel - see balsamiq mockup.

Guiding principle is one of setup things might be under settings, things you might want/need to change more often under main player controls. (+keyboard shortcuts)

controls

Initially mentioned under PR #46

recap of functionalities

Just a quick re-cap of the separation of functionalities into main control bar, settings panel shortcut tips.

Main control bar

  • rollback
  • rewind
  • fast forward - see issue #47
  • timecode display
  • Jump to time functionality - by clicking on timecode - possibly with tool tip to flag option?
  • duration display
  • playback speed indication x1
  • playback speed control - dropdown to change based on presets (or range with bars?)
  • reset playback speed ( Eg on playback speed indication + tooltip?) might not be needed if it's a drop down.

Settings

  • roll back customisable amount
  • pause while typing toggle
  • scroll sync toggle
  • adjust time-code offset
  • hide timecodes (Toggle?) - #52
  • hide speaker names (Toggle?) - #52

cheat sheets

  • Keyboard shortcut cheat sheet
  • How does this work - cheat sheet

clicking on playback rate select doesn't work in firefox on mac

Describe the bug
clicking on playback rate select doesn't work in firefox on mac

To Reproduce
Open demo app in firefox on a mac, and try to change the playback rate by clicking playback rate on playback rate display select element

Expected behavior

Expect drop down to show

Desktop (please complete the following information):

  • OS: OSX
  • Browser Firefox

Additional context
Works fine on chrome on a mac

Display time "moves" during time update

Describe the bug

To Reproduce

  • Load a transcript and click play
  • watch the display time

Expected behavior

expect it not to move

Screenshots

bug-time-display

Additional context

Might be a quick CSS fix?

Question and possible issue - initialising transcript component

Hi guys, so I've been experiencing an issue with local transcripts and hope you could help me understand a bit more what could be happening and if my approach is correct.

My previously edited local transcripts weren't loading, (due to the fact my mediaUrls contains a session signature appended to it which change periodically). After searching for localStorage load/save methods and updating this.props.mediaUrl to this.props.fileName, things still didn't work, unless I also update the componentDidUpdate lifecyle under TranscriptEditor.

Once I also updated prevProps.mediaUrl within this method my local transcripts started loading successfully. The problem then is that every time I started editing a transcript, the cursor started jumping to the beginning of the editor, and I could see in the console these repeated messages:

Transcript first and then media 
was already present in local storage...  

as the method keeps updating/executing it seems to be checking if the transcript is available locally - so I'm not understanding the purpose of why this code is under the componentDidUpdate method (or purpose of it, and the repetition under different conditions).

componentDidUpdate(prevProps, prevState) {
    // Transcript and media passed to component at same time
    if (
      (prevState.transcriptData !== this.state.transcriptData)
        && (prevProps.mediaUrl !== this.props.fileName )
    ) {
      console.info('Transcript and media');
      this.ifPresentRetrieveTranscriptFromLocalStorage();
    }
    // Transcript first and then media passed to component
    else if (
      (prevState.transcriptData === this.state.transcriptData)
      && (prevProps.mediaUrl !== this.props.mediaUrl)
    ) {
      console.info('Transcript first and then media');
      this.ifPresentRetrieveTranscriptFromLocalStorage();
    }
    // Media first and then transcript passed to component
    else if (
      (prevState.transcriptData !== this.state.transcriptData)
      && (prevProps.mediaUrl === this.props.fileName)
    ) {
      console.info('Media first and then transcript');
      this.ifPresentRetrieveTranscriptFromLocalStorage();
    }
  }

don't know if these same changes (from mediaUrl -> fileName) caused an unexpected behaviour, but having this check running on every single update doesn't seem right.

I've already applied a solution to the issue by running the isPresentInLocalStorage method once during the componentDidMount lifecyle method instead, and I can edit my transcripts without hiccups. But I'm not sure if I'm missing something that you guys had in mind with the above code.

Don't know if this could be a section we could improve - and if there's scope also to provide an alternative prop to be used as title for localStorage as well.

Thanks!

Put focus on text when pause via shortcuts

Is your feature request related to a problem? Please describe.
If the player is stopped via keyboard shortcut, the focus will not be on the text and it is not possible to quickly edit the script only via shortcuts.

Describe the solution you'd like
Upon pausing the player via shortcuts, the curser will be set to the word corresponding to the current timestamp. This allows for a quick correction of false transcribed words.

Describe alternatives you've considered
The alternative is to rely on the autoscroll feature and manually move the focus after pausing.

Additional context
It would be great if the player was usable only via keyboard, as this would speed up the correction of the transcript.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.