Changes between Initial Version and Version 1 of OxfordDictionary


Ignore:
Timestamp:
2016/04/16 17:34:07 (8 years ago)
Author:
yuna
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • OxfordDictionary

    v1 v1  
     1= オックスフォードの英英辞典から英語の発音を取得 
     2 
     3英語の勉強をしていて、単語の発音をさせれたらなぁということでオックスフォードの英英辞典 
     4の音声を取得してみました。Speach APIなどを利用してもいいのですが、発音がちょっと違うかな、と 
     5思ったので、、、 
     6 
     7 
     8他のサイトのHTMLをjQueryで取得するために、jquery.xdomainajax.jsを読み込ませます。 
     9{{{ 
     10<script src="https://code.jquery.com/jquery-2.2.3.min.js"></script> 
     11<script src="jquery.xdomainajax.js"></script> 
     12}}} 
     13 
     14あとは、下記のような関数を作って、英単語をしゃべらせます。 
     15 
     16{{{ 
     17function speak(word){ 
     18    $.ajax({ 
     19        type: 'GET', 
     20        url: 'http://www.oxfordlearnersdictionaries.com/definition/english/'+word+'?q='+word, 
     21        dataType: 'html', 
     22        crossDomain: true, 
     23        success: function(data) { 
     24              mp3=$(data.responseText).find("[title=' pronunciation American']").attr('data-src-mp3'); 
     25              alert(mp3); 
     26              var audio = new Audio(); 
     27              audio.src = mp3; 
     28              audio.play(); 
     29              alert(mp3); 
     30        } 
     31    }); 
     32} 
     33 
     34speak("hello"); 
     35}}}