Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource


Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource


Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.


Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.


                <h1>HTML5 -音声関係のAPIの実験-</h1>
<p>音声認識は Google Chrome のみ。合成音声は Google Chrome または Microsoft Edge で利用できる。</p>
<div id="container">
  <input type="button" id="recognitionStart" value="音声認識を開始" onclick="recognition_start();" />
  <input type="button" id="recognitionEnd" value="音声認識を終了" onclick="recognition_stop();" />
  <textarea id="results"> </textarea>
  <input type="button" value="合成音声で結果を話す" onclick="say()" />
  <input type="button" value="話を中断する" onclick="speech_pause()" /> <input type="button" value="話を再開する" onclick="speech_resume()" />
  <div id="voice_settings">
    <div><label for="volume">Volume</label>
      <input type="range" min="0" max="1" value="0.5" step="0.1" id="volume" /><span class="volume-value">1</span>
      <p>volume 属性は 0 から 1 までで指定できる 1 が最大。0が最小</p>
    <div><label for="rate">Rate</label>
      <input type="range" min="0.5" max="10" value="1" step="0.1" id="rate" /><span class="rate-value">1</span>
    <p>rate 属性は話す速度を調整し、 1 が既定であり、一般的な話す速度。2は2倍の速度。0.5 は半分の速度となる。0.1 以下または10以上はサポートされない</p>
      <label for="pitch">Pitch</label>
      <input type="range" min="0" max="2" value="1" step="0.1" id="pitch" /><span class="pitch-value">1</span>
    <p>pitch 属性は声の高さを調整し、0から2までの範囲をとる。0が最低ピッチ。2が最高ピッチ。1が既定。</p>
  <select id="voice_language"></select><select id="language"><option value="ja-jp">ja-jp(日本)</option><option value="en-us">en-us(米国)</option></select>
  <p>Edge の場合は日本語音声を選ぶ必要がある。Chromeはその言語が対応していれば、


                html{font-family:'YuGothicUI','Meiryo UI',sans-serif;}
#container >input{margin-bottom:4px;margin-top:4px;padding:4px 8px; border:1px solid #eee;display:inline-block;transition:all 200ms ease-out;}
#container >input:hover:enabled,#container >input:hover:active:enabled{
    background-color:hsl(219, 94%, 76%);
    box-shadow:0 0 3px #6d6a93;
#container textarea{width: 500px;height: 30vh; display:block;}
#voice_settings > div> input[type='range']{width: 400px;}
#container > select{height: 2em;margin: 4px;}
#container .rate-value,#container .pitch-value{display: inline-block;padding: 4px 8px;}
#container  p{font-size:0.8em;}
#container p:before{content:"→";padding-right:4px;}


                var recognition, result, synth, voices = [],
  voiceSelect, pitch, rate, utterThis;
$(function() {
  //ブラウザーがwebkitSppechRecognition に対応しているか判定
  if ("webkitSpeechRecognition" in window) {
    recognition = new webkitSpeechRecognition(); //Google Chrome のみ対応
    recognition.lang ="ja-jp"; // 日本語認識
    recognition.continuous = true;
    recognition.addEventListener('result', function(event) {      
      var text = '';
      for (var i = 0; i < event.results.length; i++) {
        text += event.results[i][0].transcript;
      results.val(text); //テキストボックスに書き込む
    }, false);
  } else {
    $("#recognitionStart").attr("disabled", true);
    $("#recognitionEnd").attr("disabled", true);

  results = $('#results');
  voiceSelect = $("select#voice_language");
  $("#volume").change(function() {
  $("#rate").change(function() {
  $("#pitch").change(function() {
  synth = window.speechSynthesis;

  if (speechSynthesis.onvoiceschanged !== undefined || voiceSelect.val() == "") {
    speechSynthesis.onvoiceschanged = populateVoiceList;

function recognition_start() {
  results.val(""); //テキストボックスをクリア

function recognition_stop() {

function say() {
  //Microsoft Edge と Chrome が対応
  utterThis = new SpeechSynthesisUtterance(results.val());
  utterThis.volume = parseFloat($("#volume").val());
  utterThis.pitch = parseFloat($("#pitch").val());
  utterThis.rate = parseFloat($("#rate").val());
  var selectedOption = voiceSelect.find('option:selected').attr('data-name');

  for (i = 0; i < voices.length; i++) {
    if (voices[i].name === selectedOption) {
      utterThis.voice = voices[i];
  synth.speak(utterThis); //話す	

function speech_pause() { 
function speech_resume() { 

function populateVoiceList() {
  if (voices.length > 0) return;
  voices = synth.getVoices();
  for (i = 0; i < voices.length; i++) {
    var option = document.createElement('option');
    option.textContent = voices[i].name + ' (' + voices[i].lang + ')';

    if (voices[i].default) {
      option.textContent += ' -- 既定';
    option.setAttribute('data-lang', voices[i].lang);
    option.setAttribute('data-name', voices[i].name);