Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What time is it? #280

Closed
ikucukkaya opened this issue Jun 9, 2016 · 7 comments
Closed

What time is it? #280

ikucukkaya opened this issue Jun 9, 2016 · 7 comments

Comments

@ikucukkaya
Copy link

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

@decentralgabe
Copy link

decentralgabe commented Aug 28, 2016

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);
}());

@decentralgabe
Copy link

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...

@evancohen
Copy link
Owner

@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.

@decentralgabe
Copy link

decentralgabe commented Aug 30, 2016

@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.

@evancohen
Copy link
Owner

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).

@justbill2020
Copy link
Collaborator

removed suggestion label as this is being worked on and is labeled "next"

@justbill2020
Copy link
Collaborator

#386 duplicate

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants