mirror of
https://github.com/leon-ai/leon.git
synced 2024-09-11 18:27:21 +03:00
fix: addressed comments by @JRMeyer
This commit is contained in:
parent
04d6228841
commit
b1c6f5c883
@ -17,7 +17,7 @@ export default () => new Promise(async (resolve, reject) => {
|
||||
const npmMinRequiredVersion = '5'
|
||||
const pythonMinRequiredVersion = '3'
|
||||
const flitePath = 'bin/flite/flite'
|
||||
const coquiPath = 'bin/coqui/model.tflite'
|
||||
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'
|
||||
@ -173,11 +173,11 @@ export default () => new Promise(async (resolve, reject) => {
|
||||
}
|
||||
|
||||
log.info('Offline STT')
|
||||
if (!fs.existsSync(coquiPath)) {
|
||||
if (!fs.existsSync(coquiLanguageModelPath)) {
|
||||
report.can_offline_stt.v = false
|
||||
log.warning(`Cannot find ${coquiPath}. You can setup the offline STT by running: "npm run setup:offline-stt"`)
|
||||
log.warning(`Cannot find ${coquiLanguageModelPath}. You can setup the offline STT by running: "npm run setup:offline-stt"`)
|
||||
} else {
|
||||
log.success(`Found DeepSpeech language model at ${coquiPath}`)
|
||||
log.success(`Found Coqui language model at ${coquiLanguageModelPath}`)
|
||||
}
|
||||
|
||||
// Report
|
||||
|
@ -12,7 +12,8 @@ export default () => new Promise(async (resolve, reject) => {
|
||||
|
||||
const destCoquiFolder = 'bin/coqui'
|
||||
const tmpDir = 'scripts/tmp'
|
||||
const coquiVersion = '1.0.0'
|
||||
// check this repo for updates: https://github.com/coqui-ai/STT-models/tree/main/english/coqui
|
||||
const coquiModelVersion = '1.0.0'
|
||||
let downloader = 'wget'
|
||||
if (os.get().type === 'macos') {
|
||||
downloader = 'curl -L -O'
|
||||
@ -21,8 +22,8 @@ export default () => new Promise(async (resolve, reject) => {
|
||||
if (!fs.existsSync(`${destCoquiFolder}/model.tflite`)) {
|
||||
try {
|
||||
log.info('Downloading pre-trained model...')
|
||||
await command(`cd ${tmpDir} && ${downloader} https://github.com/coqui-ai/STT-models/releases/download/english/coqui/v${coquiVersion}-huge-vocab/model.tflite`, { shell: true })
|
||||
await command(`cd ${tmpDir} && ${downloader} https://github.com/coqui-ai/STT-models/releases/download/english/coqui/v${coquiVersion}-huge-vocab/huge-vocabulary.scorer`, { shell: true })
|
||||
await command(`cd ${tmpDir} && ${downloader} https://github.com/coqui-ai/STT-models/releases/download/english/coqui/v${coquiModelVersion}-huge-vocab/model.tflite`, { shell: true })
|
||||
await command(`cd ${tmpDir} && ${downloader} https://github.com/coqui-ai/STT-models/releases/download/english/coqui/v${coquiModelVersion}-huge-vocab/huge-vocabulary.scorer`, { shell: true })
|
||||
log.success('Pre-trained model download done')
|
||||
log.info('Moving...')
|
||||
await command(`mv -f ${tmpDir}/model.tflite ${destCoquiFolder}/model.tflite`, { shell: true })
|
||||
|
@ -1,30 +1,12 @@
|
||||
import wav from 'node-wav'
|
||||
import fs from 'fs'
|
||||
import { Model } from 'stt'
|
||||
|
||||
import log from '@/helpers/log'
|
||||
|
||||
log.title('Coqui-ai Parser')
|
||||
|
||||
const parser = { }
|
||||
let STT = { }
|
||||
|
||||
/* istanbul ignore next */
|
||||
try {
|
||||
STT = require('stt-gpu') // eslint-disable-line global-require, import/no-unresolved
|
||||
|
||||
log.success('GPU version found')
|
||||
} catch (eGpu) {
|
||||
log.info('GPU version not found, trying to get the CPU version...')
|
||||
|
||||
try {
|
||||
STT = require('stt') // eslint-disable-line global-require, import/no-unresolved
|
||||
|
||||
log.success('CPU version found')
|
||||
} catch (eCpu) {
|
||||
log.error(`No Coqui-ai library found:\nGPU: ${eGpu}\nCPU: ${eCpu}`)
|
||||
}
|
||||
}
|
||||
|
||||
let model = { }
|
||||
let desiredSampleRate = 16000
|
||||
|
||||
@ -57,7 +39,7 @@ parser.init = (args) => {
|
||||
/* istanbul ignore if */
|
||||
if (process.env.LEON_NODE_ENV !== 'testing') {
|
||||
try {
|
||||
model = new STT.Model(args.model)
|
||||
model = new Model(args.model)
|
||||
} catch (error) {
|
||||
throw Error(`model.stt: ${error}`)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user