-
Notifications
You must be signed in to change notification settings - Fork 54
/
Copy pathsettings.js
63 lines (47 loc) · 1.65 KB
/
settings.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
const LocalStorage = require('node-localstorage').LocalStorage;
const os = require('os');
const path = require('path');
const fs = require('fs');
const odasStudioPath = path.join(os.homedir(), 'odas-studio');
const storagePath = path.join(odasStudioPath, 'config');
if(!fs.existsSync(odasStudioPath))
fs.mkdirSync(odasStudioPath);
const localStorage = new LocalStorage(storagePath);
class AppSettings {
constructor() {
if(localStorage.getItem('language') == null)
localStorage.setItem('language', 'fr-CA');
if(localStorage.getItem('sample-rate') == null)
localStorage.setItem('sample-rate', 16000);
if(localStorage.getItem('api-keyfile') == null)
localStorage.setItem('api-keyfile', 'google-api-key.json');
if(localStorage.getItem('use-speech') == null)
localStorage.setItem('use-speech', false);
}
set language(language) {
localStorage.setItem('language', language);
}
get language() {
return localStorage.getItem('language');
}
set sampleRate(sampleRate) {
localStorage.setItem('sample-rate', sampleRate);
}
get sampleRate() {
return parseInt(localStorage.getItem('sample-rate'));
}
set apiKeyfile(apiKeyfile) {
localStorage.setItem('api-keyfile', apiKeyfile);
}
get apiKeyfile() {
return localStorage.getItem('api-keyfile');
}
set useSpeech(useSpeech) {
localStorage.setItem('use-speech', useSpeech);
}
get useSpeech() {
return localStorage.getItem('use-speech') === 'true';
}
}
const appSettings = new AppSettings();
exports.appSettings = appSettings;