Skip to content

Commit

Permalink
new english version
Browse files Browse the repository at this point in the history
  • Loading branch information
jamiewq committed Apr 27, 2017
1 parent 653deb6 commit b574626
Show file tree
Hide file tree
Showing 8 changed files with 78 additions and 87 deletions.
4 changes: 2 additions & 2 deletions frontend/app/config.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"language": "chinese",
"language": "english",
"language_options": [
"chinese",
"english"
Expand All @@ -13,4 +13,4 @@
"fetch_mp3": "http://duyuepu.com:5099/static/",
"user": "http://duyuepu.com:5000/api"
}
}
}
Binary file added frontend/app/resources/sounds/Left_en.ogg
Binary file not shown.
Binary file added frontend/app/resources/sounds/Right_en.ogg
Binary file not shown.
1 change: 1 addition & 0 deletions frontend/app/services/utility.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ angular.module('myApp')
var deferred = $q.defer();
httpUtil.get(config.api.music_score + "/musicscores/?keyword=" + search_text)
.then(function(response) {
debugger
if (response !== null) {
deferred.resolve(response);
}
Expand Down
67 changes: 45 additions & 22 deletions frontend/app/views/play/play.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,12 @@ angular.module('myApp.play', ['ngRoute'])

function tellCurrentOffset() {
utility.stop_all_sounds();
play([config.api.fetch_mp3 + ($scope.offset + 1) + "_zh.mp3"]);
let sound_source =
config.api.fetch_mp3
+ ($scope.offset + 1)
+ (lang=="chinese"? "_zh.mp3" : "")
+ (lang=="english"? "_en.ogg" : "")
play([sound_source]);

}

Expand All @@ -121,12 +126,21 @@ angular.module('myApp.play', ['ngRoute'])
function tellCurrentBlockSize() {
utility.stop_all_sounds();
if(changingBlockSize == false) {
if(lang=="chinese") {
play([config.api.fetch_mp3 + 'length' + "_zh.mp3", config.api.fetch_mp3 + 'length/' + $scope.blockSize + ".mp3"]);
console.log("sentenceSize");
changingBlockSize = true;
}
else if(lang=="english") {
play([config.api.fetch_mp3 + 'length' + "_en.ogg", config.api.fetch_mp3 + 'length/' + $scope.blockSize + "_en.ogg"]);
}
changingBlockSize = true;
}
else {
play([config.api.fetch_mp3 + 'length/' + $scope.blockSize + ".mp3"]);
if(lang=="chinese") {
play([config.api.fetch_mp3 + 'length/' + $scope.blockSize + ".mp3"]);
}
else if(lang == "english") {
play([config.api.fetch_mp3 + 'length/' + $scope.blockSize + "_en.ogg"]);
}
}
console.log($scope.blockSize);
if(timeout_promise != null) {
Expand All @@ -143,14 +157,14 @@ angular.module('myApp.play', ['ngRoute'])
$scope.offset += $scope.blockSize;
}
if(readout == undefined || readout == true) tellCurrentOffset();
$scope.display_list = [];
for (var i = 0; i < $scope.blockSize && i + $scope.offset < $scope.size; i++) {
if (lang == "chinese") {
$scope.display_list.push("第 " + (i + $scope.offset + 1) + " 小节");
} else if (lang.indexOf("en") != -1) {
$scope.display_list.push("Measure No." + (i + $scope.offset + 1));
}
}
// $scope.display_list = [];
// for (var i = 0; i < $scope.blockSize && i + $scope.offset < $scope.size; i++) {
// if (lang == "chinese") {
// $scope.display_list.push("第 " + (i + $scope.offset + 1) + " 小节");
// } else if (lang.indexOf("en") != -1) {
// $scope.display_list.push("Measure No." + (i + $scope.offset + 1));
// }
// }
$scope.$apply();
}

Expand All @@ -160,23 +174,26 @@ angular.module('myApp.play', ['ngRoute'])
} else {
$scope.offset = 0;
}
$scope.display_list = [];

if(readout == undefined || readout == true) tellCurrentOffset();

for (var i = 0; i < $scope.blockSize && i + $scope.offset < $scope.size; i++) {
if (lang == "chinese") {
$scope.display_list.push("第 " + (i + $scope.offset + 1) + " 小节");
} else if (lang.indexOf("en") != -1) {
$scope.display_list.push("Measure No." + (i + $scope.offset + 1));
}
}
// $scope.display_list = [];
//
// for (var i = 0; i < $scope.blockSize && i + $scope.offset < $scope.size; i++) {
// if (lang == "chinese") {
// $scope.display_list.push("第 " + (i + $scope.offset + 1) + " 小节");
// } else if (lang.indexOf("en") != -1) {
// $scope.display_list.push("Measure No." + (i + $scope.offset + 1));
// }
// }
$scope.$apply();
}

