Skip to content

Commit

Permalink
Merge pull request #35 from che-effe/FixResultAppendage
Browse files Browse the repository at this point in the history
return a new result for each recognition vs appending to previous
  • Loading branch information
zenorocha authored Nov 19, 2017
2 parents 9b48975 + adb03b6 commit d01df66
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
11 changes: 10 additions & 1 deletion dist/voice-recognition.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@
type: Boolean,
value: true
},
accent: {
type: String,
value: 'en-US',
observer: '_accentChanged',
notify: true
},
text: {
type: String,
value: ''
Expand Down Expand Up @@ -43,6 +49,9 @@
},

/* -- Private Methods ------------------------------------------- */
_accentChanged: function() {
this.recognition.lang = this.accent;
},
_propagateEvent: function (eventName) {
var that = this;

Expand All @@ -55,7 +64,7 @@

this.recognition.addEventListener('result', function(e) {
for (var i = e.resultIndex; i < e.results.length; ++i) {
that.text += e.results[i][0].transcript;
that.text = e.results[i][0].transcript;
e.result = that.text;
}

Expand Down
2 changes: 1 addition & 1 deletion src/voice-recognition.html
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@

this.recognition.addEventListener('result', function(e) {
for (var i = e.resultIndex; i < e.results.length; ++i) {
that.text += e.results[i][0].transcript;
that.text = e.results[i][0].transcript;
e.result = that.text;
}

Expand Down

1 comment on commit d01df66

@masonlouchart
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the fix of appendage contains default language for recognition?

What about set the value of accent to navigator.language || 'en-US'?

Please sign in to comment.