Last active
March 4, 2020 13:47
-
-
Save mattintosh4/8b3df990c2a8977c8e6f821ddecd468d to your computer and use it in GitHub Desktop.
Wineloader for AI-Kiritan/NEUTRINO
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/ksh | |
set -e | |
set -u | |
#set -x | |
PS4=$'\e[32m>>>\e[m ' | |
while getopts b:e:f:m:n:p:h arg | |
do | |
case ${arg} in | |
b) | |
basename=${OPTARG} | |
;; | |
e) | |
xmlExtension=${OPTARG} | |
;; | |
f) | |
formantShift=${OPTARG} | |
;; | |
m) | |
modelDir=${OPTARG} | |
;; | |
n) | |
numThreads=${OPTARG} | |
;; | |
p) | |
pitchShift=${OPTARG} | |
;; | |
h) | |
1>&2 echo "\ | |
Usage: | |
Run.sh [options] | |
Options: | |
-b <string> ベース名を指定します (default: sample1) | |
-e <string> 楽譜ファイルの拡張子を指定します (default: musicxml) | |
-n <integer> スレッド数を指定します (default: 論理 CPU 数 - 1) | |
-m <string> モデルを指定します (default: KIRITAN) | |
-p <float> ピッチを指定します (default: 1.0) | |
-f <float> フォルマントを指定します (default: 1.0) | |
" | |
exit 0 | |
;; | |
esac | |
done | |
case ${WINE:+set} in | |
set) | |
;; | |
*) | |
set -- com.github.mattintosh4.easywine \ | |
org.winehq.wine-stable.wine \ | |
org.winehq.wine-devel.wine \ | |
org.winehq.wine-staging.wine | |
for bundleIdentifier | |
do | |
bundlePath=$(osascript -e $'use framework "AppKit"\non run argv\nPOSIX path of ((current application\'s NSWorkspace\'s sharedWorkspace()\'s URLForApplicationWithBundleIdentifier:(item 1 of argv)) as string)\nend run' -- ${bundleIdentifier}) | |
PATH=${bundlePath}Contents/Resources/wine/bin:/usr/bin:/bin/usr/sbin:/sbin | |
WINE=$(which wine64) || continue | |
break | |
done | |
;; | |
esac | |
"${WINE}" --version | |
neutrinoDIR=$(cd "$(dirname "${0}")" && pwd) | |
export WINEARCH=${WINEARCH:-win64} | |
export WINEDEBUG=${WINEDEBUG:--all} | |
export WINEPREFIX=${WINEPREFIX:-${neutrinoDIR}/wine} | |
set -x | |
basename=${basename:-sample1} | |
numThreads=${numThreads:-$((n = $(/usr/sbin/sysctl -n hw.logicalcpu), n > 1 ? n - 1 : n))} | |
xmlExtension=${xmlExtension:-musicxml} | |
modelDir=${modelDir:-KIRITAN} | |
pitchShift=${pitchShift:-1.0} | |
formantShift=${formantShift:-1.0} | |
cd "${neutrinoDIR}" | |
"${WINE}" bin/musicXMLtoLabel.exe \ | |
score/musicxml/"${basename}"."${xmlExtension}" \ | |
score/label/full/"${basename}".lab \ | |
score/label/mono/"${basename}".lab | |
# NEUTRINO - predict timing & acoustic features from label | |
# | |
# usage: | |
# NEUTRINO.exe full.lab timing.lab output.f0 output.mgc output.bap model_directory [option] | |
# options : description [default] | |
# -n i : number of parallel [MAX] | |
# -s : skip predict timing [off] | |
# -a : skip predict acoustic features [off] | |
# -t : view information [off] | |
"${WINE}" bin/NEUTRINO.exe \ | |
score/label/full/"${basename}".lab \ | |
score/label/timing/"${basename}".lab \ | |
output/"${basename}".f0 \ | |
output/"${basename}".mgc \ | |
output/"${basename}".bap \ | |
model/"${modelDir}"/ \ | |
-n ${numThreads} -t | |
# WORLD - synthesis from f0, mgc, bap | |
# | |
# usage: | |
# WORLD.exe Input.f0 Input.mgc Input.bap [option] | |
# options: | |
# -s i : sampling rate (Hz) [48000] | |
# -f f : pitch shift (positive number) [1.0] | |
# -m f : formant shift (positive number) [1.0] | |
# -n i : number of parallel [MAX] | |
# -s i : hi-speed synthesis [0] | |
# -o name : output wav filename [output.wav] | |
# -t : view information [off] | |
"${WINE}" bin/WORLD.exe \ | |
output/"${basename}".f0 \ | |
output/"${basename}".mgc \ | |
output/"${basename}".bap \ | |
-f ${pitchShift} \ | |
-m ${formantShift} \ | |
-o output/"${basename}"_syn.wav \ | |
-n ${numThreads} -t |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment