Skip to content

Commit

Permalink
Merge pull request #154 from daisy/tts-config
Browse files Browse the repository at this point in the history
feat(tts): configure tts via settings dialog
  • Loading branch information
marisademeglio authored Sep 25, 2023
2 parents 3b9c7e0 + 8fb662e commit 9400a26
Show file tree
Hide file tree
Showing 25 changed files with 1,009 additions and 150 deletions.
148 changes: 148 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
# this is pre-set to run on a specific revision, for troubleshooting purposes
name: Test copy of Build macOS/Windows distributions

on:
workflow_dispatch:
inputs:
refToBuild:
description: 'Branch, tag or commit SHA1 to build'
required: true
type: string
push:
tags:
- '*'

jobs:
build:
runs-on: ${{ matrix.os }}

strategy:
matrix:
os: [macos-latest, windows-latest]

steps:
- name: Check out Git repository
uses: actions/checkout@v3
with:
ref: ${{ inputs.refToBuild }}

- name: Install Node.js, NPM and Yarn
uses: actions/setup-node@v1
with:
node-version: 16

- name: Install Java and Maven
uses: actions/setup-java@v2
with:
distribution: 'adopt'
java-version: '11'

- name: Check out submodule
run: git submodule update --init --recursive

- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- name: Cache yarn
uses: actions/cache@v3
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Cache downloaded Maven dependencies
uses: actions/cache@v3
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Cache downloaded JRE
uses: actions/cache@v3
with:
path: engine/src/main/jre
# always update cache using this trick:
# https://github.com/actions/cache/blob/main/tips-and-workarounds.md#update-a-cache
key: ${{ runner.os }}-jre-${{ github.run_id }}
restore-keys: |
${{ runner.os }}-jre-
- name: Install GNU Make on macOS
if: ${{ matrix.os == 'macos-latest' }}
run: |
brew update
brew install make
- name: Build DMG if on macOS
if: ${{ matrix.os == 'macos-latest' }}
run: gmake dmg

- name: Build EXE if on Windows
if: ${{ matrix.os == 'windows-latest' }}
shell: cmd
run: engine\\make.exe exe

- name: Upload the DMG
if: ${{ matrix.os == 'macos-latest' }}
uses: actions/upload-artifact@v3
with:
name: "daisy-pipeline.dmg"
path: dist/*.dmg

- name: Upload the EXE
if: ${{ matrix.os == 'windows-latest' }}
uses: actions/upload-artifact@v3
with:
name: "daisy-pipeline.exe"
path: dist/*.exe

# # This is a basic workflow that is manually triggered

# name: Test build workflow

# on:
# workflow_dispatch:

# env:
# GH_TOKEN: ${{ secrets.GH_PIPELINE_TOKEN }}

# # A workflow run is made up of one or more jobs that can run sequentially or in parallel
# jobs:
# build:
# runs-on: ${{ matrix.os }}

# strategy:
# matrix:
# os: [macos-latest]

# steps:
# - name: Check out Git repository
# uses: actions/checkout@v1

# - name: Install Node.js, NPM and Yarn
# uses: actions/setup-node@v1
# with:
# node-version: 16

# - name: Get yarn cache directory path
# id: yarn-cache-dir-path
# run: echo "::set-output name=dir::$(yarn cache dir)"
# - name: Cache yarn
# uses: actions/cache@v3
# with:
# path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
# key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
# restore-keys: |
# ${{ runner.os }}-yarn-

# - name: Run install
# uses: borales/actions-yarn@v4
# with:
# cmd: install # will run `yarn install` command

# - name: Run build
# uses: borales/actions-yarn@v4
# with:
# cmd: dist-mac-dev
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ ENGINE_VERSION := $(shell println(xpath(new File("engine/pom.xml"), "/*/*[local-
.PHONY : dmg
dmg : src/resources/daisy-pipeline src/resources/icons/[email protected]
exec("yarn");
exec("yarn", "dist", "--mac");
exec("yarn", "dist-mac-dev", "--mac");

.PHONY : exe
exe : src/resources/daisy-pipeline
Expand Down Expand Up @@ -48,3 +48,5 @@ clean :
rm("src/resources/daisy-pipeline");
rm("node_modules/.dev-temp-build");
exec("$(MAKE)", "-C", "engine", "clean");


4 changes: 4 additions & 0 deletions buildtools/notarize.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ exports.default = async function notarizing(context) {
)
return
}
if (process.env.SKIP_NOTARIZATION) {
console.log('skipped notarizing: SKIP_NOTARIZATION=true')
return
}

const appName = context.packager.appInfo.productFilename

