Changeset 35252 for main/trunk/model-interfaces-dev/atea
- Timestamp:
- 2021-08-05T09:57:47+12:00 (3 years ago)
- Location:
- main/trunk/model-interfaces-dev/atea
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/model-interfaces-dev/atea/js/asr/TranscribeService.js
r35250 r35252 5 5 * @property {String} file_name The name of the file that was transcribed. 6 6 * @property {String} log A note of how the transcription was processed. 7 * @property {{char: String, start_time: Number}[]} metadata The character metadata.7 * @property {{char: String, confidence: Number, start_time: Number}[]} metadata The character metadata. 8 8 * @property {boolean} success A value indicating if the transcription was successful or not. 9 9 * @property {String} transcription The transcription. … … 37 37 38 38 /** 39 * Performs chunked queries to transcribe the given audio files, returning the data in iterations. 40 * Data is chunked according to which ever occurs first: 41 * A maximum of three files per request, or; 42 * A maximum of 5 MiB per request. 43 * 44 * @param {FileList} files The files to upload 45 * @returns {AsyncGenerator<TranscriptionModel[]>} The transcribed audio files. 46 */ 47 async* chunkTranscribeFiles(files) 48 { 49 let filesToSubmit = []; 50 let fileCounter = 0; 51 let byteCounter = 0; 52 53 for (let file of files) { 54 if (fileCounter == 3 || byteCounter > 5242880) // 5 MiB 55 { 56 yield await this.transcribeFiles(filesToSubmit); 57 filesToSubmit = []; 58 byteCounter = 0; 59 fileCounter = 0; 60 } 61 62 filesToSubmit[fileCounter++] = file; 63 byteCounter += file.size; 64 } 65 66 if (filesToSubmit.length > 0) { 67 yield await this.transcribeFiles(filesToSubmit); 68 } 69 } 70 71 /** 39 72 * Performs a query to transcribe the given audio files. 40 73 * 41 * @param {FileList } files The files to upload.42 * @returns {Promise<TranscriptionModel[]>} The transcribed au fio file.74 * @param {FileList | File[]} files The files to upload. 75 * @returns {Promise<TranscriptionModel[]>} The transcribed audio file. 43 76 */ 44 77 async transcribeFiles(files) -
main/trunk/model-interfaces-dev/atea/js/asr/asr-controller.js
r35250 r35252 49 49 const files = $(FILE_UPLOAD_INPUT_NAME)[0].files; 50 50 const transcribeService = new TranscribeService(); 51 51 52 52 $(FILE_UPLOAD_PROGRESS_CONTAINER_NAME).removeClass("asr-hidden"); 53 53 … … 66 66 try 67 67 { 68 const transcriptions = await transcribeService.transcribeFiles(files); 69 for (const t of transcriptions) 68 for await (const transcriptionBundle of transcribeService.chunkTranscribeFiles(files)) 70 69 { 71 if (!t.success) { 72 insertError(t.file_name, t.log); 73 } 74 else { 75 insertTranscription(t); 70 for (const t of transcriptionBundle) 71 { 72 if (!t.success) { 73 insertError(t.file_name, t.log); 74 } 75 else { 76 insertTranscription(t); 77 } 76 78 } 77 79 } … … 79 81 catch (e) 80 82 { 83 console.error("Failed to transcribe files: " + e); 81 84 insertError("all", e.statusMessage); 82 85 } -
main/trunk/model-interfaces-dev/atea/style/asr.css
r35250 r35252 19 19 } 20 20 21 .transcription-list-item .spaced-block {21 .transcription-list-item .spaced-block, .error-list-item .spaced-block { 22 22 margin-bottom: 8px; 23 23 } 24 24 25 .transcription-list-item .spaced-block:last-child {25 .transcription-list-item .spaced-block:last-child, .error-list-item .spaced-block:last-child { 26 26 margin-bottom: 0; 27 27 } -
main/trunk/model-interfaces-dev/atea/transform/pages/asr.xsl
r35250 r35252 84 84 <li class="error-list-item"> 85 85 <div> 86 Transcription failed: <span></span><br /> 87 <b>File: </b><span></span> 86 <div class="spaced-block"> 87 <b>Transcription Failed: </b><span></span> 88 </div> 89 <div class="spaced-block"> 90 <b>File: </b><span></span> 91 </div> 88 92 </div> 89 93 </li>
Note:
See TracChangeset
for help on using the changeset viewer.