Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error while setting up offline-tts on Windows 10 #488

Open
myramnath opened this issue May 11, 2023 · 4 comments
Open

Error while setting up offline-tts on Windows 10 #488

myramnath opened this issue May 11, 2023 · 4 comments
Labels
bug Indicates an unexpected problem or unintended behavior.

Comments

@myramnath
Copy link

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.)

@myramnath myramnath added the bug Indicates an unexpected problem or unintended behavior. label May 11, 2023
@TheAnalist
Copy link

TheAnalist commented May 12, 2023

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

@thebitmaster
Copy link

thebitmaster commented Jan 5, 2024

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.

@thebitmaster
Copy link

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

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"

@thebitmaster
Copy link

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior.
Projects
None yet
Development

No branches or pull requests

3 participants