Skip to content
TheChatArchiveThe Chat Archive
o1-preview-2024-09-12· OpenAIAi2 WildChat-4.8M (AI2)

<!DOCTYPE html> <html lang="zh-CN"> <head> <meta charset="UTF-8"> <meta name="viewport"…

  1. User
        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>
    
    <!-- 作者信息 -->
    <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>
    
  2. Assistant

    好的,根据你的要求,我已经修改了页面,使其在展示空间较大时,将“提示内容”框放置于侧边,并且点击会出现不同的话语;在展示空间较小时,保持原有的效果。以下是修改后的代码:

    <!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;
            }
    
            /* 大屏幕时,横向布局 */
            @media (min-width: 768px) {
                .container {
                    flex-direction: row; /* 水平布局 */
                    align-items: flex-start;
                }
                .content, .prompt {
                    max-width: 50%;
                    width: 50%;
                }
                .content {
                    margin-right: 20px;
                }
                .prompt {
                    margin-left: 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;
                width: 100%;
                animation: fadeIn 1s ease;
                margin-bottom: 20px; /* 小屏幕时的间距 */
            }
    
            @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);
                cursor: pointer; /* 鼠标变为指针,表示可点击 */
            }
    
            .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 id="result"></div>
            </div>
            <div class="prompt">
                <p>人之初,性本善。性相近,习相远。</p>
                <p>天行健,君子以自强不息。</p>
                <p>海内存知己,天涯若比邻。</p>
            </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;
    
            const phrases = [
                [
                    "人之初,性本善。性相近,习相远。",
                    "天行健,君子以自强不息。",
                    "海内存知己,天涯若比邻。"
                ],
                [
                    "老骥伏枥,志在千里。烈士暮年,壮心不已。",
                    "不积跬步,无以至千里;不积小流,无以成江海。",
                    "会当凌绝顶,一览众山小。"
                ],
                [
                    "沧海月明珠有泪,蓝田日暖玉生烟。",
                    "人生若只如初见,何事秋风悲画扇。",
                    "此情可待成追忆,只是当时已惘然。"
                ]
                // 可以根据需要添加更多的短语组
            ];
            let currentPhraseIndex = 0;
    
            const promptDiv = document.querySelector('.prompt');
    
            promptDiv.addEventListener('click', () => {
                // 切换到下一个短语组
                currentPhraseIndex = (currentPhraseIndex + 1) % phrases.length;
                const newPhrases = phrases[currentPhraseIndex];
                promptDiv.innerHTML = newPhrases.map(line => `<p>${line}</p>`).join('');
            });
    
            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>
    

    修改要点:

    1. 布局调整: 将原先的<div class="prompt">移动到.container内,与.content并列,这样可以在大屏幕时实现左右布局。

    2. 响应式设计: 使用媒体查询@media (min-width: 768px),在屏幕宽度大于768px时,设置.container的flex-direction为row,使内容水平排列。并设置.content和.prompt的宽度为50%,以实现左右各占一半的效果。

    3. 点击切换短语: 在JavaScript中,定义了一个二维数组phrases,每个子数组包含一组短语。通过监听promptDiv的点击事件,切换显示不同的短语组。

    4. 样式调整: 为了使<div class="prompt">在可点击时有交互感,增加了cursor: pointer;,让鼠标悬停时显示为手型指针。

    5. 文本内容调整: 将提示文字从“请参考以下内容”改为“请参考提示内容”,以适应在大屏幕时提示内容可能在侧边的情况。

    6. 保持小屏幕效果: 在小屏幕(如移动设备)上,布局保持为原先的纵向排列,不影响用户体验。

    通过以上修改,当用户在较大的屏幕设备上访问页面时,提示内容将显示在主内容的侧边,并且用户可以通过点击提示内容切换不同的短语。当用户在小屏幕设备上访问时,页面布局仍然是纵向排列,保持了原有的效果。

    希望这些修改符合您的需求!