-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdevBot.js
73 lines (64 loc) · 2.29 KB
/
devBot.js
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
function introl(){
const ask=prompt("what is your name ?");
$("h6").html("hello"+" "+ask+" "+"am Roh-Bot");
}
const voice=()=>{
window.SpeechRecognition = window.webkitSpeechRecognition || window.SpeechRecognition;
const recognition=new SpeechRecognition();
recognition.lang="en_us";
recognition.onresult=(talk)=>{
const SpeechToText=talk.results [0][0].transcript;
if(SpeechToText=='Time'){
setInterval(function(){
let say=new Date().toLocaleTimeString();
$(".out").text(say);
},1000);
} else if(SpeechToText=='who are you'){
const ans=["i am yhoung AI","I am Dev bot","I am Roh-Bot"];
let pick=ans[Math.floor(Math.random()*3)];
$("#reply").text(pick);
} if(SpeechToText=='black'){
$("body").css("background-color","black");
} else if(SpeechToText=="white"){
$("body").css("background-color","white");
}
if(SpeechToText=="nice to meet you"){
const rep=["Nice to meet you too","ooh thanks pal","you are kind ","same so how was your day","I love your attitude","ooh am tired"];
var reply=rep[Math.ceil(Math.random()*6)];
$("#reply").text(reply);
}
else if(SpeechToText=="good"){
$("#reply").text("awesome");
}if(SpeechToText=="browser") {
alert(`your are using \t ${navigator.appName}`)
} else if(SpeechToText=="version"){
alert(`your are using \t ${navigator.appVersion}`)
}if(SpeechToText=="hello" || "Good morning" || "Good afternoon" || "Good evening"){
const put=["same","Good day","how are you doing ?"
];
const chop=put[Math.floor(Math.random()*4)];
$("#reply").text(chop);
}else if(SpeechToText=="am fine" || "fine"){
$("#reply").text("Good to hear");
} if(SpeechToText=="play"){
//show music (maroon 5 memories)
var aud=document.getElementsByTagName("audio")[0];
aud.style.display="block";
//play the music
aud.loop=true;
aud.play();
}
else if(SpeechToText==""){
alert("you did not say anything");
}if(SpeechToText=="photo"){
var drop=document.querySelector(".img-thumbnail").style. display="block";
}
else{
$(".form-control").css("font-weight","bold")
$(".form-control").val(SpeechToText);
}
}
recognition.start();
}
//more updates still coming
//bot still under construction