<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>普通话学习助手</title>
    <!-- 引入字体 -->
    <link rel="icon" href="/other/av.png" type="image/x-icon">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Sans+SC:wght@400;700&display=swap" rel="stylesheet">
    <style>
        /* 重置样式 */
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: 'Noto Sans SC', Arial, sans-serif;
            background: linear-gradient(135deg, #f0f4f8 0%, #d9e8ff 100%);
            color: #333;
            display: flex;
            flex-direction: column;
            min-height: 100vh;
        }

        .container {
            flex: 1;
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
            padding: 40px 20px;
        }

        .content {
            background-color: rgba(255, 255, 255, 0.9);
            backdrop-filter: blur(5px);
            box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
            padding: 40px;
            border-radius: 16px;
            text-align: center;
            max-width: 600px;
            width: 100%;
            animation: fadeIn 1s ease;
        }

        @keyframes fadeIn {
            from {
                opacity: 0;
                transform: translateY(30px);
            }
            to {
                opacity: 1;
                transform: translateY(0);
            }
        }

        h1 {
            color: #1e88e5;
            font-size: 2.5em;
            margin-bottom: 30px;
        }

        button {
            background-color: #1e88e5;
            color: white;
            border: none;
            padding: 15px 30px;
            font-size: 1.1em;
            border-radius: 50px;
            cursor: pointer;
            transition: all 0.3s ease;
            position: relative;
            overflow: hidden;
            margin-bottom: 20px;
        }

        button:disabled {
            background-color: #9bbfe0;
            cursor: not-allowed;
        }

        button::after {
            content: '';
            position: absolute;
            left: -10%;
            top: -50%;
            width: 120%;
            height: 200%;
            background: rgba(255, 255, 255, 0.3);
            transform: rotate(45deg);
            opacity: 0;
            transition: all 0.5s ease;
        }

        button:hover {
            background-color: #1565c0;
        }

        button:hover::after {
            top: -20%;
            opacity: 1;
        }

        #result {
            margin-top: 20px;
        }

        .result-block {
            padding: 20px;
            border-radius: 16px;
            background-color: rgba(250, 250, 250, 0.9);
            box-shadow: inset 0 0 15px rgba(0, 0, 0, 0.05);
            text-align: left;
            margin-bottom: 20px;
        }

        .result-block h2 {
            font-size: 1.5em;
            color: #1e88e5;
            margin-bottom: 15px;
        }

        .result-block p {
            font-size: 1.2em;
            color: #333;
            line-height: 1.6;
            margin-bottom: 10px;
        }

        .prompt {
            margin-top: 20px;
            text-align: left;
            background-color: rgba(250, 250, 250, 0.9);
            padding: 20px;
            border-radius: 16px;
            box-shadow: inset 0 0 15px rgba(0, 0, 0, 0.05);
        }

        .prompt p {
            font-size: 1.2em;
            color: #333;
            line-height: 1.8;
            margin-bottom: 10px;
        }

        audio {
            margin-top: 10px;
            width: 100%;
            outline: none;
        }

        /* 作者信息 */
        .footer {
            text-align: center;
            padding: 20px;
            font-size: 1em;
            color: #888;
        }

        .footer a {
            color: #1e88e5;
            text-decoration: none;
        }

        /* 响应式设计 */
        @media (max-width: 480px) {
            h1 {
                font-size: 2em;
            }

            button {
                padding: 12px 24px;
                font-size: 1em;
            }

            .result-block h2 {
                font-size: 1.3em;
            }

            .result-block p {
                font-size: 1em;
            }

            .prompt p {
                font-size: 1em;
            }
        }
    </style>
</head>
<body>
    <div class="container">
        <div class="content">
            <h1>普通话学习助手</h1>
            <p>此工具通过一段录音来分析您在普通话发音中的错误，结果仅供参考。</p>
            <button id="recordButton">开始录音</button>
            <p>请按下“开始录音”按钮，然后说出您想说的话。 </p>
            <p>不知道说什么？请参考以下内容：</p>
            <div class="prompt">
                <p>人之初，性本善。性相近，习相远。</p>
                <p>天行健，君子以自强不息。</p>
                <p>海内存知己，天涯若比邻。</p>
            </div>
            <div id="result"></div>
        </div>
    </div>

    <!-- 作者信息 -->
    <div class="footer">
        © 2024 <a href="#">hooxing</a>
    </div>

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

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

        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 () => {
                audioBlob = new Blob(audioChunks, { type: 'audio/webm' });
                audioChunks = [];
                const formData = new FormData();
                formData.append('audio', audioBlob, 'recording.webm');

                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);
                    alert('处理录音时出错，请重试。');
                } finally {
                    recordButton.textContent = '开始录音';
                    recordButton.disabled = false;
                }
            };
            mediaRecorder.start();
        }

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

        function displayResult(result) {
            const audioUrl = URL.createObjectURL(audioBlob);
            resultDiv.innerHTML = `
                <div class="result-block">
                    <h2>识别结果</h2>
                    <p><strong>文本：</strong>${result.text}</p>
                    <p><strong>拼音：</strong>${result.pinyin.join(', ')}</p>
                    <audio controls src="${audioUrl}"></audio>
                </div>
                <div class="result-block">
                    <h2>修正建议</h2>
                    <p>${result.suggestions}</p>
                </div>
            `;
        }
    </script>
</body>
</html>
-----
修改这个页面，当页面展示空间较大时将说什么话这个框放置于侧边，并且点击会出现不同的话语，当页面展示空间小时则和现在的效果一样