What time is it?
The "what time is it" command is shown in the available commands however it has no effect. Evan I open a new issue because you told me if i didn't misunderstand you :d
I've been playing with getting this working today and am nearly there. I've been using the SpeechSynthesisUtterance API. Here's the code I've got so far (in a new file named time.js). Haven't gotten sound working quite yet, but this method does work if I run it from a non-mirror js console.
(function() {
'use strict';
function getTime() {
var currentTime = new Date();
var hours = currentTime.getHours();
var minutes = currentTime.getMinutes();
var t = "The time is ";
if (minutes < 10) {
minutes = "0" + minutes;
}
if (hours > 11) {
if (hours != 12) {
hours = hours - 12;
}
t += hours + ":" + minutes + " " + "PM";
}
else { // (hours <= 11)
t += hours + ":" + minutes + " " + "AM";
}
return t;
}
function TimeService() {
var service = {};
service.speakTime = function(msg) {
var msg = new SpeechSynthesisUtterance(getTime());
speechSynthesis.speak(msg);
};
return service;
}
angular.module('SmartMirror')
.factory('TimeService', TimeService);
}());
I had been exploring Artyom, but it looks like, unfortunately, Google has discontinued the use of the Speech API in embedded/dev chromium environments.
https://discuss.atom.io/t/webkitspeechrecognition-google-webkit-speech-api-throws-network-error-in-electron-app/27958/3
Not sure what to look into next...
@glcohen I think what you are talking about is unrelated to this issue... As for the Speech API, the workaround is in the documentation and is no longer an issue for us.
@evancohen
Could you point me to the documentation with the workaround?
As far as I can tell the problem is that speechSynthesis won't load any voices (speechSynthesis.getVoices() returns a null set), because synthesis isn't supported in Chromium. The rest of the Speech API is not the issue, I have voice commands working just fine with Google API keys.
Edit: Should I open up a new issue for this? I assumed the desired functionality to "what time is it" is to have the time spoken to the user.
Having the mirror talk back to you is not really a missing feature, I have expressly kept it out of the mirror up until now. See my response in #78 for details.
You should open up a new issue for this and we can discuss the merits of the mirror responding to you via voice there (I'll try to help you get speech synthesis working regardless).
removed suggestion label as this is being worked on and is labeled "next"
#386 duplicate