英语发音练习器

英语发音练习器

不知道怎么读就放慢来,纯html

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
  <title>English Reader</title>
  <style>
    * {
      margin: 0;
      padding: 0;
      box-sizing: border-box;
    }

    body {
      font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
      background-color: #f5f7fa;
      color: #333;
      min-height: 100vh;
      display: flex;
      flex-direction: column;
      align-items: center;
      padding: 24px 16px;
    }

    /* 上:标题 */
    .header {
      text-align: center;
      margin-bottom: 24px;
      max-width: 600px;
      width: 100%;
    }

    .header h1 {
      font-size: 26px;
      font-weight: 600;
      color: #2c3e50;
    }

    /* 中:输入与控制 */
    .content {
      width: 100%;
      max-width: 600px;
      background: white;
      padding: 24px;
      border-radius: 12px;
      box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
      margin-bottom: 24px;
    }

    textarea {
      width: 100%;
      height: 160px;
      padding: 14px;
      font-size: 16px;
      border: 1px solid #ddd;
      border-radius: 8px;
      resize: vertical;
      margin-bottom: 20px;
      font-family: inherit;
    }

    .speed-control {
      display: flex;
      flex-wrap: wrap;
      gap: 12px;
      align-items: center;
    }

    .speed-control label {
      font-weight: 600;
      color: #555;
      min-width: 100px;
    }

    .speed-control select {
      flex: 1;
      min-width: 150px;
      padding: 10px;
      border: 1px solid #ddd;
      border-radius: 6px;
      font-size: 15px;
    }

    /* 下:按钮 */
    .footer {
      width: 100%;
      max-width: 600px;
    }

    .footer button {
      width: 100%;
      padding: 14px;
      font-size: 18px;
      font-weight: 600;
      background-color: #3498db;
      color: white;
      border: none;
      border-radius: 10px;
      cursor: pointer;
      transition: background 0.2s;
    }

    .footer button:hover {
      background-color: #2980b9;
    }
  </style>
</head>
<body>
  <!-- 上 -->
  <div class="header">
    <h1>英语发音练习器-JDIT</h1>
  </div>

  <!-- 中 -->
  <div class="content">
    <textarea id="textInput" placeholder="Paste or type your English text here...">Welcome! This tool reads English text aloud at your chosen speed.</textarea>
    
    <div class="speed-control">
      <label for="rate">Speech Speed:</label>
      <select id="rate">
        <option value="0.1">Very Slow (0.1)</option>
        <option value="0.2">Slow (0.2)</option>
        <option value="0.5">Medium (0.5)</option>
        <option value="0.8">Fast (0.8)</option>
        <option value="1.0" selected>Normal (1.0)</option>
      </select>
    </div>
  </div>

  <!-- 下 -->
  <div class="footer">
    <button id="speakBtn">🔊 Read Aloud</button>
  </div>

  <script>
    const textInput = document.getElementById('textInput');
    const rateSelect = document.getElementById('rate');
    const speakBtn = document.getElementById('speakBtn');

    // Auto-focus on load
    window.addEventListener('load', () => {
      textInput.focus();
    });

    speakBtn.addEventListener('click', () => {
      const text = textInput.value.trim();
      if (!text) return;

      // Cancel any ongoing speech
      speechSynthesis.cancel();

      const utterance = new SpeechSynthesisUtterance(text);
      utterance.lang = 'en-US';
      utterance.rate = parseFloat(rateSelect.value);

      speechSynthesis.speak(utterance);
    });
  </script>
</body>
</html>
posted @ 2026-01-13 06:46  红尘过客2022  阅读(35)  评论(0)    收藏  举报