2017-04-03 13 views
0

私はarticulate.js(http://www.jqueryscript.net/demo/Lightweight-jQuery-Based-Text-To-Speech-Engine-Articulate-js/)を使用してページからコンテンツを読んで話します。それはうまく動作しています、それは何かを話している場合、私はそれを停止し、タブを選択したコンテンツを読み取ることはありませんプレスタブがある場合は動作しません。 いくつかの事前定義関数はウェブページ内のコンテンツのナレーション、現在のタスク(何も話していない)が完了していない場合、タブを押しても何も話さない

<script> 
function speak(obj) { 
    $(obj).articulate('speak'); 
}; 

function pause() { 
    $().articulate('pause'); 
}; 

function resume() { 
    $().articulate('resume'); 
}; 

function stop() { 
    $().articulate('stop'); 
}; 
</script> 

私は

<script> 
    $(document).ready(function() { 
    var counter = 0; 
    setTimeout(function(){ 
     counter +=1; 
     if (counter == 1){ 
     explode(); 
     } 
    },1000); 
    function explode(){ 
     //$('body').articulate('speak'); // Default for play whole content 
     $('h1').articulate('speak'); 
    } 

    $('body').keyup(function (e) { 
    $().articulate('stop'); 
     if (e.which == 9) { // on tab press start speaking selected element 
     var i=document.activeElement.id; 
     $('#'+i).articulate('pause').articulate('stop').articulate('speak'); 
     } 
     else{ // trying to speak what key has been pressed except tab, but not working 
      var i=document.activeElement.id; 
      $('#'+i).val().articulate('speak'); 
     } 
    }); 

    }); 
</script> 

を試してみました私はまた私が

答えて

0

が動作していないテキストボックス、上の(キーの押下を話すように)それが聞こえるようにしようとしていますバックスペース、ctrl、スペースなどを読み取っていないが、zを1から0まで非常によく話すような一定の制限があります。改善してください

<script> 
    $(document).ready(function() { 
    var counter = 0; 
    setTimeout(function(){ 
     counter +=1; 
     if (counter == 1){ 
     explode(); 
     } 
    },1000); 
    function explode(){ 
     //$('body').articulate('speak'); // Default for play whole content 
     $('h1').articulate('speak'); 
    } 

    $('body').keyup(function (e) { 
     var speaking = $().articulate('isSpeaking'); 
     var paused = $().articulate('isPaused'); 
// $().articulate('stop'); 
     if (e.which == 9) { 
      if (speaking) { 
       $().articulate('pause'); 
       $().articulate('stop'); 
      } 

      var check =0; 
      setTimeout(function(){ 
       check +=1; 
       if (check == 1){ 
        comeback(); 
       } 
      },1000); 
      function comeback() { 
       var i=document.activeElement.id; 
       $('#'+i).articulate('speak'); 

      } 
     } 
     else{ 
      var i=document.activeElement.id; 
      var m=0; 
      setTimeout(function() { 
       m+=1; 
       if(m==1){ 
        magic(); 
       } 
      },500); 
      function magic() { 
       var tempval=$('#'+i).val(); 
       var lastChar = tempval.substr(tempval.length - 1); 
       var ht ='<div>'+lastChar+'</div>'; 
       $(ht).articulate('speak'); 
      } 
     } 
    }); 

    }); 
</script> 
関連する問題