Skip to content

Commit

Permalink
Merge pull request #181 from nethesis/enable_google_speech
Browse files Browse the repository at this point in the history
Added Speech to text UI
  • Loading branch information
tonyco97 authored May 10, 2023
2 parents 4eac4ca + 1199c40 commit e48acb6
Show file tree
Hide file tree
Showing 8 changed files with 449 additions and 76 deletions.
6 changes: 6 additions & 0 deletions wizard/app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -267,12 +267,16 @@
<div ng-if="!wizard.isWizard" class="panel-body adjust-panel-body list-group-item collapse-menu {{resolveActiveTab('paramurl',2) ? 'active' : ''}}">
<div ng-click="goTo('apps/paramurl')" class="list-group-item-value menu-item-left no-opacity full-width">{{'Parameterized URLs' | translate | ellipsis:'1200'}}</div>
</div>
<div ng-if="!wizard.isWizard" class="panel-body adjust-panel-body list-group-item collapse-menu {{resolveActiveTab('cloudServices',2) ? 'active' : ''}}">
<div ng-click="goTo('apps/cloudServices')" class="list-group-item-value menu-item-left no-opacity full-width">{{'Cloud services' | translate | ellipsis:'1200'}}</div>
</div>
<div ng-if="!wizard.isWizard" class="panel-body adjust-panel-body list-group-item collapse-menu {{resolveActiveTab('bulkextensions',2) ? 'active' : ''}}">
<div ng-click="goTo('apps/bulkextensions')" class="list-group-item-value menu-item-left no-opacity full-width">{{'Bulk extensions' | translate | ellipsis:'1200'}}</div>
</div>
<div ng-if="!wizard.isWizard && (wizard.provisioning == 'tancredi')" class="panel-body adjust-panel-body list-group-item collapse-menu {{resolveActiveTab('bulkdevices',2) ? 'active' : ''}}">
<div ng-click="goTo('apps/bulkdevices')" class="list-group-item-value menu-item-left no-opacity full-width">{{'Bulk phones' | translate | ellipsis:'1200'}}</div>
</div>

</div>

