トップ 新規 編集 差分 一覧 ソース 検索 ヘルプ PDF RSS ログイン

プログラミングの初歩

プログラミングって何?


 TEDの映像

 Youtubeにアップロードされていたプログラミングに関する映像

プログラミングの初歩

 JScriptで音声合成

一文、音声合成する

1
new ActiveXObject("SAPI.SpVoice").speak("I love information literacy.");

多くの文の音声合成をし、無作為に選択する。

1
2
3
4
5
//http://www.freeprintablebehaviorcharts.com/ways_to_say_good_job.htmより
var GoodJobs = new Array("You've got it made.","You're on the right track now!","You are very good at that.","I'm happy to see you working like that.","You're doing a good job.","That's the best you've ever done.","I knew you could do it.","Now you've figured it out.","Now you have it!","GREAT!","You make it look easy.","That's the right way to do it.","You're getting better every day.","SENSATIONAL!","That's the way to do it.","Best yet.","PERFECT!","TERRIFIC!","Much better!","You've just about mastered that!","OUTSTANDING!","You did that very well.","FANTASTIC!","You're really improving.","SUPERB!","Keep it up!","You've got that down pat!","TREMENDOUS!","Good thinking!","I'm very proud of you.","I think you've got it now.","You figured that out fast.","That's really nice.","CLEVER!","That's great!","Way to go.","Now you have the hang of it!","You've done a great job.","Congratulations, you got it right","That's GOOD!","GOOD WORK!","I'm proud of the way you worked today.","You're really working hard today.","You've just about got it.","THAT'S IT!","Congratulations! .","You are doing that much better today.","You're learning fast.","Good for you!","Couldn't have done it better myself.","You did it that time!","That's the way!","SUPER DUPER!","You haven't missed a thing.","Keep up the good work.","Nothing can stop you now!","EXCELLENT!","FINE!","Wonderful!","That's better than ever.","I appreciate your hard work.","Now that's what I call a fine job!","You must have been practicing!","You're doing beautifully.","Right on! ","You're doing fine.","You are really learning a lot.","You outdid yourself today!","SPLENDID!","Good going!","MARVELOUS!","Good job.","Well, look at you go!","DYNAMITE!","Nice Work");
var VoiceObj = new ActiveXObject("SAPI.SpVoice");
for(var i=0;i<10;i++) {
    VoiceObj.Speak(GoodJobs[Math.floor((Math.random()*GoodJobs.length)+1)]);}

 JScriptで音声認識

単に音声認識する

1
2
3
4
5
6
var RecoContextObj=WScript.CreateObject("SAPI.SpInProcRecoContext","Recog_");
RecoContextObj.Recognizer.AudioInput=RecoContextObj.Recognizer.GetAudioInputs().Item(0);
var RecoGrammarObj=RecoContextObj.CreateGrammar();
RecoGrammarObj.DictationSetState(1);
while(true)WScript.Sleep(1000);
function Recog_Recognition(StreamNumber,StreamPosition,RecognitionType,Result){WScript.Echo(Result.PhraseInfo.GetText());}

音声認識した時に、一部の言葉に関しては英語に変換し音声合成する

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
var VoiceObj = new ActiveXObject("SAPI.SpVoice");
var Voices = VoiceObj.getVoices();
for (var i=0;i<Voices.count;i++){
    WScript.Echo(Voices(i).GetDescription());
}
var RecoContextObj=WScript.CreateObject("SAPI.SpInProcRecoContext","Recog_");
RecoContextObj.Recognizer.AudioInput=RecoContextObj.Recognizer.GetAudioInputs().Item(0);
var RecoGrammarObj=RecoContextObj.CreateGrammar();
RecoGrammarObj.DictationSetState(1);
while(true) {
    WScript.Sleep(1000);
}
function Recog_Recognition(StreamNumber,StreamPosition,RecognitionType,Result){
    var text = Result.PhraseInfo.GetText();
    if(text=="こんにちは") {
        VoiceObj.Speak("Hello");
    } else if(text.indexOf("おはよう")>-1) {
        VoiceObj.Speak("Good Morning!");
    } else if(text.indexOf("今晩は")>-1) {
        VoiceObj.Speak("Good Evening!");
    } else if(text.indexOf("俺")>-1) {
        VoiceObj.Speak("kaba");
    } else if(text.indexOf("生麦生米生卵")>-1) {
        VoiceObj.Speak("The seething sea ceaseth and thus the seething sea sufficeth us.");
    }
    WScript.Echo(text);
}

 参考リンク

JSライブラリ

  1. enchant.js
  2. tmlib.js
  3. PlayCanvas
goodJobs.js second.js voice.js

最終更新時間:2017年10月13日 10時14分20秒