mirror of
https://github.com/jambonz/jambonz-feature-server.git
synced 2025-12-20 16:50:39 +00:00
added initial support for dialogflow
This commit is contained in:
41
lib/tasks/dialogflow/transcription.js
Normal file
41
lib/tasks/dialogflow/transcription.js
Normal 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;
|
||||
Reference in New Issue
Block a user