pietrop / slate-transcript-editor

A React component to make correcting automated transcriptions of audio and video easier and faster. Using the SlateJs editor.
https://pietrop.github.io/slate-transcript-editor
Other
76 stars 33 forks source link

Slate transcript editor

Work in progress

Building on the success and lessons learned from @bbc/react-transcript-editor. Mostly to be used in the context of autoEdit 3(digital paper edit), and other proejcts.

Criterias/Principles

See project board for more details of ongoing work.

See draftJs vs slateJs in doc/notes for some considerations that inspired this version.

Storybook

Setup

git clone git@github.com:pietrop/slate-transcript-editor.git
cd slate-transcript-editor
npm install

Usage

Usage - dev

npm run storybook

or

npm start

Visit http://localhost:6006/

Usage - prod

slate-transcript-editor

npm install slate-transcript-editor
import  SlateTranscriptEditor  from 'slate-transcript-editor';

<SlateTranscriptEditor
  mediaUrl={DEMO_MEDIA_URL}
  transcriptData={DEMO_TRANSCRIPT}
  handleSaveEditor=// optional - function to handle when user clicks save btn in the UI
  />

or with more options, see table below

See storybook *.stories.js in src/components/ for more examples

Attributes Description required type
transcriptData Transcript json yes Json
mediaUrl string url to media file - audio or video yes String
handleSaveEditor function to handle when user clicks save btn in the UI no Function
handleAutoSaveChanges returns content of transcription after there's a change, auto save has condierable performance lag on longer files, sudgest to not use for files over 45 min/1hour. no Function
autoSaveContentType specify the file format for data returned by handleAutoSaveChanges and handleSaveEditor,falls default to digitalpaperedit, and runs alignement before export. Other option is slate,without alignement. no String
isEditable set to true if you want to be able to edit the text no Boolean
showTimecodes set to true if you want to show timecodes in the transcript at paragraph level no Boolean
showSpeakers set to true if you want to show speaker labels in the transcript at paragraph level no Boolean
title defaults to empty String, also used in file names for exported files. no String
showTitle Whether to display the provided title no String
handleAnalyticsEvents optional function to log analytics, returns event name as string, and some data as object associated with that event, see storybook for example no Function
optionalBtns optional buttons or react components can be passed to the sidebar see storybook for example no Jsx

see storybook for example code

Adapters

System Architecture

Customizing look and feel

The project uses material-ui. The style of the components is therefore self contained and does not reequire any additional stylesheet.

Theming

You can use material-ui's Theming and colors

Examples
Theming a whole CRA app ```js import React from 'react'; import ReactDOM from 'react-dom'; import './index.css'; import App from './App'; import { BrowserRouter } from 'react-router-dom'; // Material UI Theme provider import { createMuiTheme, ThemeProvider } from '@material-ui/core/styles'; // You can use material UI color design tokens, your own or color hex value import { blue, indigo, green, purple } from '@material-ui/core/colors'; import 'fontsource-roboto'; // customize yout theme as much or as little as you want const theme = createMuiTheme({ palette: { background: { // paper: '#424242', // default: '#303030', }, primary: { main: purple, }, secondary: { main: green, }, }, }); ReactDOM.render( <> , document.getElementById('root') ); ```
Theming only the Slate Transcript Editor, in a parent component ```js import React from 'react'; // Material UI Theme provider import { createMuiTheme, ThemeProvider } from '@material-ui/core/styles'; // You can use material UI color design tokens, your own or color hex value import { blue, indigo, green, purple } from '@material-ui/core/colors'; // optional fonts import 'fontsource-roboto'; // customize yout theme as much or as little as you want const theme = createMuiTheme({ palette: { background: { // paper: '#424242', // default: '#303030', }, primary: { main: purple, }, secondary: { main: green, }, }, }); function TranscriptPage(props) { // some state and functions handlers for `TranscriptEditor` // eg `handleSave` const handleSave = (data) => { // Do something with the data eg save }; return ( ); } export default TranscriptPage; ```

Documentation

There's a docs folder in this repository.

The docs folder syncs with gitbook to make the documentation more pleasent to browse at autoedit.gitbook.io/slate-transcript-editor-docs/ - Work in progress

The doc folder syncs with gitbook for ease of browsing at gitbook slate-transcript-editor-docs

Development env

If you have nvm you can run nvm use to change to the node version for this repo.

Linting

This repo uses prettier for linting. If you are using visual code you can add the Prettier - Code formatter extension, and configure visual code to do things like format on save.

You can also run the linting via npm scripts

npm run lint

and there's also a pre-commit hook that runs it too.

Build

build module

Following storybook Distribute UI across an organization guide.

build storybook

nvm use 12
npm run build-storybook

Tests

nvm use 14
npm run test

🚧 Wok in progress 🚧

(for now only localized to CSV composer module - and not fully working)

Deployment

Deployment module

To publish module to npm

npm run publish:public

and for a test run use

npm run publish:dry:run

Deployment storybook

To publish storybook to github pages

npm run deploy:ghpages