|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="ja" xml:lang="ja">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=EUC-JP" />
<title>VDS APIを使ってWebページを音声で読み上げてみよう!</title>
<script type="text/javascript" src="http://api.vdsapi.ne.jp/cgi-bin/vds.cgi?key=[key]">
</script>
<script type="text/javascript">
<!--
var vdsp;
var vds;
window.onload=function() {
try {
vdsp = new VoiceDeliveryPlayer("vdsp");
vds = new VoiceDelivery(vdsp, "vds");
} catch(e) {
alert("音声合成を行うためのオブジェクトを生成できませんでした!");
}
}
function readOut(index) {
buf = document.getElementById("readOutHere" + index).innerHTML;
result = vds.speak(buf);
switch (result) {
case -103:
alert("読み上げ文字列が許可されている長さを超えました。");
break;
case -105:
alert("読み上げ文字列が指定されていません。");
break;
case -301:
alert("残念ながら、1日あたりの再生回数が規定数を超えました。たくさん再生してくれて、ありがとう。");
break;
case -501:
alert("ページをリロードして、もう一度再生ボタンを押してみてください。");
break;
}
}
function serverProcessFinished() {
alert("サーバ側の音声合成が終了しました。");
}
-->
</script>
<style text="text/css">
.item { width: 300px; float: left; }
</style>
</head>
<body style="text-align: center;">
<div id="vdsp"></div>
<div style="width: 900px; margin: 0 auto;">
<h2>VDS APIを使ってウェブページを音声で読み上げてみよう!</h2>
<div class="item">
<h3>読み上げる</h3>
<div id="readOutHere1">
こんにちは、世界
</div>
<input type="button" value="読み上げる" onclick="readOut(1)" />
</div>
<div class="item">
<h3>再生と停止</h3>
<div id="readOutHere2">
吾輩は猫である。名前はまだ無い。
</div>
<input type="button" value="読み上げる" onclick="readOut(2)" />
<input type="button" value="停止" onclick="vdsp.speakStop()" />
</div>
<div class="item">
<h3>TakashiJPmの声で読み上げる</h3>
<div id="readOutHere3">
どこで生れたかとんと見当がつかぬ。
</div>
<input type="button" value="読み上げる" onclick="vds.setCast('TakashiJPm'); readOut(3);" />
</div>
<div class="item">
<h3>KeikoJPfの声で読み上げる</h3>
<div id="readOutHere4">
何でも薄暗いじめじめした所でニャーニャー泣いていた事だけは記憶している。
</div>
<input type="button" value="読み上げる" onclick="vds.setCast('KeikoJPf'); readOut(4);" />
</div>
<div class="item">
<h3>読み上げる速度を変える</h3>
<div id="readOutHere5">
吾輩はここで始めて人間というものを見た。
</div>
<input type="button" value="遅く読み上げる" onclick="vds.setRate(-10); readOut(5);" />
<input type="button" value="早く読み上げる" onclick="vds.setRate(10); readOut(5);" />
</div>
<div class="item">
<h3>左右のスピーカーから読み上げる</h3>
<div id="readOutHere6">
しかもあとで聞くとそれは書生という人間中で一番獰悪な種族であったそうだ。
</div>
<input type="button" value="右側のスピーカー" onclick="vdsp.setPan(10); readOut(6);" />
<input type="button" value="左側のスピーカー" onclick="vdsp.setPan(-10); readOut(6);" />
</div>
<div class="item">
<h3>大きな声で読み上げる</h3>
<div id="readOutHere7">
この書生というのは時々我々を捕えて煮て食うという話である。
</div>
<input type="button" value="読み上げる" onclick="vdsp.setVolume(5); readOut(7);" />
</div>
<div class="item">
<h3>一時停止</h3>
<div id="readOutHere8">
しかしその当時は何という考もなかったから別段恐しいとも思わなかった。
</div>
<input type="button" value="読み上げる" onclick="readOut(8);" />
<input type="button" value="一時停止" onclick="vdsp.speakPause();" />
</div>
<div class="item">
<h3>イベント通知</h3>
<div id="readOutHere9">
ただ彼の掌に載せられてスーと持ち上げられた時何だかフワフワした感じがあったばかりである。
</div>
<input type="button" value="読み上げる" onclick="vds.setFinishCallback('serverProcessFinished()'); readOut(9);" />
</div>
<br clear="both">
<div>
<br><br>
Powered by <a href="http://www.vdsapi.ne.jp/">VDS(Voice Delivery System) API</a>
</div>
</div>
</body>
</html>
|