Changeset 35433
- Timestamp:
- 2021-09-20T16:50:02+12:00 (3 years ago)
- Location:
- main/trunk/model-interfaces-dev/atea/korero-maori-asr/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/model-interfaces-dev/atea/korero-maori-asr/src/components/AudioUpload.vue
r35432 r35433 158 158 */ 159 159 async getTranscriptions(files) { 160 await Util.delay(1000); // TODO: Remove - UI testing purposes only 160 await Util.delay(200); // TODO: Remove - UI testing purposes only 161 162 const validFiles = []; 163 164 // Skip any files that have already been transcribed 165 for (const file of files) { 166 if (this.$store.getters.hasTranscriptionOfFile(file)) { 167 this.createFailure(file.file_name, this.translations.get("AudioUpload_AlreadyTranscribed")); 168 } 169 else { 170 validFiles.push(file); 171 } 172 } 173 174 if (validFiles.length === 0) { 175 return; 176 } 161 177 162 178 try { 163 for await (const batch of transcribeService.batchTranscribeFiles( files)) {179 for await (const batch of transcribeService.batchTranscribeFiles(validFiles)) { 164 180 for (const t of batch) { 165 181 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 this.createFailure(t.file_name, t.log); 183 continue; 184 } 185 186 const f = files.find(f => f.name === t.file_name); 187 if (f === undefined) { 188 this.createFailure(t.file_name, this.translations.get("ErrorTryAgain")); 189 continue; 190 } 191 192 const tvm = new TranscriptionViewModel(t, f); 193 194 try { 195 this.$store.commit("transcriptionAdd", tvm); 196 } 197 catch (TranscriptionExistsError) { 198 this.createFailure(t.file_name, this.translations.get("AudioUpload_AlreadyTranscribed")); 182 199 } 183 200 } … … 188 205 console.error(e); 189 206 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 } 207 this.createFailure(e.fileName, e.message) 208 } 209 }, 210 createFailure(fileName, reason) { 211 const failure = new TranscriptionViewFailure(fileName, reason); 212 this.failures.set(failure.id, failure); 198 213 } 199 214 } -
main/trunk/model-interfaces-dev/atea/korero-maori-asr/src/main.js
r35432 r35433 13 13 constructor(transcription, file) { 14 14 /** @type {String} The UUID of this transcription. */ 15 this.id = file.name + file.size + file.type; // Should be a fairly reliable indicator of uniqueness.15 this.id = TranscriptionViewModel.getId(file); // Should be a fairly reliable indicator of uniqueness. 16 16 17 17 /** @type {String} The transcription. */ … … 26 26 /** @type {File} The file from which the transcription was generated. */ 27 27 this.file = file; 28 } 29 30 static getId(file) { 31 return file.name + file.size + file.type; 28 32 } 29 33 } … … 110 114 state.translations = translations; 111 115 } 116 }, 117 getters: { 118 hasTranscriptionOfFile: (state) => (file) => { 119 const id = TranscriptionViewModel.getId(file); 120 return state.rawTranscriptions.has(id); 121 } 112 122 } 113 123 });
Note:
See TracChangeset
for help on using the changeset viewer.