<!-- ADMINS -->
Expand Down Expand Up @@ -432,6 +436,7 @@
<script src="scripts/directives/genericerror.js"></script>
<script src="scripts/services/routeservice.js"></script>
<script src="scripts/services/codecservice.js"></script>
<script src="scripts/services/voicemailtextservice.js"></script>
<script src="scripts/filters/ellipsis.js"></script>
<script src="scripts/controllers/final.js"></script>
<script src="scripts/controllers/configurations/profiles.js"></script>
Expand All @@ -456,6 +461,7 @@
<script src="scripts/filters/blacklistfilternokeydsp.js"></script>
<script src="scripts/controllers/apps/streaming.js"></script>
<script src="scripts/controllers/apps/paramurl.js"></script>
<script src="scripts/controllers/apps/voicemailText.js"></script>
<script src="scripts/controllers/admin/languages.js"></script>
<script src="scripts/controllers/apps/bulkextensions.js"></script>
<script src="scripts/services/bulkservice.js"></script>
Expand Down
5 changes: 5 additions & 0 deletions wizard/app/scripts/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,11 @@ angular
controller: 'AppsParamurlCtrl',
controllerAs: 'apps/paramurl'
})
.when('/apps/cloudServices', {
templateUrl: 'views/apps/cloudServices.html',
controller: 'AppsVoicemailTextCtrl',
controllerAs: 'apps/voicemailText'
})
.when('/admin/languages', {
templateUrl: 'views/admin/languages.html',
controller: 'AdminLanguagesCtrl',
Expand Down
113 changes: 113 additions & 0 deletions wizard/app/scripts/controllers/apps/voicemailText.js
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();
}
);
3 changes: 2 additions & 1 deletion wizard/app/scripts/i18n/locale-en.json
Original file line number Diff line number Diff line change
Expand Up @@ -149,5 +149,6 @@
"expkeys_title": "Exp keys",
"expkey_label": "Exp key",
"progkey_label": "Label",
"upload_invalid_filename": "The file name is not valid. It can only contain letters, numbers and the symbols _ - . ( ) "
"upload_invalid_filename": "The file name is not valid. It can only contain letters, numbers and the symbols _ - . ( ) ",
"Spy":"Listen"
}
23 changes: 20 additions & 3 deletions wizard/app/scripts/i18n/locale-it.json
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@
"PBX CDR": "CDR globale",
"Group CDR": "CDR gruppo",
"Advanced SMS": "SMS avanzato",
"Spy": "Spia",
"Spy": "Ascolta",
"Intrude": "Intrusione",
"Advanced Recording": "Registrazioni avanzate",
"Pickup": "Pickup",
Expand All @@ -258,7 +258,7 @@
"Advanced Parking": "Parcheggio avanzato",
"PBX lines": "Linee centralino",
"Advanced queue agent panel": "Pannello agente di coda avanzato",
"Lost Queue Calls": "Chiamate perse code",
"Lost Queue Calls": "Chiamate non gestite",
"Advanced Off Hour": "Fuori orario avanzato",
"General and notifications settings": "Impostazioni generali di notifica",
"View Phonebook, add contacts, modify and delete own contacts": "Visualizza Rubrica, aggiungi contatti, modifica ed elimina i contatti propri",
Expand Down Expand Up @@ -1042,5 +1042,22 @@
"The change was not successful":"La modifica non è andata a buon fine",
"Choose the profile": "Scegli il profilo",
"Users Configuration": "Configurazione Utenti",
"In case of multiple selection will not be possible to see the outbound number if configurated in variable modality": "In caso di selezione multipla non è possibile visualizzare il numero in uscita se configurato nella modalità variabile"
"In case of multiple selection will not be possible to see the outbound number if configurated in variable modality": "In caso di selezione multipla non è possibile visualizzare il numero in uscita se configurato nella modalità variabile",
"Cloud services": "Servizi cloud",
"Cloud service configuration": "Configurazione servizi cloud",
"Enable Google speech-to-text": "Abilita Google Speech-to-text",
"Upload Google Auth JSON File": "Carica JSON di autenticazione di Google",
"Upload": "Carica",
"Google Cloud services description": "Google Cloud è una piattaforma di servizi cloud pubblica offerta da Google. La piattaforma fornisce un'ampia gamma di servizi. Questi servizi sono offerti su una scala globale, con data center in tutto il mondo che forniscono alta disponibilità e prestazioni affidabili. Google Cloud è una delle principali piattaforme cloud disponibili sul mercato, con un'ampia adozione in molti settori. Per saperne di più: ",
"Google Cloud official page": "Pagina ufficiale di Google Cloud",
"Google Cloud official documentation": "Documentazione ufficiale di Google Cloud",
"Google Cloud products": "Produtti Google Cloud",
"File already uploaded, click here to replace it": "File già caricato, clicca qui per sostituirlo",
"Select a file to upload": "Seleziona un file da caricare",
"Google cloud services": "Servizi di Google cloud",
"Google speech description": "Google Speech-to-Text è un servizio cloud che converte l'audio in testo utilizzando le tecnologie di riconosciment o vocale di Google. Per saperne di più:",
"Google STT official page": "Pagina ufficiale di Google SST",
"Google STT official documentation": "Documentazione ufficiale di Google SST",
"Google Speec-to-text": "Google Speech-to-Text",
"Token description": "Per accedere ai servizi di Google Cloud, è necessario fornire un token di autorizzazione valido. Puoi caricare il file JSON contenente le credenziali necessarie tramite il pulsante 'Upload'. Una volta caricato il file, il sistema utilizzerà le credenziali contenute nel JSON per autenticare le tue richieste ai servizi di Google Cloud."
}
70 changes: 70 additions & 0 deletions wizard/app/scripts/services/voicemailtextservice.js
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);
}
);
});
};
});
Loading

0 comments on commit e48acb6

Please sign in to comment.