Skip to content

Commit

Permalink
RSS + removing ding. Fixes evancohen#287 (evancohen#294)
Browse files Browse the repository at this point in the history
* RSS Service (evancohen#161)

* Create rss-service

* RSS service

* Support for RSS service

* RSS service

* Update index.html

* RSS service

* minor updates

* Added rss-service

* Randomize the news

* Revert "Randomize the news"

This reverts commit ef94678.

* RSS fixes

* RSS fixes

* RSS fixes

* removing rss-service.js

* Fixing an unpextec line issue after merge

* RSS display fixes

* RSS display fixes

* RSS display fixes

* Removing ding as a result of evancohen#287

The ding was causing a freeze in a rewind. This is a temporary workaround to stop the keyword spotter from hanging after a few utterances.
  • Loading branch information
evancohen authored Jun 15, 2016
1 parent 1b5733b commit c8251b2
Show file tree
Hide file tree
Showing 8 changed files with 117 additions and 2 deletions.
5 changes: 5 additions & 0 deletions config.example.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ var config = {
},
traffic: {
key : "", // Bing Maps API Key

reload_interval : 5, // Number of minutes the information is refreshed
// An array of tips that you would like to display travel time for
trips : [{
Expand All @@ -81,6 +82,10 @@ var config = {
/*startTime: "",
endTime: ""*/ // Optional starttime and endtime when the traffic information should be displayed on screen. The format can be either hh:mm or hh:mm am/pm
}]
},
rss: {
feeds : [], // RSS feeds list - e.g. ["rss1.com", "rss2.com"]
refreshInterval : 120 // Number of minutes the information is refreshed
}
};

Expand Down
20 changes: 19 additions & 1 deletion css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -356,4 +356,22 @@ ul.calendar {

.xkcd {
-webkit-filter: invert(100%);
max-width: 100%; }
max-width: 100%;
}

.news {
height: 75px;
margin-bottom: 5px;
}

.news-title {
font-family: 'Open Sans', sans-serif;
font-size: 12px;
margin-bottom: 5px;
}

.news-content {
font-family: 'Open Sans', sans-serif;
font-size: 20px;
margin-bottom: 55px;
}
13 changes: 13 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
<script src="js/services/traffic.js"></script>
<script src="js/services/fitbit.js"></script>
<script src="js/services/reminder.js"></script>
<script src="js/services/rss.js"></script>
<script src="js/controller.js"></script>

<!-- Styles and Resources -->
Expand Down Expand Up @@ -156,6 +157,18 @@ <h2>{{ 'commands.title' | translate }}</h2>
</small>
</div>

<div class="news">
<div class="fade" ng-show="focus == 'default' && shownews && news != null">
<div class="news-title dimmed fade">
<span><i class="fa fa-rss fade" style="margin-right: 5px";></i></span>
<span fade>Source: {{news.title}}, Last Updated: {{news.lastUpdated.format('MMM DD, h:mm a')}} </span>
</div>
<div class="news-content fade">
<span class="fade">{{news.content}}</span>
</div>
</div>
</div>

<div class="error" ng-bind="speechError" ng-show="speechError"></div>
<div class="interim-result" ng-bind="interimResult" ng-hide="speechError"></div>
</div>
Expand Down
19 changes: 19 additions & 0 deletions js/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@
ReminderService,
SearchService,
SoundCloudService,
RssService,
$rootScope, $scope, $timeout, $interval, tmhDynamicLocale, $translate) {
var _this = this;
$scope.listening = false;
$scope.debug = false;
$scope.focus = "default";
$scope.user = {};
$scope.shownews = true;
$scope.commands = [];
/*$translate('home.commands').then(function (translation) {
$scope.interimResult = translation;
Expand Down Expand Up @@ -169,6 +171,23 @@

$interval(refreshComic, 12*60*60000); // 12 hours

var refreshRss = function () {
console.log ("Refreshing RSS");
$scope.news = null;
RssService.refreshRssList();
};

var updateNews = function() {
$scope.shownews = false;
setTimeout(function(){ $scope.news = RssService.getNews(); $scope.shownews = true; }, 1000);
};

refreshRss();
$interval(refreshRss, config.rss.refreshInterval * 60000);

updateNews();
$interval(updateNews, 8000); // cycle through news every 8 seconds

var addCommand = function(commandId, commandFunction){
var voiceId = 'commands.'+commandId+'.voice';
var textId = 'commands.'+commandId+'.text';
Expand Down
60 changes: 60 additions & 0 deletions js/services/rss.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
(function(annyang) {
'use strict';

function RssService($http) {
var service = {};
service.feed = [];
service.currentFeed = 0;

service.init = function() {
service.feed = [];
service.currentFeed = 0;
var currentTime = new moment();

angular.forEach(config.rss.feeds, function(url) {
$http.jsonp('http://ajax.googleapis.com/ajax/services/feed/load?v=1.0&num=50&callback=JSON_CALLBACK&q=' + encodeURIComponent(url)).then(function(response) {
for (var i=0; i < response.data.responseData.feed.entries.length; i++){
var feedEntry = {
title : response.data.responseData.feed.title,
content: response.data.responseData.feed.entries[i].title,
lastUpdated : currentTime,
};
//console.log(feedEntry);
service.feed.push(feedEntry);
}
});
});
return service.feed;
};

service.refreshRssList = function() {
return service.init();
};

service.getNews = function() {
if (service.feed == null) {
return null;
}
switch (config.rss.mode) {
case 'random':
service.currentFeed = Math.floor(Math.random() * service.feed.length);
break;

case 'sequence':
default:
if (service.currentFeed == (service.feed.length-1)){
service.currentFeed = 0;
}
else {
service.currentFeed = service.currentFeed + 1;
}
};
return service.feed[service.currentFeed];
} ;

return service;
}

angular.module('SmartMirror')
.factory('RssService', RssService);
}(window.annyang));
Empty file modified scripts/install.sh
100755 → 100644
Empty file.
Empty file modified speech/_snowboydetect.so
100755 → 100644
Empty file.
2 changes: 1 addition & 1 deletion speech/kws.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def interrupt_callback():

def hotword_detected_callback():
print("!Hotword Detected")
snowboydecoder.play_audio_file(snowboydecoder.DETECT_DING)
#snowboydecoder.play_audio_file(snowboydecoder.DETECT_DING)

if len(sys.argv) < 2:
print("Error: need to specify model name and sensitivity")
Expand Down

0 comments on commit c8251b2

Please sign in to comment.