Changeset 35456


Ignore:
Timestamp:
2021-09-23T16:52:55+12:00 (3 years ago)
Author:
cstephen
Message:

Hoist active word

Location:
main/trunk/model-interfaces-dev/atea/korero-maori-asr/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/model-interfaces-dev/atea/korero-maori-asr/src/components/TranscriptionItemEditor.vue

    r35455 r35456  
    2020    </div>
    2121
    22     <word-timing-selector :surroundingWords="surroundingWords" :word="selectedWord" :wordIndex="selectedIndex" />
     22    <word-timing-selector class="word-timing-selector" :surroundingWords="surroundingWords" :word="selectedWord" />
    2323
    2424    <div class="editor-controls">
     
    6060
    6161.word-highlight-applied {
    62     background-color: rgba(255, 255, 0, 0.4);
     62    background-color: var(--highlighted-word-bg);
    6363}
    6464
     
    7575    font-family: inherit;
    7676    font-size: 1rem;
     77}
     78
     79.word-timing-selector {
     80    margin: 0.5em auto;
    7781}
    7882</style>
     
    171175            }
    172176
    173             const words = this.words.slice(min, max);
    174             // words.splice(index - min, 1); // Remove the index word, as it is not a 'surrounding' word
    175 
    176             return words;
     177            return this.words.slice(min, max);
    177178        },
    178179        /**
     
    200201        },
    201202        onEditorFocus(index) {
    202             const wordStartTime = this.words[index].startTime + 0.01;
    203             this.$store.commit("playbackStateSetTime", { id: this.transcription.id, time: wordStartTime });
     203            if (this.playbackState.currentTime < this.words[index].startTime || this.playbackState.curentTime > this.words[index].endTime) {
     204                const wordStartTime = this.words[index].startTime + 0.01;
     205                this.$store.commit("playbackStateSetTime", { id: this.transcription.id, time: wordStartTime });
     206            }
     207
    204208            this.selectedIndex = index;
    205209        },
  • main/trunk/model-interfaces-dev/atea/korero-maori-asr/src/components/WordTimingSelector.vue

    r35455 r35456  
    44
    55    <div class="words-container" ref="wordsContainer">
    6         <input type="range" class="slider-continuous" ref="slider" />
    7 
    8         <div class="surround-word" v-for="word in mySurroundingWords" :key="word.id" :style="{ left: word.left, width: word.length }">
     6        <div class="word" v-for="word in mySurroundingWords" :key="word.id" :style="{ left: word.left, width: word.length }"
     7            :class="[ shouldHoist(word) ? 'hoisted' : 'surround-word' ]">
    98            <span>{{ word.word }}</span>
    109        </div>
     
    1918    display: flex;
    2019    align-items: center;
     20    justify-content: center;
    2121    gap: 1em;
     22    height: 3em;
    2223}
    2324
    2425.words-container {
    25     flex-grow: 0.5;
     26    flex-grow: 0.6;
    2627    position: relative;
    27     height: 2.5em;
     28    height: 1.5em;
    2829}
    2930
    30 .surround-word {
     31.word {
    3132    position: absolute;
    3233    text-align: center;
     
    3940    background-color: rgba(var(--bg-color-raw), 0.3);
    4041    border: 1px solid rgba(var(--bg-color-raw), 0.6);
     42}
     43
     44.surround-word {
     45    top: 50%;
     46}
     47
     48.hoisted {
     49    top: -50%;
     50    background-color: var(--highlighted-word-bg);
    4151}
    4252</style>
     
    6272        surroundingWords: Array,
    6373        word: { word: String, startTime: Number, endTime: Number },
    64         wordIndex: Number,
    6574        upperBound: Number
    6675    },
     
    9099    watch: {
    91100        surroundingWords() {
    92             this.scaleWords();
     101            this.getMySurroundingWords();
    93102        }
    94103    },
    95104    methods: {
    96         scaleWords() {
     105        getMySurroundingWords() {
    97106            if (!this.isMounted) {
    98107                return;
     
    105114
    106115            const audioLength = this.surroundingWords[this.surroundingWords.length - 1].endTime - this.surroundingWords[0].startTime;
    107             const sliderLengthPx = this.$refs.slider.offsetWidth;
     116            const sliderLengthPx = this.$refs.wordsContainer.offsetWidth;
    108117
    109118            const scalingFactor = sliderLengthPx / audioLength;
     
    118127            }
    119128
     129            // myWords.splice(this.surroundingWords.indexOf(this.word), 1);
    120130            this.mySurroundingWords = myWords;
     131        },
     132        shouldHoist(word) {
     133            return word.startTime === this.word.startTime;
    121134        }
    122135    },
    123136    mounted() {
    124137        this.isMounted = true;
    125         this.scaleWords();
     138        this.getMySurroundingWords();
    126139    }
    127140}
  • main/trunk/model-interfaces-dev/atea/korero-maori-asr/src/styles/theme.scss

    r35449 r35456  
    1616    --monospace-font: 1rem 'Roboto Mono', sans-serif;
    1717    --page-bg-color: #f7f4f0;
     18    --highlighted-word-bg: rgba(255, 255, 0, 0.4);
    1819}
    1920
Note: See TracChangeset for help on using the changeset viewer.