added initial support for dialogflow

This commit is contained in:
Dave Horton
2020-07-08 14:16:37 -04:00
parent c1112ea477
commit a4bcfca9e6
11 changed files with 579 additions and 6 deletions

View File

@@ -0,0 +1,41 @@
class Transcription {
constructor(logger, evt) {
this.logger = logger;
this.recognition_result = evt.recognition_result;
}
get isEmpty() {
return !this.recognition_result;
}
get isFinal() {
return this.recognition_result && this.recognition_result.is_final === true;
}
get confidence() {
if (!this.isEmpty) return this.recognition_result.confidence;
}
get text() {
if (!this.isEmpty) return this.recognition_result.transcript;
}
startsWith(str) {
return (this.text.toLowerCase() || '').startsWith(str.toLowerCase());
}
includes(str) {
return (this.text.toLowerCase() || '').includes(str.toLowerCase());
}
toJSON() {
return {
final: this.recognition_result.is_final === true,
text: this.text,
confidence: this.confidence
};
}
}
module.exports = Transcription;