Skip to content
This repository was archived by the owner on Jul 18, 2025. It is now read-only.

Commit e15b8c2

Browse files
authored
Merge pull request #81 from JSKitty/master
Stable AudioPlayer + Transcription system
2 parents 0b76611 + 4684dc0 commit e15b8c2

2 files changed

Lines changed: 6 additions & 3 deletions

File tree

src-tauri/tauri.conf.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
}
2020
],
2121
"security": {
22-
"csp": "default-src 'self' ipc: http://ipc.localhost; img-src 'self' https: asset: http://asset.localhost; media-src 'self' https: asset: http://asset.localhost; style-src 'self' 'unsafe-inline'",
22+
"csp": "default-src 'self' ipc: http://ipc.localhost; img-src 'self' https: asset: http://asset.localhost; media-src 'self' https: asset: http://asset.localhost; style-src 'self' 'unsafe-inline'; connect-src 'self' asset: http://asset.localhost",
2323
"assetProtocol": {
2424
"enable": true,
2525
"scope": ["$DOWNLOAD/vector/*", "$DOCUMENT/vector/*"]

src/js/voice.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,7 @@ function handleAudioAttachment(cAttachment, assetUrl, pMessage, msg) {
338338

339339
// Create hidden audio element for playback control
340340
const audPreview = document.createElement('audio');
341+
audPreview.crossOrigin = 'anonymous';
341342
audPreview.preload = 'metadata';
342343
audPreview.src = assetUrl;
343344
audPreview.style.display = 'none';
@@ -390,7 +391,7 @@ function handleAudioAttachment(cAttachment, assetUrl, pMessage, msg) {
390391
function initAudioAnalyser() {
391392
if (audioContext) return;
392393

393-
audioContext = new (window.AudioContext || window.webkitAudioContext)();
394+
audioContext = new AudioContext();
394395
analyser = audioContext.createAnalyser();
395396
analyser.fftSize = 256; // Increased for better frequency resolution
396397
analyser.smoothingTimeConstant = 0.85; // Slightly more smoothing for visual appeal
@@ -495,7 +496,6 @@ function handleAudioAttachment(cAttachment, assetUrl, pMessage, msg) {
495496
customPlayer.appendChild(playBtn);
496497
customPlayer.appendChild(waveform);
497498
customPlayer.appendChild(timeDisplay);
498-
customPlayer.appendChild(transcribeBtn);
499499

500500
audioContainer.appendChild(audPreview);
501501
audioContainer.appendChild(customPlayer);
@@ -664,6 +664,9 @@ function handleAudioAttachment(cAttachment, assetUrl, pMessage, msg) {
664664

665665
// Only add transcription UI for supported formats
666666
if (['wav', 'mp3', 'flac'].includes(cAttachment.extension)) {
667+
// Display the Transcribe button
668+
customPlayer.appendChild(transcribeBtn);
669+
667670
// Add transcribe button container
668671
const transcribeContainer = document.createElement('div');
669672
transcribeContainer.classList.add('transcribe-container');

0 commit comments

Comments
 (0)