diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2020-10-12 17:15:33 +0200 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2020-10-12 17:15:33 +0200 |
| commit | 3fbc92d236e243ad23b0bba8aa7399ea2384b1cd (patch) | |
| tree | 2b9acf547393bd29e83e3eab2c0cfc576c7b629b | |
| parent | fee9c2fccc2a059d8307c789c110e38f3c3727df (diff) | |
hopefully fixing seek issues not already fixed by CBR
5 files changed, 26 insertions, 30 deletions
diff --git a/animism-align/README.md b/animism-align/README.md index 045751e..9cdb949 100644 --- a/animism-align/README.md +++ b/animism-align/README.md @@ -11,6 +11,20 @@ conda create env -f environment.yml npm install ``` +## Generating waveform peaks + +Make sure your source sound is encoded as a 192 kbps CBR MP3: + +``` +ffmpeg -i original.wav -b:a 192k ../data_store/peaks/episode_99.mp3 +``` + +Then generate the peaks: + +``` +./cli.py peaks parse -i original.wav +``` + ## Running the site Before running the commands, enter the client directory, load the Conda environment, and make sure the database is current: diff --git a/animism-align/cli/commands/peaks/parse.py b/animism-align/cli/commands/peaks/parse.py index f5b36a4..da183f4 100644 --- a/animism-align/cli/commands/peaks/parse.py +++ b/animism-align/cli/commands/peaks/parse.py @@ -26,14 +26,15 @@ def cli(ctx, fp_in): print(f"Loading {fp_in}") y, sr = librosa.load(fp_in, sr=None) - sr_10 = math.ceil(sr / 10) + sr_10 = sr / 10 steps = math.ceil(y.shape[0] / sr_10) peaks = numpy.ndarray(steps) for i in range(steps): - offset = i * sr_10 - slice = y[offset:offset + sr_10] + offset_start = math.floor(i * sr_10) + offset_end = math.ceil((i + 1) * sr_10) + slice = y[offset_start:offset_end] peak = max(abs(slice.min()), slice.max()) peaks[i] = float('%.3f' % peak) # peaks[i * 2 + 1] = float('%.3f' % slice.max()) diff --git a/animism-align/frontend/app/views/align/align.actions.js b/animism-align/frontend/app/views/align/align.actions.js index 6074b34..6eca0a7 100644 --- a/animism-align/frontend/app/views/align/align.actions.js +++ b/animism-align/frontend/app/views/align/align.actions.js @@ -1,13 +1,12 @@ import * as types from 'app/types' -import { store, history, dispatch } from 'app/store' -import { api } from 'app/utils' +import { store } from 'app/store' import actions from 'app/actions' // import { session } from 'app/session' import throttle from 'lodash.throttle' import debounce from 'lodash.debounce' import { ZOOM_STEPS } from 'app/constants' -import { getFirstPunctuationMarkIndex, cutFirstSentence } from 'app/utils/align.utils' +import { cutFirstSentence } from 'app/utils/align.utils' export const setScrollPosition = start_ts => dispatch => ( dispatch({ type: types.align.set_display_setting, key: 'start_ts', value: start_ts }) @@ -27,16 +26,16 @@ export const setCursor = cursor_ts => dispatch => ( ) export const setSelectedAnnotation = annotation => dispatch => { - dispatch({ type: types.align.set_selected_annotation, data: annotation }) debouncedUpdateAnnotation.flush() + dispatch({ type: types.align.set_selected_annotation, data: annotation }) } export const clearSelectedAnnotation = () => dispatch => { - dispatch({ type: types.align.clear_selected_annotation }) debouncedUpdateAnnotation.flush() + dispatch({ type: types.align.clear_selected_annotation }) } export const updateSelectedAnnotation = annotation => dispatch => { - dispatch({ type: types.align.set_selected_annotation, data: { ...annotation } }) debouncedUpdateAnnotation(annotation) + dispatch({ type: types.align.set_selected_annotation, data: { ...annotation } }) } export const debouncedUpdateAnnotation = debounce(annotation => { console.log('updating annotation', annotation) @@ -47,7 +46,7 @@ export const debouncedUpdateAnnotation = debounce(annotation => { export const setSelectedParagraph = paragraph_id => dispatch => { dispatch({ type: types.align.set_display_setting, key: 'selected_paragraph_id', value: paragraph_id }) } -export const clearSelectedParagraph = paragraph_id => dispatch => { +export const clearSelectedParagraph = () => dispatch => { dispatch({ type: types.align.set_display_setting, key: 'selected_paragraph_id', value: -1 }) } diff --git a/animism-align/frontend/app/views/align/containers/annotations.container.js b/animism-align/frontend/app/views/align/containers/annotations.container.js index 7a2cf79..167ae3a 100644 --- a/animism-align/frontend/app/views/align/containers/annotations.container.js +++ b/animism-align/frontend/app/views/align/containers/annotations.container.js @@ -1,15 +1,6 @@ import React, { Component } from 'react' -// import { Link } from 'react-router-dom' -import { bindActionCreators } from 'redux' import { connect } from 'react-redux' -import actions from 'app/actions' -// import * as alignActions from '../align.actions' - -import { ZOOM_STEPS } from 'app/constants' -import { clamp } from 'app/utils' -import { positionToTime } from 'app/utils/align.utils' - import AnnotationForm from 'app/views/align/components/annotations/annotation.form' import AnnotationIndex from 'app/views/align/components/annotations/annotation.index' @@ -34,7 +25,4 @@ const mapStateToProps = state => ({ annotation: state.align.annotation, }) -const mapDispatchToProps = dispatch => ({ -}) - -export default connect(mapStateToProps, mapDispatchToProps)(Annotations) +export default connect(mapStateToProps)(Annotations) diff --git a/animism-align/frontend/app/views/align/containers/timeline.container.js b/animism-align/frontend/app/views/align/containers/timeline.container.js index 3d3cc33..d1917b5 100644 --- a/animism-align/frontend/app/views/align/containers/timeline.container.js +++ b/animism-align/frontend/app/views/align/containers/timeline.container.js @@ -1,6 +1,5 @@ import React, { Component } from 'react' // import { Link } from 'react-router-dom' -import { bindActionCreators } from 'redux' import { connect } from 'react-redux' import actions from 'app/actions' @@ -9,7 +8,6 @@ import Annotations from 'app/views/align/containers/annotations.container' import Waveform from 'app/views/align/components/timeline/waveform.component' import Ticks from 'app/views/align/components/timeline/ticks.component' import Cursor from 'app/views/align/components/timeline/cursor.component' -import PlayButton from 'app/views/align/components/player/playButton.component' import PlayCursor from 'app/views/align/components/timeline/playCursor.component' import { WAVEFORM_SIZE, ZOOM_STEPS, INNER_HEIGHT } from 'app/constants' @@ -163,8 +161,4 @@ const mapStateToProps = state => ({ text: state.site.text, }) -const mapDispatchToProps = dispatch => ({ - // alignActions: bindActionCreators({ ...alignActions }, dispatch), -}) - -export default connect(mapStateToProps, mapDispatchToProps)(Timeline) +export default connect(mapStateToProps)(Timeline) |
