Created
March 19, 2017 19:58
-
-
Save jsmithdev/6b5bbcf2718294afaf7fac8e26c7a6b0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// LIVE @ https://jsfiddle.net/jamiesmith/q8aw51ry/ | |
Date.prototype.today = function () { | |
return ((this.getDate() < 10)?"0":"") + this.getDate() +"/"+(((this.getMonth()+1) < 10)?"0":"") + (this.getMonth()+1) +"/"+ this.getFullYear(); | |
} | |
Date.prototype.timeNow = function () { | |
return ((this.getHours() < 10)?"0":"") + this.getHours() +":"+ ((this.getMinutes() < 10)?"0":"") + this.getMinutes() | |
//+":"+ ((this.getSeconds() < 10)?"0":"") + this.getSeconds(); | |
} | |
const newDate = new Date(); | |
let d = newDate.timeNow() + " on " + newDate.today() | |
let speech = 'hey you, the time is '+d | |
const synth = window.speechSynthesis | |
let utterThis = new SpeechSynthesisUtterance(speech) | |
utterThis.lang = "en-US" | |
// uncomment below for Spanish | |
//utterThis.lang = "es" | |
synth.speak(utterThis) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment