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

Google stt #16

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 9 additions & 46 deletions config.js
Original file line number Diff line number Diff line change
@@ -1,62 +1,25 @@
/*******************************************************************************
* Copyright (c) 2015 IBM Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*******************************************************************************/

/*eslint-env node */
module.exports = {
/*options : {
//vad_threshold: '3.5',
//upperf: '1000',
//hmm: './deps/pocketsphinx-5prealpha/model/en-us/en-us',
//http://www.speech.cs.cmu.edu/tools/lmtool.html use this website
//to generate lm and dict file based on your keyword-name
//lm: './lm/humix.lm',
//dict: './lm/humix.dic',
//keyword-name: 'HUMIX', //all capital characters
//samprate: '16000',
//maxwpf: '5',
//topn: '2',
//maxhmmpf: '3000',
//pl_window: '7',
//ds: '2',
//cmdproc: './util/processcmd.sh',
//lang: 'zh-tw',
//wav-proc: './voice/interlude/beep2.wav',
//wav-bye: './voice/interlude/beep1.wav',
//logfn: '/dev/null'
},*/
lang: 'en', // 'en', 'cht' or 'chs'
'stt-engine': 'watson', // 'watson' or 'google',
'stt-engine': 'google', // 'watson' or 'google',
'tts-engine': 'watson', // 'watson' or 'itri' or 'iflytek'
stt: {
watson: {
username: '<your_username>',
passwd: '<your_password>'
username: '',
passwd: ''
},
google: {
username: 'xxxxx',
passwd: '<replace as your appid>'
googleCredentialFile: '',//the location of your google auth credential file.
googleProjectName: '',//the project name which create your credential file.
googleLan:'en-US',// en-Us or cmn-Hant-TW
}
},
tts: {
watson: {
username: '<your_username>',
passwd: '<your_password>'
username: '',
passwd:''
},
iflytek: {
appid: '123456'
appid: '<app_id>'
},
itri: {
username: '<your_username>',
Expand Down
16 changes: 11 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ var Buffer = require('buffer').Buffer;
var path = require('path');
var watson = require('watson-developer-cloud');
//var Sound = require('node-aplay');
var HumixSense = require('node-humix-sense');
var HumixSense = require('humix-sense');
var log = require('humix-logger').createLogger('humix-dialog-module', {
consoleLevel : 'debug'
});
Expand Down Expand Up @@ -98,6 +98,7 @@ var commandRE = /---="(.*)"=---/;
* '----="command string"=---'
*/
function receiveCommand(cmdstr) {
sendAplay2HumixSpeech('voice/interlude/beep3.wav');
cmdstr = cmdstr.trim();
if (config['stt-engine']) {
log.debug('command found:', cmdstr);
Expand Down Expand Up @@ -131,7 +132,7 @@ try {
ds: '2',
cmdproc: './util/processcmd.sh',
lang: 'zh-tw',
'wav-proc': './voice/interlude/beep2.wav',
'wav-proc': './voice/interlude/beep3.wav',
'wav-bye': './voice/interlude/beep1.wav',
logfn: '/dev/null'
};
Expand All @@ -145,6 +146,7 @@ try {
engineIndex[engine], require('./lib/' + engine).startSession);
hs.start(receiveCommand);
} catch (error) {
console.log('catch this error');
log.error(error);
}

Expand Down Expand Up @@ -221,6 +223,7 @@ function sendAplay2HumixSpeech(file) {
* Watson TTS Processing
*/
function WatsonTTS(text, filename) {
console.log('enter the TTS and the text is : ' + text);
ttsWatson.synthesize({
text : text,
accept : 'audio/wav'
Expand Down Expand Up @@ -351,8 +354,11 @@ function cleanup() {
}
}
process.on('SIGINT', function() {
cleanup();
process.exit(0);
console.log('prcess interupt');
//cleanup();
//process.exit(1);
process.abort()
// process.exit(0);
});
process.on('SIGHUP', function() {
cleanup();
Expand All @@ -371,7 +377,7 @@ process.on('error', function() {

process.on('uncaughtException', function(err) {
if (err.toString().indexOf('connect ECONNREFUSED')) {
log.error('exception,', JSON.stringify(err));
//log.error('exception,', JSON.stringify(err));
//cleanup();
//process.exit(0);
}
Expand Down
Loading