Ignore:
Timestamp:
2021-08-05T09:57:47+12:00 (3 years ago)
Author:
davidb
Message:

Implement auto-chunking of transcription requests, and display more error information to the user.

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  
    55 * @property {String} file_name The name of the file that was transcribed.
    66 * @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.
    88 * @property {boolean} success A value indicating if the transcription was successful or not.
    99 * @property {String} transcription The transcription.
     
    3737
    3838    /**
     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    /**
    3972     * Performs a query to transcribe the given audio files.
    4073     *
    41      * @param {FileList} files The files to upload.
    42      * @returns {Promise<TranscriptionModel[]>} The transcribed aufio file.
     74     * @param {FileList | File[]} files The files to upload.
     75     * @returns {Promise<TranscriptionModel[]>} The transcribed audio file.
    4376     */
    4477    async transcribeFiles(files)
  • main/trunk/model-interfaces-dev/atea/js/asr/asr-controller.js

    r35250 r35252  
    4949    const files = $(FILE_UPLOAD_INPUT_NAME)[0].files;
    5050    const transcribeService = new TranscribeService();
    51    
     51
    5252    $(FILE_UPLOAD_PROGRESS_CONTAINER_NAME).removeClass("asr-hidden");
    5353
     
    6666    try
    6767    {
    68         const transcriptions = await transcribeService.transcribeFiles(files);
    69         for (const t of transcriptions)
     68        for await (const transcriptionBundle of transcribeService.chunkTranscribeFiles(files))
    7069        {
    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                }
    7678            }
    7779        }
     
    7981    catch (e)
    8082    {
     83        console.error("Failed to transcribe files: " + e);
    8184        insertError("all", e.statusMessage);
    8285    }
  • main/trunk/model-interfaces-dev/atea/style/asr.css

    r35250 r35252  
    1919}
    2020
    21 .transcription-list-item .spaced-block {
     21.transcription-list-item .spaced-block, .error-list-item .spaced-block {
    2222  margin-bottom: 8px;
    2323}
    2424
    25 .transcription-list-item .spaced-block:last-child {
     25.transcription-list-item .spaced-block:last-child, .error-list-item .spaced-block:last-child {
    2626  margin-bottom: 0;
    2727}
  • main/trunk/model-interfaces-dev/atea/transform/pages/asr.xsl

    r35250 r35252  
    8484                <li class="error-list-item">
    8585                    <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>
    8892                    </div>
    8993                </li>
Note: See TracChangeset for help on using the changeset viewer.