diff --git a/qwen3-tts-frontend/src/components/AudioRecorder.tsx b/qwen3-tts-frontend/src/components/AudioRecorder.tsx index ea2aeb6..d1f82de 100644 --- a/qwen3-tts-frontend/src/components/AudioRecorder.tsx +++ b/qwen3-tts-frontend/src/components/AudioRecorder.tsx @@ -42,6 +42,13 @@ export function AudioRecorder({ onChange }: AudioRecorderProps) { const result = await validateAudioFile(file) + console.log('录音验证结果:', { + valid: result.valid, + duration: result.duration, + recordingDuration: recordingDuration, + error: result.error + }) + if (result.valid && result.duration) { onChange(file) setAudioInfo({ duration: result.duration, size: file.size }) @@ -65,7 +72,9 @@ export function AudioRecorder({ onChange }: AudioRecorderProps) { } } - const handleReset = () => { + const handleReset = (e: React.MouseEvent) => { + e.preventDefault() + e.stopPropagation() clearRecording() setAudioInfo(null) setValidationError(null) @@ -105,7 +114,14 @@ export function AudioRecorder({ onChange }: AudioRecorderProps) { {(audioInfo.size / 1024 / 1024).toFixed(2)} MB · {audioInfo.duration.toFixed(1)} 秒

- @@ -118,7 +134,7 @@ export function AudioRecorder({ onChange }: AudioRecorderProps) { diff --git a/qwen3-tts-frontend/src/hooks/useAudioRecorder.ts b/qwen3-tts-frontend/src/hooks/useAudioRecorder.ts index d32b09f..f11f35f 100644 --- a/qwen3-tts-frontend/src/hooks/useAudioRecorder.ts +++ b/qwen3-tts-frontend/src/hooks/useAudioRecorder.ts @@ -23,7 +23,7 @@ interface UseAudioRecorderReturn { async function convertToWav(audioBlob: Blob): Promise { const arrayBuffer = await audioBlob.arrayBuffer() - const audioContext = new AudioContext({ sampleRate: 24000 }) + const audioContext = new AudioContext() const audioBuffer = await audioContext.decodeAudioData(arrayBuffer) const numberOfChannels = audioBuffer.numberOfChannels