diff --git a/public/index.html b/public/index.html index ee1eaf7..576df80 100644 --- a/public/index.html +++ b/public/index.html @@ -667,15 +667,30 @@
-
- Audio Recording - {{ formatBytes(newMessageAudio.audio_blob.size) }} + +
+ + +
+ +
+ + +
+ {{ formatBytes(newMessageAudio.audio_blob.size) }} +
+
+ +
+
@@ -2418,7 +2433,7 @@ } }, - stopRecordingAudioAttachment: function() { + async stopRecordingAudioAttachment() { // clear audio recording timer clearInterval(this.audioAttachmentRecordingTimer); @@ -2437,10 +2452,20 @@ return; } + // decode codec2 audio back to wav so we can show a preview audio player before user sends it + const decoded = await Codec2Lib.runDecode("1200", new Uint8Array(audio)); + + // convert decoded codec2 to wav audio and create a blob + const wavAudio = await Codec2Lib.rawToWav(decoded); + const wavBlob = new Blob([wavAudio], { + type: "audio/wav", + }); + // update message audio attachment this.newMessageAudio = { audio_mode: 0x04, // hardcoded to LXMF.AM_CODEC2_1200 for now audio_blob: new Blob([audio]), + audio_wav_url: URL.createObjectURL(wavBlob), }; },