Skip to content

Commit 313cc06

Browse files
committed
Refactor MP3 encoder initialization to use audio context sample rate and reduce bitrate
1 parent 0c3c393 commit 313cc06

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

index.html

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,6 @@ <h3>Transcription:</h3>
147147
let isRecording = false;
148148
let exitWarningEnabled = false;
149149
let mp3Encoder = null;
150-
let mp3EncoderSampleRate = 44100; // Default sample rate for MP3 encoder
151150

152151
// Check if the browser supports the required APIs
153152
if (!window.MediaRecorder || !(window.webkitSpeechRecognition || window.SpeechRecognition)) {
@@ -214,8 +213,7 @@ <h3>Transcription:</h3>
214213
let mp3Data = [];
215214

216215
// Initialize MP3 encoder with proper sample rate
217-
mp3EncoderSampleRate = audioContext.sampleRate;
218-
mp3Encoder = new lamejs.Mp3Encoder(1, mp3EncoderSampleRate, 128);
216+
mp3Encoder = new lamejs.Mp3Encoder(1, audioContext.sampleRate, 64);
219217

220218
audioProcessor.onaudioprocess = (e) => {
221219
if (!isRecording) return;

0 commit comments

Comments
 (0)