mirror of
https://github.com/leon-ai/leon.git
synced 2024-11-23 20:12:08 +03:00
refactor: move up /server/src/config to /core level
This commit is contained in:
parent
dcddacca29
commit
3713521b08
2
.gitignore
vendored
2
.gitignore
vendored
@ -8,7 +8,7 @@ test/coverage/
|
||||
bridges/python/.venv/*
|
||||
downloads/*
|
||||
logs/*
|
||||
server/src/config/**/*.json
|
||||
core/config/**/*.json
|
||||
bin/coqui/*
|
||||
bin/flite/*
|
||||
|
||||
|
@ -18,10 +18,10 @@ export default () => new Promise(async (resolve, reject) => {
|
||||
const pythonMinRequiredVersion = '3'
|
||||
const flitePath = 'bin/flite/flite'
|
||||
const coquiLanguageModelPath = 'bin/coqui/huge-vocabulary.scorer'
|
||||
const amazonPath = 'server/src/config/voice/amazon.json'
|
||||
const googleCloudPath = 'server/src/config/voice/google-cloud.json'
|
||||
const watsonSttPath = 'server/src/config/voice/watson-stt.json'
|
||||
const watsonTtsPath = 'server/src/config/voice/watson-tts.json'
|
||||
const amazonPath = 'core/config/voice/amazon.json'
|
||||
const googleCloudPath = 'core/config/voice/google-cloud.json'
|
||||
const watsonSttPath = 'core/config/voice/watson-stt.json'
|
||||
const watsonTtsPath = 'core/config/voice/watson-tts.json'
|
||||
const nlpModelPath = 'core/data/leon-model.nlp'
|
||||
const report = {
|
||||
can_run: { title: 'Run', type: 'error', v: true },
|
||||
|
@ -1,5 +1,6 @@
|
||||
import { google } from 'googleapis'
|
||||
import fs from 'fs'
|
||||
import path from 'path'
|
||||
import { waterfall } from 'async'
|
||||
|
||||
import log from '@/helpers/log'
|
||||
@ -58,7 +59,7 @@ class Synchronizer {
|
||||
const driveFolderName = `leon-${this.classification.domain}-${this.classification.skill}`
|
||||
const folderMimeType = 'application/vnd.google-apps.folder'
|
||||
const entities = fs.readdirSync(this.downloadDir)
|
||||
const key = JSON.parse(fs.readFileSync(`${__dirname}/../config/synchronizer/google-drive.json`, 'utf8'))
|
||||
const key = JSON.parse(fs.readFileSync(path.join(process.cwd(), 'core/config/synchronizer/google-drive.json'), 'utf8'))
|
||||
const authClient = new google.auth.JWT(
|
||||
key.client_email,
|
||||
key,
|
||||
|
@ -1,3 +1,4 @@
|
||||
import path from 'path'
|
||||
import stt from '@google-cloud/speech'
|
||||
|
||||
import log from '@/helpers/log'
|
||||
@ -18,7 +19,7 @@ parser.conf = {
|
||||
* the env variable "GOOGLE_APPLICATION_CREDENTIALS" provides the JSON file path
|
||||
*/
|
||||
parser.init = () => {
|
||||
process.env.GOOGLE_APPLICATION_CREDENTIALS = `${__dirname}/../../config/voice/google-cloud.json`
|
||||
process.env.GOOGLE_APPLICATION_CREDENTIALS = path.join(process.cwd(), 'core/config/voice/google-cloud.json')
|
||||
|
||||
try {
|
||||
client = new stt.SpeechClient()
|
||||
|
@ -1,4 +1,5 @@
|
||||
import fs from 'fs'
|
||||
import path from 'path'
|
||||
|
||||
import Asr from '@/core/asr'
|
||||
import log from '@/helpers/log'
|
||||
@ -32,9 +33,9 @@ class Stt {
|
||||
|
||||
/* istanbul ignore next */
|
||||
if (this.provider === 'google-cloud-stt' && typeof process.env.GOOGLE_APPLICATION_CREDENTIALS === 'undefined') {
|
||||
process.env.GOOGLE_APPLICATION_CREDENTIALS = `${__dirname}/../config/voice/google-cloud.json`
|
||||
process.env.GOOGLE_APPLICATION_CREDENTIALS = path.join(process.cwd(), 'core/config/voice/google-cloud.json')
|
||||
} else if (typeof process.env.GOOGLE_APPLICATION_CREDENTIALS !== 'undefined'
|
||||
&& process.env.GOOGLE_APPLICATION_CREDENTIALS.indexOf('config/voice/google-cloud.json') === -1) {
|
||||
&& process.env.GOOGLE_APPLICATION_CREDENTIALS.indexOf('google-cloud.json') === -1) {
|
||||
log.warning(`The "GOOGLE_APPLICATION_CREDENTIALS" env variable is already settled with the following value: "${process.env.GOOGLE_APPLICATION_CREDENTIALS}"`)
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
import Stt from 'ibm-watson/speech-to-text/v1'
|
||||
import { IamAuthenticator } from 'ibm-watson/auth'
|
||||
import fs from 'fs'
|
||||
import path from 'path'
|
||||
import { Duplex } from 'stream'
|
||||
|
||||
import log from '@/helpers/log'
|
||||
@ -19,7 +20,7 @@ parser.conf = {
|
||||
* Initialize Watson Speech-to-Text based on credentials in the JSON file
|
||||
*/
|
||||
parser.init = () => {
|
||||
const config = JSON.parse(fs.readFileSync(`${__dirname}/../../config/voice/watson-stt.json`, 'utf8'))
|
||||
const config = JSON.parse(fs.readFileSync(path.join(process.cwd(), 'core/config/voice/watson-stt.json'), 'utf8'))
|
||||
|
||||
try {
|
||||
client = new Stt({
|
||||
|
@ -3,6 +3,7 @@ import Ffmpeg from 'fluent-ffmpeg'
|
||||
import { path as ffmpegPath } from '@ffmpeg-installer/ffmpeg'
|
||||
import { path as ffprobePath } from '@ffprobe-installer/ffprobe'
|
||||
import fs from 'fs'
|
||||
import path from 'path'
|
||||
|
||||
import log from '@/helpers/log'
|
||||
import string from '@/helpers/string'
|
||||
@ -29,7 +30,7 @@ synthesizer.conf = {
|
||||
* Initialize Amazon Polly based on credentials in the JSON file
|
||||
*/
|
||||
synthesizer.init = (lang) => {
|
||||
const config = JSON.parse(fs.readFileSync(`${__dirname}/../../config/voice/amazon.json`, 'utf8'))
|
||||
const config = JSON.parse(fs.readFileSync(path.join(process.cwd(), 'core/config/voice/amazon.json'), 'utf8'))
|
||||
synthesizer.conf.VoiceId = voices[lang].VoiceId
|
||||
|
||||
try {
|
||||
|
@ -3,6 +3,7 @@ import Ffmpeg from 'fluent-ffmpeg'
|
||||
import { path as ffmpegPath } from '@ffmpeg-installer/ffmpeg'
|
||||
import { path as ffprobePath } from '@ffprobe-installer/ffprobe'
|
||||
import fs from 'fs'
|
||||
import path from 'path'
|
||||
|
||||
import log from '@/helpers/log'
|
||||
import string from '@/helpers/string'
|
||||
@ -37,7 +38,7 @@ synthesizer.conf = {
|
||||
* The env variable "GOOGLE_APPLICATION_CREDENTIALS" provides the JSON file path
|
||||
*/
|
||||
synthesizer.init = (lang) => {
|
||||
process.env.GOOGLE_APPLICATION_CREDENTIALS = `${__dirname}/../../config/voice/google-cloud.json`
|
||||
process.env.GOOGLE_APPLICATION_CREDENTIALS = path.join(process.cwd(), 'core/config/voice/google-cloud.json')
|
||||
synthesizer.conf.voice = voices[lang]
|
||||
|
||||
try {
|
||||
|
@ -1,5 +1,6 @@
|
||||
import events from 'events'
|
||||
import fs from 'fs'
|
||||
import path from 'path'
|
||||
|
||||
import log from '@/helpers/log'
|
||||
import lang from '@/helpers/lang'
|
||||
@ -39,9 +40,9 @@ class Tts {
|
||||
|
||||
/* istanbul ignore next */
|
||||
if (this.provider === 'google-cloud-tts' && typeof process.env.GOOGLE_APPLICATION_CREDENTIALS === 'undefined') {
|
||||
process.env.GOOGLE_APPLICATION_CREDENTIALS = `${__dirname}/../config/voice/google-cloud.json`
|
||||
process.env.GOOGLE_APPLICATION_CREDENTIALS = path.join(process.cwd(), 'core/config/voice/google-cloud.json')
|
||||
} else if (typeof process.env.GOOGLE_APPLICATION_CREDENTIALS !== 'undefined'
|
||||
&& process.env.GOOGLE_APPLICATION_CREDENTIALS.indexOf('config/voice/google-cloud.json') === -1) {
|
||||
&& process.env.GOOGLE_APPLICATION_CREDENTIALS.indexOf('google-cloud.json') === -1) {
|
||||
log.warning(`The "GOOGLE_APPLICATION_CREDENTIALS" env variable is already settled with the following value: "${process.env.GOOGLE_APPLICATION_CREDENTIALS}"`)
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,7 @@ import Ffmpeg from 'fluent-ffmpeg'
|
||||
import { path as ffmpegPath } from '@ffmpeg-installer/ffmpeg'
|
||||
import { path as ffprobePath } from '@ffprobe-installer/ffprobe'
|
||||
import fs from 'fs'
|
||||
import path from 'path'
|
||||
|
||||
import log from '@/helpers/log'
|
||||
import string from '@/helpers/string'
|
||||
@ -30,7 +31,7 @@ synthesizer.conf = {
|
||||
* Initialize Watson Text-to-Speech based on credentials in the JSON file
|
||||
*/
|
||||
synthesizer.init = (lang) => {
|
||||
const config = JSON.parse(fs.readFileSync(`${__dirname}/../../config/voice/watson-tts.json`, 'utf8'))
|
||||
const config = JSON.parse(fs.readFileSync(path.join(process.cwd(), 'core/config/voice/watson-tts.json'), 'utf8'))
|
||||
synthesizer.conf.voice = voices[lang].voice
|
||||
|
||||
try {
|
||||
|
Loading…
Reference in New Issue
Block a user