<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>普通话学习助手</title>
    <style>
        body {
            font-family: 'Noto Sans', Arial, sans-serif;
            background-color: #f0f4f8;
            color: #333;
            margin: 0;
            padding: 0;
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
        }

        .container {
            background-color: #fff;
            box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
            padding: 30px;
            border-radius: 8px;
            text-align: center;
            max-width: 600px;
            width: 100%;
        }

        h1 {
            color: #4CAF50;
            font-size: 2.2em;
            margin-bottom: 20px;
        }

        button {
            background-color: #4CAF50;
            color: white;
            border: none;
            padding: 12px 24px;
            font-size: 16px;
            border-radius: 25px;
            cursor: pointer;
            transition: background-color 0.3s ease;
        }

        button:hover {
            background-color: #45a049;
        }

        #result {
            margin-top: 20px;
            padding: 20px;
            border-radius: 8px;
            background-color: #f9f9f9;
            box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.05);
        }

        p {
            margin: 10px 0;
            font-size: 1.1em;
            color: #333;
        }

        audio {
            margin-top: 20px;
            width: 100%;
        }
    </style>
</head>
<body>
    <div class="container">
        <h1>普通话学习助手</h1>
        <button id="recordButton">开始录音</button>
        <div id="result"></div>
    </div>

    <script>
        const recordButton = document.getElementById('recordButton');
        const resultDiv = document.getElementById('result');
        let mediaRecorder;
        let audioChunks = [];

        recordButton.addEventListener('click', async () => {
            if (recordButton.textContent === '开始录音') {
                await startRecording();
                recordButton.textContent = '停止录音';
            } else {
                stopRecording();
                recordButton.textContent = '开始录音';
            }
        });

        async function startRecording() {
            const stream = await navigator.mediaDevices.getUserMedia({ audio: true });
            mediaRecorder = new MediaRecorder(stream, {
                mimeType: 'audio/webm;codecs=opus',
                audioBitsPerSecond: 16000
            });
            mediaRecorder.ondataavailable = event => {
                audioChunks.push(event.data);
            };
            mediaRecorder.onstop = async () => {
                const audioBlob = new Blob(audioChunks, { type: 'audio/wav' });
                audioChunks = [];
                const formData = new FormData();
                formData.append('audio', audioBlob, 'recording.wav');

                try {
                    const response = await fetch('http://127.0.0.1:5000/getJson', {
                        method: 'POST',
                        body: formData
                    });
                    const result = await response.json();
                    displayResult(result);
                } catch (error) {
                    console.error('Error:', error);
                }
            };
            mediaRecorder.start();
        }

        function stopRecording() {
            mediaRecorder.stop();
        }

        function displayResult(result) {
            resultDiv.innerHTML = `
                <p><strong>识别文本:</strong> ${result.text}</p>
                <p><strong>拼音:</strong> ${result.pinyin}</p>
                <p><strong>修正建议:</strong> ${result.suggestions}</p>
                <audio controls src="${result.speech_url}"></audio>
            `;
        }
    </script>
</body>
</html>
---------
美化这个界面