This commit is contained in:
2025-09-06 09:07:35 +08:00
parent 93ccd0e7f5
commit 0b67beb83f

View File

@@ -433,23 +433,7 @@
<div class="container"> <div class="container">
<h1>🎙️ 英语朗读评测</h1> <h1>🎙️ 英语朗读评测</h1>
<div class="format-selector">
<label for="audioFormat">选择音频格式:</label>
<select id="audioFormat">
<option value="wav">WAV</option>
</select>
</div>
<div class="settings">
<h3>录音设置</h3>
<div class="setting-item">
<label>麦克风音量:</label>
<div style="display: flex; align-items: center; gap: 10px;">
<input type="range" id="volumeSlider" min="0" max="100" value="50">
<span id="volumeValue">50%</span>
</div>
</div>
</div>
<!-- 添加英文朗读文本输入区域 --> <!-- 添加英文朗读文本输入区域 -->
<div class="text-container"> <div class="text-container">
<h3 style="color: #5eead4; margin-bottom: 10px;">📝 请朗读以下文本</h3> <h3 style="color: #5eead4; margin-bottom: 10px;">📝 请朗读以下文本</h3>
@@ -553,7 +537,7 @@
this.timer = document.getElementById('timer'); this.timer = document.getElementById('timer');
this.duration = document.getElementById('duration'); this.duration = document.getElementById('duration');
this.fileSize = document.getElementById('fileSize'); this.fileSize = document.getElementById('fileSize');
this.audioFormat = document.getElementById('audioFormat'); this.audioFormat = "WebM";
this.volumeSlider = document.getElementById('volumeSlider'); this.volumeSlider = document.getElementById('volumeSlider');
this.volumeValue = document.getElementById('volumeValue'); this.volumeValue = document.getElementById('volumeValue');
this.uploadProgress = document.getElementById('uploadProgress'); this.uploadProgress = document.getElementById('uploadProgress');
@@ -582,13 +566,6 @@
this.stopBtn.addEventListener('click', () => this.stopRecording()); this.stopBtn.addEventListener('click', () => this.stopRecording());
this.playBtn.addEventListener('click', () => this.playRecording()); this.playBtn.addEventListener('click', () => this.playRecording());
this.uploadBtn.addEventListener('click', () => this.uploadRecording()); this.uploadBtn.addEventListener('click', () => this.uploadRecording());
this.volumeSlider.addEventListener('input', (e) => {
this.volumeValue.textContent = e.target.value + '%';
if (this.audioContext && this.audioContext.destination) {
this.audioContext.destination.volume.value = e.target.value / 100;
}
});
} }
async startRecording() { async startRecording() {
@@ -699,7 +676,7 @@
} }
getMimeType() { getMimeType() {
const format = this.audioFormat.value; const format = "webm";
const supportedTypes = { const supportedTypes = {
'webm': 'audio/webm;codecs=opus', 'webm': 'audio/webm;codecs=opus',
'mp4': 'audio/mp4', 'mp4': 'audio/mp4',
@@ -759,7 +736,7 @@
this.uploadProgress.classList.add('show'); this.uploadProgress.classList.add('show');
const formData = new FormData(); const formData = new FormData();
const format = this.audioFormat.value; const format = "webm";
const extensions = {'webm': 'webm', 'mp4': 'mp4', 'wav': 'wav'}; const extensions = {'webm': 'webm', 'mp4': 'mp4', 'wav': 'wav'};
const fileName = `recording_${Date.now()}.${extensions[format]}`; const fileName = `recording_${Date.now()}.${extensions[format]}`;