leon
leon copied to clipboard
Error while setting up offline-tts on Windows 10
Specs
- Leon version: 1.0.0-beta.8
- OS (or browser) version: Windows 10
- Node.js version: v18.15.0
- Complete "leon check" (or "npm run check") output: .: REPORT :. âšī¸ Here is the diagnosis about your current setup â Run â Run skills â Reply you by texting â Start the TCP server â ī¸ Amazon Polly text-to-speech â ī¸ Google Cloud text-to-speech â ī¸ Watson text-to-speech â ī¸ Offline text-to-speech â ī¸ Google Cloud speech-to-text â ī¸ Watson speech-to-text â ī¸ Offline speech-to-text
â Hooray! Leon can run correctly âšī¸ If you have some yellow warnings, it is all good. It means some entities are not yet configured
- (if using Docker) Complete "npm run docker:check" output:
- (optional) Leon skill version:
Expected Behavior
Should Install offline tts
Actual Behavior
Got this error:
leon>npm run setup:offline-tts
[email protected] setup:offline-tts ts-node scripts/setup-offline/run-setup-tts.js
âšī¸ Setting up offline text-to-speech... âšī¸ Downloading run-time synthesis engine... đ¨ Failed to install offline text-to-speech: Error: Command failed with exit code 1: cd scripts/tmp && wget http://ports.ubuntu.com/pool/universe/f/flite/flite_2.1-release.orig.tar.bz2 'wget' is not recognized as an internal or external command, operable program or batch file. đ¨ Failed to set up offline TTS: Error: Command failed with exit code 1: cd scripts/tmp && wget http://ports.ubuntu.com/pool/universe/f/flite/flite_2.1-release.orig.tar.bz2 'wget' is not recognized as an internal or external command, operable program or batch file.
How Do We Reproduce?
Try installing on Windows 10
Extra (like a sample repo to reproduce the issue, etc.)
The problem is "wget" command which is not avaliable on windows sistem. Instead we can use de command "curl" with -o and -L option.
After some researches I figured out that the command
function executes the script inserted as parameter in cmd.exe in windows systems ( maybe I'm wrong ).
I tried to execute the curl command with -O and -L parameters, as mentioned before, but I got a couple of errors.
So I modified the parameters suplied to curl to avoid also The revocation function was unable to check revocation for the certificate
error with curl -O "http://simple-test" --ssl-no-revok
and everything went right.
Finally the modified code in "scripts/setup-offline/run-setup-tts.js" should be:
import`` fs from 'node:fs'
import { command } from 'execa'
import { LogHelper } from '@/helpers/log-helper'
import { SystemHelper } from '@/helpers/system-helper'
/**
* Set up offline text-to-speech
*/
export default () =>
new Promise(async (resolve, reject) => {
LogHelper.info('Setting up offline text-to-speech...')
const destFliteFolder = 'bin/flite'
const tmpDir = 'scripts/tmp'
let makeCores = ''
if (SystemHelper.getNumberOfCPUCores() > 2) {
makeCores = `-j ${SystemHelper.getNumberOfCPUCores() - 2}`
}
let downloader = 'wget'
if (SystemHelper.getInformation().type === 'macos') {
downloader = 'curl -L -O'
} else if (SystemHelper.getInformation().type === 'windows') { // this is the added block for windows curl command
downloader = 'curl -O --ssl-no-revok'
}
if (!fs.existsSync(`${destFliteFolder}/flite`)) {
try {
LogHelper.info('Downloading run-time synthesis engine...')
await command(
`cd ${tmpDir} && ${downloader} http://ports.ubuntu.com/pool/universe/f/flite/flite_2.1-release.orig.tar.bz2`,
{ shell: true }
)
LogHelper.success('Run-time synthesis engine download done')
LogHelper.info('Unpacking...')
await command(
`cd ${tmpDir} && tar xfvj flite_2.1-release.orig.tar.bz2 && cp ../assets/leon.lv flite-2.1-release/config`,
{ shell: true }
)
LogHelper.success('Unpack done')
LogHelper.info('Configuring...')
await command(
`cd ${tmpDir}/flite-2.1-release && ./configure --with-langvox=leon`,
{ shell: true }
)
LogHelper.success('Configure done')
LogHelper.info('Building...')
await command(`cd ${tmpDir}/flite-2.1-release && make ${makeCores}`, {
shell: true
})
LogHelper.success('Build done')
LogHelper.info('Cleaning...')
await command(
`cp -f ${tmpDir}/flite-2.1-release/bin/flite ${destFliteFolder} && rm -rf ${tmpDir}/flite-2.1-release*`,
{ shell: true }
)
LogHelper.success('Clean done')
LogHelper.success('Offline text-to-speech installed')
resolve()
} catch (e) {
LogHelper.error(`Failed to install offline text-to-speech: ${e}`)
reject(e)
}
} else {
LogHelper.success('Offline text-to-speech is already installed')
resolve()
}
})
curl check revocation error on stackoverflow: https://stackoverflow.com/questions/54938026/curl-unknown-error-0x80092012-the-revocation-function-was-unable-to-check-r
After replacing scripts/setup-offline/run-setup-tts.js with the above code, I now get this error:
c:\Users\User1\.leon>npm run setup:offline-tts
> [email protected] setup:offline-tts
> ts-node scripts/setup-offline/run-setup-tts.js
c:\Users\User1\.leon\node_modules\@swc\core\index.js:241
return bindings.transformSync(isModule ? JSON.stringify(src) : src, isModule, toBuffer(newOptions));
^
Error:
à Expected 'from', got '`'
ââ[c:/Users/User1/.leon/scripts/setup-offline/run-setup-tts.js:1:1]
1 â import`` fs from 'node:fs'
¡ â
â°ââââ
Caused by:
0: failed to process input file
1: Syntax Error
at Compiler.transformSync (c:\Users\User1\.leon\node_modules\@swc\core\index.js:241:29)
at Object.transformSync (c:\Users\User1\.leon\node_modules\@swc\core\index.js:348:21)
at Object.transpile (c:\Users\User1\.leon\node_modules\ts-node\src\transpilers\swc.ts:69:39)
at c:\Users\User1\.leon\node_modules\ts-node\src\index.ts:1355:35
at Object.compile (c:\Users\User1\.leon\node_modules\ts-node\src\index.ts:1458:13)
at Module.m._compile (c:\Users\User1\.leon\node_modules\ts-node\src\index.ts:1617:30)
at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)
at Object.require.extensions.<computed> [as .js] (c:\Users\User1\.leon\node_modules\ts-node\src\index.ts:1621:12)
at Module.load (node:internal/modules/cjs/loader:1207:32)
at Function.Module._load (node:internal/modules/cjs/loader:1023:12) {
code: 'GenericFailure'
}
c:\Users\User1\.leon>npm run setup:offline-stt
Evidently the Windows TTS script also needs a rewrite, as I get:
c:\Users\User1\.leon>npm run setup:offline-stt
> [email protected] setup:offline-stt
> ts-node scripts/setup-offline/run-setup-stt.js
âšī¸ Setting up offline speech-to-text...
âšī¸ Downloading pre-trained model...
đ¨ Failed to install offline speech-to-text: Error: Command failed with exit code 1: cd scripts/tmp && wget https://github.com/coqui-ai/STT-models/releases/download/english/coqui/v1.0.0-huge-vocab/model.tflite
'wget' is not recognized as an internal or external command,
operable program or batch file.
đ¨ Failed to set up offline STT: Error: Command failed with exit code 1: cd scripts/tmp && wget https://github.com/coqui-ai/STT-models/releases/download/english/coqui/v1.0.0-huge-vocab/model.tflite
'wget' is not recognized as an internal or external command,
operable program or batch file.
...so the same wget problem.
The problem is "wget" command which is not avaliable on windows sistem. Instead we can use de command "curl" with -o and -L option.
After some researches I figured out that the
command
function executes the script inserted as parameter in cmd.exe in windows systems ( maybe I'm wrong ).I tried to execute the curl command with -O and -L parameters, as mentioned before, but I got a couple of errors. So I modified the parameters suplied to curl to avoid also
The revocation function was unable to check revocation for the certificate
error withcurl -O "http://simple-test" --ssl-no-revok
and everything went right.Finally the modified code in "scripts/setup-offline/run-setup-tts.js" should be:
import`` fs from 'node:fs' import { command } from 'execa' import { LogHelper } from '@/helpers/log-helper' import { SystemHelper } from '@/helpers/system-helper' /** * Set up offline text-to-speech */ export default () => new Promise(async (resolve, reject) => { LogHelper.info('Setting up offline text-to-speech...') const destFliteFolder = 'bin/flite' const tmpDir = 'scripts/tmp' let makeCores = '' if (SystemHelper.getNumberOfCPUCores() > 2) { makeCores = `-j ${SystemHelper.getNumberOfCPUCores() - 2}` } let downloader = 'wget' if (SystemHelper.getInformation().type === 'macos') { downloader = 'curl -L -O' } else if (SystemHelper.getInformation().type === 'windows') { // this is the added block for windows curl command downloader = 'curl -O --ssl-no-revok' } if (!fs.existsSync(`${destFliteFolder}/flite`)) { try { LogHelper.info('Downloading run-time synthesis engine...') await command( `cd ${tmpDir} && ${downloader} http://ports.ubuntu.com/pool/universe/f/flite/flite_2.1-release.orig.tar.bz2`, { shell: true } ) LogHelper.success('Run-time synthesis engine download done') LogHelper.info('Unpacking...') await command( `cd ${tmpDir} && tar xfvj flite_2.1-release.orig.tar.bz2 && cp ../assets/leon.lv flite-2.1-release/config`, { shell: true } ) LogHelper.success('Unpack done') LogHelper.info('Configuring...') await command( `cd ${tmpDir}/flite-2.1-release && ./configure --with-langvox=leon`, { shell: true } ) LogHelper.success('Configure done') LogHelper.info('Building...') await command(`cd ${tmpDir}/flite-2.1-release && make ${makeCores}`, { shell: true }) LogHelper.success('Build done') LogHelper.info('Cleaning...') await command( `cp -f ${tmpDir}/flite-2.1-release/bin/flite ${destFliteFolder} && rm -rf ${tmpDir}/flite-2.1-release*`, { shell: true } ) LogHelper.success('Clean done') LogHelper.success('Offline text-to-speech installed') resolve() } catch (e) { LogHelper.error(`Failed to install offline text-to-speech: ${e}`) reject(e) } } else { LogHelper.success('Offline text-to-speech is already installed') resolve() } })
curl check revocation error on stackoverflow: https://stackoverflow.com/questions/54938026/curl-unknown-error-0x80092012-the-revocation-function-was-unable-to-check-r
One thing I'm fairly sure is wrong is that there shouldn't be the two ''s after the first 'import' in the script. I removed those and tried again. This time I get:
c:\Users\User1.leon\scripts\setup-offline>npm run setup:offline-tts
[email protected] setup:offline-tts ts-node scripts/setup-offline/run-setup-tts.js
and that's it. When I try to do
leon start
again I still get:
.: TTS :. âšī¸ Initializing TTS...
.: FLITE TTS SYNTHESIZER :. â New instance đ¨ Cannot find bin\flite\flite You can set up the offline TTS by running: "npm run setup:offline-tts"
I then went back to another doc page here:
https://docs.getleon.ai/1.0.0-beta.4/offline
And so I ran:
[email protected] setup:offline ts-node scripts/setup-offline/setup-offline.js
âšī¸ Checking OS environment... đ¨ Voice offline mode is not available on Windows đ¨ undefined
c:\Users\User1.leon\scripts\setup-offline>
So is it actually not supported yet?
Thanks for all your hard work on Leon!