Changeset 35542
- Timestamp:
- 2021-10-01T15:01:09+13:00 (3 years ago)
- 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
r35541 r35542 20 20 </div> 21 21 22 <word-timing-selector class="word-timing-selector" :surroundingWords="surroundingWords" :word="selectedWord" v-if="enableEditing" />22 <word-timing-selector class="word-timing-selector" :surroundingWords="surroundingWords" v-model:word="selectedWord" v-if="enableEditing" /> 23 23 24 24 <div class="editor-controls"> … … 97 97 * @param {Number} endTime The time within the audio that this word finishes being spoken. 98 98 */ 99 constructor(word, startTime, endTime ) {99 constructor(word, startTime, endTime, id = null, shouldHighlight = false, deletionAttempts = 0) { 100 100 /** @type {String} The ID of this word. */ 101 this.id = Util.generateUuid();101 this.id = id ?? Util.generateUuid(); 102 102 103 103 /** @type {String} The word. */ … … 111 111 112 112 /** @type {Boolean} A value indicating whether this word should be highlighted. */ 113 this.shouldHighlight = false;113 this.shouldHighlight = shouldHighlight; 114 114 115 115 /** @type {Number} The number of times the user has tried to delete this word. */ 116 this.deletionAttempts = 0;116 this.deletionAttempts = deletionAttempts; 117 117 } 118 118 } … … 150 150 return this.getSurroundingWords(this.selectedIndex); 151 151 }, 152 selectedWord() { 153 return this.words[this.selectedIndex]; 152 selectedWord: { 153 get() { 154 return this.words[this.selectedIndex]; 155 }, 156 set(value) { 157 this.words[this.selectedIndex] = value; 158 } 154 159 }, 155 160 ...mapState({ -
main/trunk/model-interfaces-dev/atea/korero-maori-asr/src/components/WordTimingSelector.vue
r35540 r35542 77 77 78 78 <script> 79 import { Word as TWord } from "./TranscriptionItemEditor.vue" 79 80 import Util from "../js/Util" 80 81 … … 97 98 name: "WordTimingSelector", 98 99 props: { 99 /** @type {Array< { word: String, startTime: Number, endTime: Number }>} */100 /** @type {Array<TWord>} */ 100 101 surroundingWords: Array, 101 word: { word: String, startTime: Number, endTime: Number },102 word: TWord, 102 103 upperBound: Number 103 104 }, … … 106 107 isMounted: false, 107 108 /** @type {Array<Word>} */ 108 mySurroundingWords: [],109 // mySurroundingWords: [], 109 110 canShiftMinValue: false, 110 111 canShiftMaxValue: false, … … 142 143 }, 143 144 audioSnippetLength() { 144 return this.surroundingWords[this.surroundingWords.length - 1].endTime - this.surroundingWords[0].startTime; 145 if (this.surroundingWords.length === 0) { 146 return 0; 147 } 148 else { 149 return this.surroundingWords[this.surroundingWords.length - 1].endTime - this.surroundingWords[0].startTime; 150 } 145 151 }, 146 152 /** … … 157 163 wordLeftOffsetPx() { 158 164 return this.surroundingWords[0].startTime * this.scalingFactor; 159 } 160 }, 161 watch: { 162 surroundingWords() { 163 this.mySurroundingWords = this.convertSurroundingWords(); 165 }, 166 mySurroundingWords() { 167 const myWords = []; 168 169 if (this.surroundingWords.length === 0) { 170 return myWords; 171 } 172 173 for (const word of this.surroundingWords) { 174 myWords.push(this.convertWord(word)); 175 } 176 177 return myWords; 164 178 } 165 179 }, … … 188 202 }, 189 203 shouldHoist(word) { 190 return word && this.word && word.startTime === this.word.startTime && word.word === this.word.word;204 return word === this.myWord; 191 205 }, 192 206 /** … … 198 212 } 199 213 200 const word = this.my Word;214 const word = this.mySurroundingWords[this.wordIndex]; 201 215 202 216 if (event.movementX < 0 && word.left + event.movementX < 0) { … … 208 222 } 209 223 210 word.left += event.movementX;224 this.mySurroundingWords[this.wordIndex].left += event.movementX; 211 225 word.length -= event.movementX; 212 226 }, … … 229 243 230 244 word.length += event.movementX; 245 this.myWordToWord(); 231 246 }, 232 247 onHandleMouseUp() { 233 248 this.canShiftMinValue = false; 234 249 this.canShiftMaxValue = false; 250 }, 251 myWordToWord() { 252 const pxLeft = this.myWord.left; 253 const pxRight = this.myWord.left + this.myWord.length; 254 255 const startTime = (pxLeft + this.wordLeftOffsetPx) / this.scalingFactor; 256 const endTime = (pxRight + this.wordLeftOffsetPx) / this.scalingFactor; 257 258 const word = new TWord(this.word.word, startTime, endTime, this.word.id, this.word.shouldHighlight, this.word.deletionAttempts); 259 this.$emit("update:word", word); 235 260 } 236 261 }, … … 240 265 mounted() { 241 266 this.isMounted = true; 242 this.mySurroundingWords = this.convertSurroundingWords();243 267 } 244 268 }
Note:
See TracChangeset
for help on using the changeset viewer.