Changeset 35432 for main/trunk
- Timestamp:
- 2021-09-20T15:13:08+12:00 (3 years ago)
- Location:
- main/trunk/model-interfaces-dev/atea/korero-maori-asr/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/model-interfaces-dev/atea/korero-maori-asr/src/App.vue
r35431 r35432 17 17 </div> 18 18 19 <div v-if="showInfo" class=" card border-accent">19 <div v-if="showInfo" class="paper"> 20 20 A tool to transcribe audio recordings of spoken MÄori. Basic support for editing the transcriptions is provided, 21 21 and they can be downloaded in multiple formats. … … 81 81 .transcription-list-item { 82 82 transition: all 0.8s ease; 83 margin-bottom: 1em; 84 85 &:last-child { 86 margin-bottom: 0; 87 } 83 88 } 84 89 -
main/trunk/model-interfaces-dev/atea/korero-maori-asr/src/components/AudioUpload.vue
r35429 r35432 138 138 this.isTranscribing = true; 139 139 140 await getTranscriptions(this.files, this.$store, this);140 await this.getTranscriptions(this.files); 141 141 142 142 this.files = []; // Clear the file list, as there is no reason the user would want to transcribe the same file multiple times over … … 152 152 dismissFailure(id) { 153 153 this.failures.delete(id); 154 }, 155 /** 156 * Gets the transcription of each submitted audio file. 157 * @param {File[]} files The files to transcribe. 158 */ 159 async getTranscriptions(files) { 160 await Util.delay(1000); // TODO: Remove - UI testing purposes only 161 162 try { 163 for await (const batch of transcribeService.batchTranscribeFiles(files)) { 164 for (const t of batch) { 165 if (!t.success) { 166 createFailure(this, t); 167 } 168 else { 169 const f = files.find(f => f.name === t.file_name); 170 if (f === undefined) { 171 createFailure(this, t, this.translations.get("ErrorTryAgain")); 172 } 173 174 const tvm = new TranscriptionViewModel(t, f); 175 176 try { 177 this.$store.commit("transcriptionAdd", tvm); 178 } 179 catch (TranscriptionExistsError) { 180 createFailure(this, t, this.translations.get("AudioUpload_AlreadyTranscribed")); 181 } 182 } 183 } 184 } 185 } 186 catch (e) { 187 console.error("Failed to transcribe files"); 188 console.error(e); 189 190 const failure = new TranscriptionViewFailure(e.fileName, e.message); 191 this.failures.set(failure.id, failure); 192 } 193 194 function createFailure(that, t, reason = null) { 195 const failure = new TranscriptionViewFailure(t.file_name, reason ?? t.log); 196 that.failures.set(failure.id, failure); 197 } 154 198 } 155 199 } 156 200 } 157 158 /**159 * Gets the transcription of each submitted audio file.160 *161 * @param {File[]} files The files to transcribe.162 */163 async function getTranscriptions(files, store, vm) {164 await Util.delay(200); // TODO: Remove - UI testing purposes only165 166 try {167 for await (const batch of transcribeService.batchTranscribeFiles(files)) {168 for (const t of batch) {169 if (!t.success) {170 const failure = new TranscriptionViewFailure(t.file_name, t.log);171 vm.failures.set(failure.id, failure);172 }173 else {174 const f = files.find(f => f.name === t.file_name);175 if (f === undefined) {176 throw new Error("File name mismatch");177 }178 179 // TODO: Hash file name and size instead. Good indicator that the user has uploaded a duplicate.180 const tvm = new TranscriptionViewModel(t, f);181 store.commit("transcriptionAdd", tvm);182 // let model = new TranscriptionViewModel(t, f);183 // model.words = getTranscriptionWords(t);184 185 // TranscriptionsListVM.transcriptions.set(model.id, model);186 }187 }188 }189 }190 catch (e) {191 console.error("Failed to transcribe files");192 console.error(e);193 194 const failure = new TranscriptionViewFailure(e.fileName, e.message);195 vm.failures.set(failure.id, failure);196 }197 }198 201 </script> -
main/trunk/model-interfaces-dev/atea/korero-maori-asr/src/components/ToggleButton.vue
r35431 r35432 10 10 color: var(--primary-bg-color); 11 11 background-color: var(--paper-color); 12 border: 2px solid var(--primary-bg-color);13 12 box-shadow: var(--primary-box-shadow-thin); 14 13 } -
main/trunk/model-interfaces-dev/atea/korero-maori-asr/src/main.js
r35430 r35432 3 3 import App from "./App.vue"; 4 4 import ToggleButton from "./components/ToggleButton.vue" 5 import Util from "./js/Util"6 5 7 6 export class TranscriptionViewModel { … … 14 13 constructor(transcription, file) { 15 14 /** @type {String} The UUID of this transcription. */ 16 this.id = Util.generateUuid();15 this.id = file.name + file.size + file.type; // Should be a fairly reliable indicator of uniqueness. 17 16 18 17 /** @type {String} The transcription. */ … … 53 52 } 54 53 54 export class TranscriptionExistsError extends Error { 55 constructor(message = "", ...args) { 56 super(message, ...args); 57 } 58 } 59 55 60 const store = createStore({ 56 61 state() { … … 70 75 */ 71 76 transcriptionAdd(state, transcription) { 77 if (state.rawTranscriptions.has(transcription.id)) { 78 throw new Error("Transcription already exists"); 79 } 72 80 state.rawTranscriptions.set(transcription.id, transcription); 73 81 }, -
main/trunk/model-interfaces-dev/atea/korero-maori-asr/src/styles/_material.scss
r35431 r35432 21 21 --body-color: rgb(39, 39, 39); 22 22 23 --primary-box-shadow: 0px 2px 4px 0px #505050; 24 --primary-box-shadow-thin: 0px 1px 3px 0px #747474; 23 --primary-box-shadow: 0 2px 4px 0 #505050; 24 --primary-box-shadow-thin: 0 1px 3px 0 #747474; 25 25 26 --hover-brightness: 92%; 26 27 … … 50 51 --primary-bg-color: var(--accent-bg-color); 51 52 --primary-fg-color: var(--accent-fg-color); 52 }53 54 .border-accent {55 border: 2px var(--accent-bg-color) solid;56 53 } 57 54 … … 248 245 width: 100%; // Required for firefox 249 246 250 &:focus {251 outline: none;252 }253 254 247 &::-webkit-slider-thumb { 255 248 -webkit-appearance: none;
Note:
See TracChangeset
for help on using the changeset viewer.