add electron unit test, move local model files to /models directory
This commit is contained in:
Родитель
6bcb33df7d
Коммит
5b065ebd60
|
@ -1,9 +1,8 @@
|
|||
*.gz
|
||||
/models
|
||||
/build
|
||||
/dist
|
||||
/public/audio
|
||||
/public/*.pbmm
|
||||
/public/*.scorer
|
||||
|
||||
# Logs
|
||||
logs
|
||||
|
|
|
@ -21,8 +21,11 @@ tar xfvz audio-0.7.0.tar.gz -C ./public/
|
|||
(Optional) Download or softlink DeepSpeech 0.7.4 model files to the root of the project:
|
||||
|
||||
```
|
||||
mkdir models
|
||||
cd models
|
||||
wget https://github.com/mozilla/DeepSpeech/releases/download/v0.7.4/deepspeech-0.7.4-models.pbmm
|
||||
wget https://github.com/mozilla/DeepSpeech/releases/download/v0.7.4/deepspeech-0.7.4-models.scorer
|
||||
cd ..
|
||||
```
|
||||
|
||||
If the files do not exist, they will be downloaded.
|
||||
|
|
|
@ -14,7 +14,8 @@
|
|||
"rebuild": "npm rebuild --runtime=electron --target=9.0.5 --disturl=https://atom.io/download/atom-shell --abi=75",
|
||||
"pack": "npm run build && electron-builder --dir",
|
||||
"dist": "npm run build && electron-builder",
|
||||
"dist-win": "npm run build && electron-builder --x64"
|
||||
"dist-win": "npm run build && electron-builder --x64",
|
||||
"dev-test": "concurrently \"BROWSER=none npm start\" \"wait-on http://localhost:3000 && ./node_modules/.bin/electron public/electron.js DEEPSPEECH_TEST\""
|
||||
},
|
||||
"postinstall": "electron-builder install-app-deps",
|
||||
"homepage": "./",
|
||||
|
|
|
@ -37,10 +37,24 @@ function createWindow(model) {
|
|||
|
||||
// message from front-end App.js, request that this file be processed by DeepSpeech
|
||||
ipcMain.handle('recognize-wav', async function (event, file) {
|
||||
let filePath = path.resolve(__dirname, 'audio', file);
|
||||
return recognizeWav(filePath, model);
|
||||
const filePath = path.resolve(__dirname, 'audio', file);
|
||||
const results = await recognizeWav(filePath, model);
|
||||
if (results) checkDone(file, results);
|
||||
return results;
|
||||
});
|
||||
|
||||
let count = 0;
|
||||
function checkDone(file, results) {
|
||||
if (process.argv.indexOf('DEEPSPEECH_TEST') > -1) {
|
||||
count++
|
||||
console.log('test:', count, file, results);
|
||||
if (count === 3) {
|
||||
console.log('test done');
|
||||
process.exit();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// message from front-end App.js, retrieve list of .wav files in /public/audio
|
||||
ipcMain.handle('load-files', function (event) {
|
||||
return new Promise(function (resolve, reject) {
|
||||
|
|
|
@ -7,9 +7,9 @@ const {getModel} = require('./recognize-wav');
|
|||
|
||||
let appDataPath;
|
||||
|
||||
if (fs.existsSync(path.resolve(__dirname, '../deepspeech-0.7.4-models.pbmm'))) {
|
||||
if (fs.existsSync(path.resolve(__dirname, '../models/deepspeech-0.7.4-models.pbmm'))) {
|
||||
// if the deepspeech model was found at the root, use that directory
|
||||
appDataPath = path.resolve(__dirname, '..');
|
||||
appDataPath = path.resolve(__dirname, '../models');
|
||||
}
|
||||
else {
|
||||
// otherwise use the electron "appData" path
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -xe
|
||||
|
||||
THIS=$(dirname "$0")
|
||||
|
||||
pushd ${THIS}
|
||||
source ../tests.sh
|
||||
|
||||
npm install $(get_npm_package_url)
|
||||
npm install
|
||||
npm run rebuild
|
||||
|
||||
ln -s $HOME/DeepSpeech/models models
|
||||
ln -s ~/DeepSpeech/audio ./public/
|
||||
|
||||
npm run dev-test
|
||||
popd
|
Загрузка…
Ссылка в новой задаче