Expand Down
2 changes: 1 addition & 1 deletion engine
Submodule engine updated 1 files
+1 −1 .mvn/settings.xml
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"displayName": "DAISY Pipeline (2023)",
"name": "pipeline-ui",
"description": "User interface for the DAISY Pipeline",
"version": "1.1.0",
"version": "1.2.0-BETA",
"main": "./node_modules/.dev-temp-build/main.js",
"devTempBuildFolder": "./node_modules/.dev-temp-build",
"devServer": "http://localhost:4927",
Expand Down Expand Up @@ -46,7 +46,7 @@
"pipeline:refresh": "node ./bin/modules/prebuild/pipeline.js --refresh",
"nodemon:start": "nodemon --watch src/main --watch src/renderer/bridge --watch src/shared --ignore src/resources --ext \"*\" --exec yarn dev:main",
"predist": "yarn build",
"dist": "./node_modules/.bin/electron-builder",
"dist": "./node_modules/.bin/electron-builder --publish never",
"release": "electron-builder --publish always",
"clean": "rimraf dist",
"prepare": "husky install",
Expand Down
6 changes: 6 additions & 0 deletions src/main/data/apis/pipeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
jobXmlToJson,
scriptsXmlToJson,
scriptXmlToJson,
voicesToJson,
} from 'shared/parser/pipelineXmlConverter'
import {
Datatype,
Expand Down Expand Up @@ -122,4 +123,9 @@ export const pipelineAPI = {
(ws) => `${baseurl(ws)}/alive`,
(text) => aliveXmlToJson(text)
),
fetchVoices: () =>
createPipelineFetchFunction(
(ws) => `${baseurl(ws)}/voices`,
(text) => voicesToJson(text)
),
}
7 changes: 7 additions & 0 deletions src/main/data/middlewares/pipeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
removeJobs,
selectVisibleJobs,
setAlive,
setVoices,
} from 'shared/data/slices/pipeline'

import {
Expand All @@ -31,6 +32,7 @@ import {
PipelineStatus,
ResultFile,
Script,
Voice,
Webservice,
} from 'shared/types'

Expand Down Expand Up @@ -309,6 +311,11 @@ export function pipelineMiddleware({ getState, dispatch }) {
})
.then((datatypes) => {
dispatch(setDatatypes(datatypes))
return pipelineAPI.fetchVoices()(newWebservice)
})
.then((voices: Array<Voice>) => {
console.log('Voices', voices)
dispatch(setVoices(voices))
})
.catch((e) => {
error('useWebservice', e)
Expand Down
14 changes: 14 additions & 0 deletions src/main/data/middlewares/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { existsSync, readFileSync, writeFile } from 'fs'
import { resolve } from 'path'
import { ENVIRONMENT } from 'shared/constants'
import { save } from 'shared/data/slices/settings'
import { ttsConfigToXml } from 'shared/parser/pipelineXmlConverter/ttsConfigToXml'
import { ApplicationSettings } from 'shared/types'
import { RootState } from 'shared/types/store'
import { resolveUnpacked } from 'shared/utils'
Expand Down Expand Up @@ -45,6 +46,10 @@ export function readSettings() {
colorScheme: 'system',
appStateOnClosingMainWindow: undefined,
jobsStateOnClosingMainWindow: 'close',
ttsConfig: {
preferredVoices: [],
xmlFilepath: resolve(app.getPath('userData'), 'ttsConfig.xml'),
},
} as ApplicationSettings
try {
if (existsSync(settingsFile)) {
Expand All @@ -60,6 +65,10 @@ export function readSettings() {
...loaded?.localPipelineProps?.webservice,
},
},
ttsConfig: {
...settings.ttsConfig,
...loaded?.ttsConfig,
},
}
}
} catch (e) {
Expand Down Expand Up @@ -93,6 +102,11 @@ export function settingsMiddleware({ getState }) {
JSON.stringify(settings, null, 4),
() => {}
)
writeFile(
settings.ttsConfig.xmlFilepath,
ttsConfigToXml(settings.ttsConfig),
() => {}
)
break
default:
break
Expand Down
7 changes: 5 additions & 2 deletions src/renderer/components/Fields/FileOrFolderInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export function FileOrFolderInput({
initialValue = '',
makeSlotForErrors = true,
labelledBy = '',
enabled = true,
}: {
dialogProperties: string[] // electron dialog properties for open or save, depending on which one you're doing (see 'type')
elemId: string // ID for the control widget
Expand All @@ -33,6 +34,7 @@ export function FileOrFolderInput({
required?: boolean
makeSlotForErrors?: boolean // create a span for error messages; if false, it is assumed that this will appear elsewhere
labelledBy?: string // id of the label for this element, if present use aria-labelledby, if absent, assume the label will have an htmlFor on it
enabled?: boolean // should the control be given the 'grayedout' classname
}) {
// the value is stored internally as it can be set 2 ways
// and also broadcast via onChange so that a parent component can subscribe
Expand Down Expand Up @@ -111,14 +113,15 @@ export function FileOrFolderInput({
tabIndex={0}
className={`filename ${
userInteracted ? 'interacted' : ''
}`}
} ${enabled ? '' : 'grayedout'}`}
value={value ?? ''}
onChange={(e) => onTextInput(e)}
id={elemId}
required={required}
aria-labelledby={labelledBy ?? ''}
disabled={!enabled}
></input>
<button type="button" onClick={(e) => onClick(e, name)}>
<button type="button" onClick={(e) => onClick(e, name)} disabled={!enabled} className={enabled ? '' : 'grayedout'}>
{buttonLabel}
</button>
</div>
Expand Down
Loading

0 comments on commit 9400a26

Please sign in to comment.