みかづきブログ その3

本ブログは更新を終了しました。通算140万ユーザーの方に観覧頂くことができました。長い間、ありがとうございました。

👆

引越し先はこちらです!

iOS 8.1.2 で SpeechSynthesisUtterance を試す

iOS 8.1.2 で SpeechSynthesisUtterance の rate とか pitch が効くようになった気がします。

JavaScript

(function(win, doc) {
    
    "use strict";
    
    var msg = new SpeechSynthesisUtterance("生麦生米生卵"),
        isPlay = false;
    
    msg.lang = "ja-JP";

    msg.onend = function() {
        isPlay = false;
    };
    
    doc.getElementById("btn").addEventListener("click", function() {
        if (isPlay) {
            return;
        }
        
        isPlay = true;
        msg.rate = Math.random() * 2 || 1; // ランダムにスピードを決定
        win.speechSynthesis.speak(msg);
    }, false);

})(this, document);

DEMO

f:id:kimizuka:20141210181255g:plain
http://jsrun.it/kimmy/eq9M



Chromeではまだ効かない気がします。