$scope.handFeekback = function() {
var sound_source = "/resources/sounds/" + $scope.hand
+(lang=="chinese"?".mp3":"")
+(lang=="english"?"_en.ogg":"");
var sound = new Howl({
src: ['/resources/sounds/'+$scope.hand+'.mp3'],
src: [sound_source],
preload: true,
autoplay: true,
rate : 1,
Expand All @@ -186,6 +203,9 @@ angular.module('myApp.play', ['ngRoute'])
},
onend: function() {
console.log('Finished!');
},
onloaderror: function(e){
debugger
}
});
}
Expand Down Expand Up @@ -228,6 +248,9 @@ angular.module('myApp.play', ['ngRoute'])
setTimeout(function() {
play(list);
}, 0);
},
onloaderror: function(e){
debugger
}
});
utility.active_sounds.push(sound);
Expand Down
6 changes: 3 additions & 3 deletions frontend/app/views/search/search.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
</div>

<div ng-if="showResult == true && selected !== null" class="result">
<p class="result-name">{{searchList[selected].name}}</p>
<p class="result-author">{{show("Composer") +" : "+ searchList[selected].composer}}</p>
<p class="result-difficulty">{{ show("Difficulty") + " : " + searchList[selected].hardness}}</p>
<p class="result-name">{{searchList[selected].title}}</p>
<p class="result-author">{{show("Composer") +" : "+ searchList[selected].author}}</p>
<p class="result-difficulty">{{ show("Difficulty") + " : Easy" }}</p>
</div>

<button ng-if="showResult == true && selected !== null && selected != 0" class="left-search" />
Expand Down
84 changes: 25 additions & 59 deletions frontend/app/views/search/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ angular.module('myApp.search', ['ngRoute'])
});
}])

.controller('SearchCtrl', ['$scope', 'httpUtil', 'navigation', 'fakeData', 'utility', 'display',
function($scope, httpUtil, navigation, fakeData, utility, display) {
.controller('SearchCtrl', ['$scope', 'httpUtil', 'navigation', 'fakeData', 'utility', 'display', 'config',
function($scope, httpUtil, navigation, fakeData, utility, display, config) {
$scope.shouldFocus = true;
$scope.showResult = false;
$scope.searchString = "";
Expand Down Expand Up @@ -71,23 +71,6 @@ angular.module('myApp.search', ['ngRoute'])
$scope.selected --;
$scope.$apply();
}
utility.get_voice_by_text($scope.searchList[$scope.selected].name)
.then(function(sound_url){
var sound = new Howl({
src: [sound_url],
autoplay: true,
loop: false,
onload: function() {
utility.stop_all_sounds();
utility.active_sounds.push(sound);
},
onend: function() {
console.log('Finished!');
}
});
}, function(error){

});
}
}

Expand All @@ -97,23 +80,6 @@ angular.module('myApp.search', ['ngRoute'])
$scope.selected ++;
$scope.$apply();
}
utility.get_voice_by_text($scope.searchList[$scope.selected].name)
.then(function(sound_url){
var sound = new Howl({
src: [sound_url],
autoplay: true,
loop: false,
onload: function() {
utility.stop_all_sounds();
utility.active_sounds.push(sound);
},
onend: function() {
console.log('Finished!');
}
});
}, function(error){

});
}
}

Expand All @@ -128,41 +94,41 @@ angular.module('myApp.search', ['ngRoute'])
.then(function(response) {
if (response !== null) {
$scope.searchList = response;
debugger
if($scope.searchList.length > 0) {
$scope.selected = 0;
utility.get_voice_by_text($scope.searchList[$scope.selected].name)
.then(function(sound_url){
var sound = new Howl({
src: [sound_url],
autoplay: true,
loop: false,
onload: function() {
utility.stop_all_sounds();
utility.active_sounds.push(sound);
},
onend: function() {
console.log('Finished!');
}
});
}, function(error){

});
var sound = new Howl({
src: [config.api.fetch_mp3 + $scope.searchList[$scope.selected].title_mp3],
preload: true,
autoplay: true,
rate: 1,
onload: function() {
utility.active_sounds.push(sound);
},
onend: function() {
console.log('Finished!');
list.splice(0, 1);
setTimeout(function() {
play(list);
}, 0);
},
onloaderror: function(e){
debugger
}
});
}
}
$scope.$apply();
}, function(error) {
var response = fakeData.searchList; // TODO: Change to real API data
if (response !== null) {
$scope.searchList = response;
if($scope.searchList.length > 0) $scope.selected = 0;
}
debugger
});

key('enter', function() {
console.log('enter key pressed');
$scope.focus();
$scope.showResult = false;
$scope.$apply();
navigation('play', {"id" : $scope.searchList[$scope.selected].name});
navigation('play', {"id" : $scope.searchList[$scope.selected].title});
});

key('left', function() {
Expand Down
3 changes: 2 additions & 1 deletion text2speech/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ var app = express();
var urlencode = require('urlencode');
var randomstring = require("randomstring");

// use: http://localhost:8001/speak?sentence=good day Jamie
// use: http://localhost:8001/speak?language=en&sentence=hello a everyone and oh my god what the hack
// http://localhost:8001/speak?language=zh-cn&sentence=hello a everyone and oh my god what the hack
// use: http://localhost:8001/voice/ffdsafdsafdsafsadrjenqw.wav

app.use(cors());
Expand Down

0 comments on commit b574626

Please sign in to comment.