Ignore:
Timestamp:
2021-09-14T11:13:37+12:00 (3 years ago)
Author:
davidb
Message:

Implement transcription text download

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/model-interfaces-dev/atea/korero-maori-asr/src/components/TranscriptionItem.vue

    r35355 r35384  
    88
    99            <span>{{ translations.get("TranscriptionItem_FileName") }}: {{ transcription.fileName }}</span>
     10
     11            <button @click="downloadAsText" type="button">
     12                <span class="material-icons">download</span>
     13                <span>{{ translations.get("TranscriptionItem_DownloadAsText") }}</span>
     14            </button>
    1015
    1116            <button class="theme-error" @click="remove" type="button">
     
    3641    display: grid;
    3742    gap: 0.5em 0.5em;
    38     grid-template-columns: auto 1fr auto;
     43    grid-template-columns: auto 1fr auto auto;
    3944    align-items: center;
    4045
     
    5257<script>
    5358import { mapState } from "vuex";
     59import { saveAs } from "file-saver"
    5460import TranscriptionItemEditor from "./TranscriptionItemEditor.vue"
    5561import { TranscriptionViewModel } from "../main";
     
    8591            // Start our removal animation and give it some time to complete
    8692            Util.delay(550).then(() => this.$store.commit("transcriptionRemove", this.transcription.id));
     93        },
     94        downloadAsText() {
     95            const extensionIndex = this.transcription.fileName.lastIndexOf(".");
     96            let fileName = this.transcription.fileName.slice(0, extensionIndex);
     97            fileName += "_transcription.txt";
     98
     99            const blob = new Blob([ this.transcription.transcription ], { type: "text/plain;charset=utf-8" });
     100            saveAs(blob, fileName);
    87101        }
    88102    }
Note: See TracChangeset for help on using the changeset viewer.