Changeset 35455 for main


Ignore:
Timestamp:
2021-09-23T15:07:13+12:00 (3 years ago)
Author:
cstephen
Message:

Properly identify surrounding words

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

Legend:

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

    r35454 r35455  
    2020    </div>
    2121
    22     <word-timing-selector :surroundingWords="getSurroundingWords()" />
     22    <word-timing-selector :surroundingWords="surroundingWords" :word="selectedWord" :wordIndex="selectedIndex" />
    2323
    2424    <div class="editor-controls">
     
    127127            enableEditing: false,
    128128            words: [],
    129             lastHighlightedWordIndex: 0
     129            lastHighlightedWordIndex: 0,
     130            selectedIndex: 0
    130131        }
    131132    },
     
    142143            return this.$store.getters.transcriptionPlaybackLength(this.transcription.id);
    143144        },
     145        surroundingWords() {
     146            return this.getSurroundingWords(this.selectedIndex);
     147        },
     148        selectedWord() {
     149            return this.words[this.selectedIndex];
     150        },
    144151        ...mapState({
    145152            playbackState: state => state.playbackState,
     
    151158            await AudioPlayback.play(this.transcription.id, startTime);
    152159        },
    153         getSurroundingWords() {
    154             return this.words.slice(2, 7);
     160        getSurroundingWords(index) {
     161            const BUFFER = 2; // The number of words to take on each side
     162
     163            let min = index;
     164            for (let i = index; i > index - BUFFER && i > 0; i--) {
     165                min--;
     166            }
     167
     168            let max = index + 1;
     169            for (let i = index; i < index + BUFFER && i < this.words.length; i++) {
     170                max++;
     171            }
     172
     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;
    155177        },
    156178        /**
     
    180202            const wordStartTime = this.words[index].startTime + 0.01;
    181203            this.$store.commit("playbackStateSetTime", { id: this.transcription.id, time: wordStartTime });
     204            this.selectedIndex = index;
    182205        },
    183206        onEditorFocusOut(index) {
     
    273296                if (word.startTime < newValue && word.endTime > newValue) {
    274297                    word.shouldHighlight = true;
     298
     299                    if (this.$refs[word.id]) {
     300                        this.$refs[word.id].focus();
     301                    }
     302
    275303                    this.lastHighlightedWordIndex = i;
    276304                    break;
  • main/trunk/model-interfaces-dev/atea/korero-maori-asr/src/components/WordTimingSelector.vue

    r35454 r35455  
    6262        surroundingWords: Array,
    6363        word: { word: String, startTime: Number, endTime: Number },
     64        wordIndex: Number,
    6465        upperBound: Number
    6566    },
Note: See TracChangeset for help on using the changeset viewer.