-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #181 from nethesis/enable_google_speech
Added Speech to text UI
- Loading branch information
Showing
8 changed files
with
449 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
"use strict"; | ||
|
||
/** | ||
* @ngdoc function | ||
* @name nethvoiceWizardUiApp.controller:AppsVoicemailTextCtrl | ||
* @description | ||
* # AppsVoicemailTextCtrl | ||
* Controller of the nethvoiceWizardUiApp | ||
*/ | ||
angular | ||
.module("nethvoiceWizardUiApp") | ||
.controller( | ||
"AppsVoicemailTextCtrl", | ||
function ($rootScope, $scope, VoicemailTextService) { | ||
$scope.authorizationAvailable = false; | ||
|
||
$scope.getSpeechStatus = function () { | ||
VoicemailTextService.getGoogleSpeechStatus().then( | ||
function (res) { | ||
let status = res.data; | ||
if (status === "enabled") { | ||
$scope.voicemailTextEnabled = true; | ||
} else { | ||
$scope.voicemailTextEnabled = false; | ||
} | ||
}, | ||
function (err) { | ||
console.log(err); | ||
} | ||
); | ||
}; | ||
|
||
$scope.getAuthenticationFileStatus = function () { | ||
VoicemailTextService.getGoogleAuthentication().then( | ||
function (res) { | ||
$scope.authorizationAvailable = true; | ||
}, | ||
function (err) { | ||
console.log(err); | ||
$scope.authorizationAvailable = false; | ||
} | ||
); | ||
}; | ||
|
||
$scope.toggleVoicemailText = function () { | ||
$scope.voicemailTextEnabled == !$scope.voicemailTextEnabled; | ||
let status = ""; | ||
$scope.voicemailTextEnabled | ||
? (status = "enabled") | ||
: (status = "disabled"); | ||
VoicemailTextService.sendGoogleSpeechStatus({ | ||
status, | ||
}).then( | ||
function (res) {}, | ||
function (err) { | ||
console.log(err); | ||
} | ||
); | ||
}; | ||
|
||
$scope.uploadAuthorizationFile = function (authorizationFileBase64) { | ||
VoicemailTextService.uploadGoogleAuthorizationFile({ | ||
file: authorizationFileBase64, | ||
}).then( | ||
function (res) { | ||
$scope.authorizationAvailable = true; | ||
}, | ||
function (err) { | ||
console.log(err); | ||
} | ||
); | ||
}; | ||
|
||
$scope.tempVoicemail = {}; | ||
|
||
$scope.errorVoicemailUpload = { | ||
file: { | ||
status: false, | ||
title: "File format error", | ||
content: "File must be a JSON", | ||
}, | ||
}; | ||
|
||
$scope.googleAuthorizationUpload = function () { | ||
$("#uploadInput").click(); | ||
$("#uploadInput").change(function (e) { | ||
if (e.target.files[0].name != undefined) { | ||
$scope.tempVoicemail.jsonFileName = e.target.files[0].name; | ||
var reader = new FileReader(); | ||
reader.onload = function (ev) { | ||
$scope.$apply(function () { | ||
$scope.tempVoicemail.file64 = ev.target.result; | ||
$scope.uploadAuthorizationFile(ev.target.result); | ||
$scope.errorVoicemailUpload.file.status = false; | ||
$("#uploadInput").val(""); | ||
$("#uploadInput").unbind(); | ||
}); | ||
}; | ||
|
||
reader.readAsDataURL(e.target.files[0]); | ||
} else { | ||
$scope.$apply(function () { | ||
$scope.error.fileJson.status = true; | ||
}); | ||
} | ||
}); | ||
console.log("che valore ha", $scope.tempVoicemail.file64); | ||
}; | ||
|
||
$scope.getSpeechStatus(); | ||
$scope.getAuthenticationFileStatus(); | ||
} | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
"use strict"; | ||
|
||
/** | ||
* @ngdoc service | ||
* @name nethvoiceWizardUiApp.VoicemailTextService | ||
* @description | ||
* # VoicemailTextService | ||
* Service in the nethvoiceWizardUiApp. | ||
*/ | ||
angular | ||
.module("nethvoiceWizardUiApp") | ||
.service("VoicemailTextService", function ($q, RestService) { | ||
//Get status of google speech to text | ||
this.getGoogleSpeechStatus = function () { | ||
return $q(function (resolve, reject) { | ||
RestService.get("/configuration/voicemailgooglestt").then( | ||
function (res) { | ||
resolve(res); | ||
}, | ||
function (err) { | ||
reject(err); | ||
} | ||
); | ||
}); | ||
}; | ||
|
||
//Send new status of google speech to text | ||
this.sendGoogleSpeechStatus = function (objectSpeechStatus) { | ||
return $q(function (resolve, reject) { | ||
RestService.post( | ||
"/configuration/voicemailgooglestt/" + objectSpeechStatus.status | ||
).then( | ||
function (res) { | ||
resolve(res); | ||
}, | ||
function (err) { | ||
reject(err); | ||
} | ||
); | ||
}); | ||
}; | ||
|
||
//Send new status of google speech to text | ||
this.uploadGoogleAuthorizationFile = function (obj) { | ||
return $q(function (resolve, reject) { | ||
RestService.post("/configuration/googleauth", obj).then( | ||
function (res) { | ||
resolve(res); | ||
}, | ||
function (err) { | ||
reject(err); | ||
} | ||
); | ||
}); | ||
}; | ||
|
||
//Get status of autentichation file speech to text | ||
this.getGoogleAuthentication = function () { | ||
return $q(function (resolve, reject) { | ||
RestService.get("/configuration/googleauthexists").then( | ||
function (res) { | ||
resolve(res); | ||
}, | ||
function (err) { | ||
reject(err); | ||
} | ||
); | ||
}); | ||
}; | ||
}); |
Oops, something went wrong.