Compare commits
No commits in common. "master" and "v0.2.0" have entirely different histories.
|
@ -1,15 +0,0 @@
|
|||
# Config file for generic text editors.
|
||||
|
||||
root = true
|
||||
|
||||
[*]
|
||||
charset = utf-8
|
||||
end_of_line = lf
|
||||
indent_style = tab
|
||||
indent_size = 4
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespace = true
|
||||
|
||||
[*.{yml,yaml}]
|
||||
indent_style = space
|
||||
indent_size = 2
|
|
@ -1,5 +0,0 @@
|
|||
# Use Git LFS for binary files
|
||||
*.wav filter=lfs diff=lfs merge=lfs -text
|
||||
*.flac filter=lfs diff=lfs merge=lfs -text
|
||||
*.ogg filter=lfs diff=lfs merge=lfs -text
|
||||
*.mp3 filter=lfs diff=lfs merge=lfs -text
|
|
@ -1,87 +0,0 @@
|
|||
name: Build
|
||||
|
||||
on: push
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- description: Windows - Visual Studio
|
||||
os: windows-2019
|
||||
cmakeOptions: '-G "Visual Studio 16 2019" -A x64'
|
||||
publish: true
|
||||
- description: macOS - Xcode
|
||||
os: macos-13
|
||||
cmakeOptions: ""
|
||||
publish: true
|
||||
- description: Linux - GCC
|
||||
os: ubuntu-20.04
|
||||
cmakeOptions: "-D CMAKE_C_COMPILER=gcc-10 -D CMAKE_CXX_COMPILER=g++-10"
|
||||
publish: true
|
||||
- description: Linux - Clang
|
||||
os: ubuntu-20.04
|
||||
cmakeOptions: "-D CMAKE_C_COMPILER=clang-12 -D CMAKE_CXX_COMPILER=clang++-12"
|
||||
publish: false
|
||||
env:
|
||||
BOOST_ROOT: ${{ github.workspace }}/lib/boost
|
||||
BOOST_URL: https://sourceforge.net/projects/boost/files/boost/1.86.0/boost_1_86_0.tar.bz2/download
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
lfs: true
|
||||
- name: Restore Boost from cache
|
||||
uses: actions/cache@v4
|
||||
id: cache-boost
|
||||
with:
|
||||
path: ${{ env.BOOST_ROOT }}
|
||||
key: ${{ env.BOOST_URL }}
|
||||
- name: Download Boost
|
||||
if: steps.cache-boost.outputs.cache-hit != 'true'
|
||||
shell: bash
|
||||
run: |
|
||||
if [ "$RUNNER_OS" == "Windows" ]; then
|
||||
# use forward slashes only
|
||||
BOOST_ROOT=$(echo $BOOST_ROOT | sed 's/\\/\//g')
|
||||
fi
|
||||
mkdir -p $BOOST_ROOT
|
||||
curl --insecure -L $BOOST_URL | tar -xj --strip-components=1 -C $BOOST_ROOT
|
||||
- name: Build Rhubarb
|
||||
shell: bash
|
||||
run: |
|
||||
JAVA_HOME=$JAVA_HOME_11_X64
|
||||
mkdir build
|
||||
cd build
|
||||
cmake ${{ matrix.cmakeOptions }} ..
|
||||
cmake --build . --config Release --target package
|
||||
- name: Run tests
|
||||
shell: bash
|
||||
run: |
|
||||
if [ "$RUNNER_OS" == "Windows" ]; then
|
||||
./build/rhubarb/Release/runTests.exe
|
||||
else
|
||||
./build/rhubarb/runTests
|
||||
fi
|
||||
- name: Upload artifacts
|
||||
if: ${{ matrix.publish }}
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: ${{ matrix.description }}
|
||||
path: build/*.zip
|
||||
release:
|
||||
needs: build
|
||||
runs-on: ubuntu-latest
|
||||
if: startsWith(github.ref, 'refs/tags/v')
|
||||
steps:
|
||||
- name: Download artifacts
|
||||
uses: actions/download-artifact@v4
|
||||
- name: Create GitHub release draft
|
||||
uses: softprops/action-gh-release@v2
|
||||
with:
|
||||
draft: true
|
||||
files: "*.zip"
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
@ -1,3 +1,3 @@
|
|||
.vs/
|
||||
build/
|
||||
*.user
|
||||
/.idea
|
||||
/.vs
|
||||
/build
|
||||
|
|
181
CHANGELOG.md
|
@ -1,181 +0,0 @@
|
|||
# Version history
|
||||
|
||||
## Version 1.13.0
|
||||
|
||||
* **Improved** animation rules for "F" sound when using just the basic mouth shapes.
|
||||
|
||||
## Version 1.12.0
|
||||
|
||||
* **Added** support for skinning in Rhubarb for Spine ([issue #108](https://github.com/DanielSWolf/rhubarb-lip-sync/issues/108))
|
||||
|
||||
## Version 1.11.0
|
||||
|
||||
* **Added** support for more WAVE file features ([issue #101](https://github.com/DanielSWolf/rhubarb-lip-sync/issues/101))
|
||||
* **Changed** Rhubarb Lip Sync for Spine so that it works with any modern JRE ([issue #97](https://github.com/DanielSWolf/rhubarb-lip-sync/issues/97))
|
||||
* **Changed** Windows build from 32 bit to 64 bit ([issue #98](https://github.com/DanielSWolf/rhubarb-lip-sync/issues/98))
|
||||
|
||||
## Version 1.10.0
|
||||
|
||||
* **Added** switch data file exporter for Moho (formerly Anime Studio) and OpenToonz ([issue #69](https://github.com/DanielSWolf/rhubarb-lip-sync/issues/69))
|
||||
* **Added** support for Spine 3.8 beta ([issue #74](https://github.com/DanielSWolf/rhubarb-lip-sync/issues/74))
|
||||
* **Improved** animation rule for OW sound: animating it as E-F rather than F.
|
||||
|
||||
## Version 1.9.1
|
||||
|
||||
* **Fixed** segmentation fault on OS X ([issue #65](https://github.com/DanielSWolf/rhubarb-lip-sync/issues/65)).
|
||||
|
||||
## Version 1.9.0
|
||||
|
||||
* **Added** basic support for non-English recordings through phonetic recognition ([issue #45](https://github.com/DanielSWolf/rhubarb-lip-sync/issues/45)).
|
||||
* **Improved** processing speed for WAVE files ([issue #58](https://github.com/DanielSWolf/rhubarb-lip-sync/issues/58)).
|
||||
* **Fixed** a bug that resulted in unwanted mouth movement at beginning of a recording ([issue #53](https://github.com/DanielSWolf/rhubarb-lip-sync/issues/53)).
|
||||
* **Fixed** a bug that garbled special characters in the output file path ([issue #54](https://github.com/DanielSWolf/rhubarb-lip-sync/issues/54)).
|
||||
* **Fixed** a bug that prevented the progress bar from reaching 100% ([issue #48](https://github.com/DanielSWolf/rhubarb-lip-sync/issues/48)).
|
||||
* **Fixed** file paths in exported XML and JSON files ([issue #59](https://github.com/DanielSWolf/rhubarb-lip-sync/issues/59)).
|
||||
|
||||
## Version 1.8.0
|
||||
|
||||
* **Added** support for Ogg Vorbis (.ogg) file format ([issue #40](https://github.com/DanielSWolf/rhubarb-lip-sync/issues/40)).
|
||||
* **Fixed** build error with some versions of Boost ([issue #41](https://github.com/DanielSWolf/rhubarb-lip-sync/issues/41)).
|
||||
|
||||
## Version 1.7.2
|
||||
|
||||
* **Fixed** bug in Rhubarb for Spine where processing failed depending on the number of existing animations ([issue #34](https://github.com/DanielSWolf/rhubarb-lip-sync/issues/34#issuecomment-378198776)).
|
||||
|
||||
## Version 1.7.1
|
||||
|
||||
* **Added** more helpful error dialogs for internal errors in Rhubarb Lip Sync for Spine.
|
||||
* **Added**: Internal errors in Rhubarb Lip Sync for Spine are logged to the console (`stderr`).
|
||||
* **Fixed** generic error message in Rhubarb for Spine ([issue #34](https://github.com/DanielSWolf/rhubarb-lip-sync/issues/34)).
|
||||
|
||||
## Version 1.7.0
|
||||
|
||||
* **Added** integration with Spine animation software (Rhubarb Lip Sync for Spine).
|
||||
* **Added** full Unicode support: File names, dialog files, strings in exported files etc. should now be fully Unicode-compatible.
|
||||
* **Added** `--machineReadable` command-line option to allow for better integration with other applications.
|
||||
* **Added** `--consoleLevel` command-line option to control how much detail to log to the console (`stderr`).
|
||||
* **Changed** message output to the console: Unless specified using `--consoleLevel`, only errors and fatal errors are printed to the console. Previously, warnings were also printed.
|
||||
* **Fixed** segfault with WAVE file containing some initial music before spoken words ([issue #25](https://github.com/DanielSWolf/rhubarb-lip-sync/issues/25))
|
||||
|
||||
## Version 1.6.0
|
||||
|
||||
* **Added** a script for lip-syncing in Adobe After Effects.
|
||||
* **Added** `--output` command-line option.
|
||||
* **Changed** the official spelling of the project: Rhubarb Lip-Sync is now Rhubarb Lip Sync (without the hyphen).
|
||||
|
||||
## Version 1.5.0
|
||||
|
||||
* **Added** animation code optimizing animation for words containing "to".
|
||||
* **Improved** animation rules: better animation of ER and AW sounds.
|
||||
* **Fixed** compilation with Boost 1.56.0+ ([issue #9](https://github.com/DanielSWolf/rhubarb-lip-sync/issues/9)).
|
||||
|
||||
## Version 1.4.2
|
||||
|
||||
* **Fixed** incorrect animation before some pauses ([issue #7](https://github.com/DanielSWolf/rhubarb-lip-sync/issues/7)).
|
||||
|
||||
## Version 1.4.1
|
||||
|
||||
* **Fixed** crash with message "Time range start must not be less than end." ([issue #6](https://github.com/DanielSWolf/rhubarb-lip-sync/issues/6))
|
||||
|
||||
## Version 1.4.0
|
||||
|
||||
* **Added** animation code preventing long static segments.
|
||||
|
||||
Watch yourself in a mirror saying "He seized his keys." Your lips barely moved, right? That's exactly what would happen in previous versions of Rhubarb Lip Sync. Only worse: Because there is only one "clenched teeth" mouth shape, the mouth would stay completely static during phrases like this. Rhubarb Lip Sync 1.4.0 now does what [a professional animator would do](http://animateducated.blogspot.de/2016/10/lip-sync-animation-2.html?showComment=1478861729702#c2940729096183546458): It opens the mouth a bit wider for some syllables, keeping the lips moving. This may be cheating, but it looks much better!
|
||||
|
||||
* **Improved** animation rules to use wide-open mouth shape more often.
|
||||
|
||||
Previous versions used mouth shape D (the wide-open mouth) very sparingly. This release uses it more often, which makes the resulting animation more lively and interesting.
|
||||
|
||||
## Version 1.3.0
|
||||
|
||||
* **Improved** animation algorithm: Implemented new, bidirectional animation algorithm.
|
||||
|
||||
Since version 1.0.0, Rhubarb Lip Sync has used a predictive animation algorithm. That means that in many situations (usually before a vowel), the mouth *anticipates* the upcoming sound. It moves *ahead of time*, resulting in more natural animation.
|
||||
|
||||
For version 1.3.0, this core animation algorithm has been re-written from scratch. The new algorithm still anticipates the *next* vowel, but now also considers the *previous* vowel. The resulting animation is even closer to human speech.
|
||||
|
||||
* **Added** artistic timing.
|
||||
|
||||
Previous versions of Rhubarb Lip Sync have tried to reproduce the timing of the recording as precisely as possible. For rapid speech, this often resulted in jittery animation that didn't look good: It tried to fit too much information into the available time. Traditional animators have known this problem since the 1930s. Instead of slavishly following the timing of the recording, they focus on important sounds and mouth shapes, showing them earlier (and thus longer) than would be realistic. On the other hand, they often skip unimportant sounds and mouth shapes altogether.
|
||||
|
||||
Rhubarb Lip Sync 1.3.0 adds a new step in the animation pipeline that emulates this artistic approach. The resulting animation looks much cleaner and smoother. Ironically, it also looks more in-sync than the precise animation created by earlier versions.
|
||||
|
||||
* **Added** `--extendedShapes` command-line option.
|
||||
|
||||
Previous versions of Rhubarb Lip Sync used a fixed set of eight or nine mouth shapes for animation. If users wanted to use fewer mouth shapes, they had to modify the output, for instance by replacing every "X" shape with an "A". This version of Rhubarb Lip Sync introduces the `--extendedShapes` command-line option that allows the user to specify which mouth shapes should be used. This is not only more convenient; knowing which mouth shapes are actually available also allows Rhubarb Lip Sync to create better animation.
|
||||
|
||||
* **Added** `--quiet` mode.
|
||||
|
||||
A "quiet" mode has been added. In that mode, Rhubarb Lip Sync doesn't create any output except for animation data and error messages. This is helpful when using Rhubarb Lip Sync as part of an automated process.
|
||||
|
||||
* **Improved** animation rules and tweening for better animation.
|
||||
|
||||
Animation rules define which mouth shapes can be used to represent a specific sound. For this release, there have been many tweaks to the animation rules, making some sounds look much more convincing. In addition, the rules for inbetweens ("tweening") have been improved. As in traditional animation, the mouth now "pops" open without inbetweens, then closes smoothly.
|
||||
|
||||
* **Improved** pause animations.
|
||||
|
||||
Pauses in speech are tricky to animate. Early version of Rhubarb Lip Sync always closed the mouth, which looks strange for very short pauses. Later versions kept the mouth open for short pauses, which can also look weird if the first mouth shape *after* the pause is identical to the mouth shape *during* the pause: It looks as if somebody just forgot to animate that part.
|
||||
|
||||
This version of Rhubarb Lip Sync uses three different strategies for animating pauses, depending on the duration of the pause and the mouth shapes before and after it.
|
||||
|
||||
* **Fixed** bugs in the grapheme-to-phoneme algorithm.
|
||||
|
||||
Rhubarb Lip Sync comes with a huge dictionary containing pronunciations for more than 100,000 English words. If the dialog text contains words not found in this dictionary, Rhubarb Lip Sync will try to guess the correct pronunciation. I've fixed several bugs in the G2P algorithm that does this. As a result, using the `--dialogFile` option now results in even better animation.
|
||||
|
||||
## Version 1.2.0
|
||||
|
||||
* **Improved** dialog handling to allow for incorrect input dialog.
|
||||
|
||||
Since version 1.0.0, Rhubarb Lip Sync can handle situations where the dialog text is specified (using the `-dialogFile` option), but the actual recording omits some words. For instance, the specified dialog text can be "That's all gobbledygook to me," but the recording only says "That's gobbledygook to me," dropping the word "all."
|
||||
|
||||
Until now, however, Rhubarb Lip Sync couldn't handle *changed* or *inserted* words, such as a recording saying "That's *just* gobbledygook to me." This restriction has been removed. As of version 1.2.0, the actual recording may freely deviate from the specified dialog text. Rhubarb Lip Sync will ignore the dialog file where it audibly differs from the recording, and benefit from it where it matches.
|
||||
|
||||
## Version 1.1.0
|
||||
|
||||
* **Improved** speech recognition to be more reliable.
|
||||
|
||||
The first step in automatic lip sync is speech recognition.
|
||||
Rhubarb Lip Sync 1.1.0 recognizes spoken dialog more accurately, especially at the beginning of recordings.
|
||||
This improves the overall quality of the resulting animation.
|
||||
|
||||
* **Improved** breath detection to be more accurate.
|
||||
|
||||
Rhubarb Lip Sync animates not only dialog, but also noises such as taking a breath.
|
||||
For this version, the accuracy of breath detection has been improved.
|
||||
You shouldn't see actors opening their mouth for no reason any more.
|
||||
|
||||
* **Improved** animation of short pauses.
|
||||
|
||||
During short pauses between words or sentences (up to 0.35s), the mouth is kept open.
|
||||
Now, this open mouth shape is chosen based on the previous and following mouth shapes.
|
||||
This gives pauses in speech a more natural, less mechanical look.
|
||||
|
||||
* **Added** capability to build on Linux
|
||||
|
||||
In addition to Windows and OS X, Rhubarb Lip Sync can now be built on Linux systems.
|
||||
I'm not offering binary distributions for Linux at this time.
|
||||
To build the application yourself, you need CMake, Boost, and a C++14-compatible compiler.
|
||||
|
||||
## Version 1.0.0
|
||||
|
||||
* **Improved** animation algorithm: More realistic animation using new, predictive algorithm.
|
||||
* **Added** tweening for smoother animation.
|
||||
* **Added** support for non-dialog noises (breathing, smacking, etc.)
|
||||
* **Improved** processing speed substantially through multithreading.
|
||||
* **Improved** reliability of voice recognition.
|
||||
* **Added** support for long recordings (I've tested a 30-minute file).
|
||||
* **Added** capability to handle recording that deviate from the specified dialog text.
|
||||
* **Added** capability to handle unknown words as well as numbers, abbreviations, etc. in the specified dialog text.
|
||||
|
||||
## Version 0.2.0
|
||||
|
||||
* **Added** multiple output formats: TSV, XML, JSON.
|
||||
* **Added** experimental option to supply dialog text.
|
||||
* **Improved** error handling and error messages.
|
||||
|
||||
## Version 0.1.0
|
||||
|
||||
* **Added** two-pass phone detection using [CMU PocketSphinx](http://cmusphinx.sourceforge.net/).
|
||||
* **Added** fixed set of eight mouth shapes, based on the Hanna-Barbera shapes.
|
||||
* **Added** naive (but well-tuned) mapping from phones to mouth shapes.
|
171
CMakeLists.txt
|
@ -1,41 +1,166 @@
|
|||
cmake_minimum_required(VERSION 3.24)
|
||||
cmake_minimum_required(VERSION 3.3)
|
||||
|
||||
include(appInfo.cmake)
|
||||
# Support legacy OS X versions
|
||||
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.7" CACHE STRING "Minimum OS X deployment version")
|
||||
|
||||
set(appName "Rhubarb Lip Sync")
|
||||
set(appVersionMajor 0)
|
||||
set(appVersionMinor 2)
|
||||
set(appVersionPatch 0)
|
||||
set(appVersionSuffix "")
|
||||
set(appVersion "${appVersionMajor}.${appVersionMinor}.${appVersionPatch}${appVersionSuffix}")
|
||||
|
||||
project(${appName})
|
||||
|
||||
# Build and install main executable
|
||||
add_subdirectory(rhubarb)
|
||||
# Enable C++14
|
||||
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
|
||||
endif()
|
||||
|
||||
# Build and install extras
|
||||
add_subdirectory("extras/AdobeAfterEffects")
|
||||
add_subdirectory("extras/MagixVegas")
|
||||
add_subdirectory("extras/EsotericSoftwareSpine")
|
||||
# Make sure Xcode uses libc++ instead of libstdc++, allowing us to use the C++14 standard library prior to OS X 10.9
|
||||
if("${CMAKE_GENERATOR}" STREQUAL "Xcode")
|
||||
add_compile_options(-stdlib=libc++)
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -stdlib=libc++")
|
||||
endif()
|
||||
|
||||
# Install misc. files
|
||||
install(
|
||||
FILES README.adoc LICENSE.md CHANGELOG.md
|
||||
DESTINATION .
|
||||
# Use static run-time
|
||||
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
|
||||
add_compile_options(/MT$<$<CONFIG:Debug>:d>)
|
||||
endif()
|
||||
|
||||
# Set global flags and define flags variables for later use
|
||||
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
||||
set(enableWarningsFlags "-Wall;-Wextra")
|
||||
set(disableWarningsFlags "-w")
|
||||
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
|
||||
set(enableWarningsFlags "/W4")
|
||||
set(disableWarningsFlags "/W0")
|
||||
|
||||
# Disable warning C4456: declaration of '...' hides previous local declaration
|
||||
# I'm doing that on purpose.
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4458")
|
||||
endif()
|
||||
|
||||
# Enable project folders
|
||||
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
|
||||
|
||||
# Define libraries
|
||||
|
||||
# ... Boost
|
||||
set(Boost_USE_STATIC_LIBS ON) # Use static libs
|
||||
set(Boost_USE_MULTITHREADED ON) # Enable multithreading support
|
||||
set(Boost_USE_STATIC_RUNTIME ON) # Use static C++ runtime
|
||||
find_package(Boost REQUIRED COMPONENTS filesystem locale system)
|
||||
include_directories(SYSTEM ${Boost_INCLUDE_DIRS})
|
||||
|
||||
# ... C++ Format
|
||||
include_directories(SYSTEM "lib/cppformat")
|
||||
FILE(GLOB cppFormatFiles "lib/cppformat/*.cc")
|
||||
add_library(cppFormat ${cppFormatFiles})
|
||||
target_compile_options(cppFormat PRIVATE ${disableWarningsFlags})
|
||||
set_target_properties(cppFormat PROPERTIES FOLDER lib)
|
||||
|
||||
# ... sphinxbase
|
||||
include_directories(SYSTEM "lib/sphinxbase-5prealpha-2015-08-05/include")
|
||||
FILE(GLOB_RECURSE sphinxbaseFiles "lib/sphinxbase-5prealpha-2015-08-05/src/libsphinxbase/*.c")
|
||||
add_library(sphinxbase ${sphinxbaseFiles})
|
||||
target_compile_options(sphinxbase PRIVATE ${disableWarningsFlags})
|
||||
set_target_properties(sphinxbase PROPERTIES FOLDER lib)
|
||||
|
||||
# ... PocketSphinx
|
||||
include_directories(SYSTEM "lib/pocketsphinx-5prealpha-2015-08-05/include" "lib/pocketsphinx-5prealpha-2015-08-05/src/libpocketsphinx")
|
||||
FILE(GLOB pocketSphinxFiles "lib/pocketsphinx-5prealpha-2015-08-05/src/libpocketsphinx/*.c")
|
||||
add_library(pocketSphinx ${pocketSphinxFiles})
|
||||
target_link_libraries(pocketSphinx sphinxbase)
|
||||
target_compile_options(pocketSphinx PRIVATE ${disableWarningsFlags})
|
||||
set_target_properties(pocketSphinx PROPERTIES FOLDER lib)
|
||||
|
||||
# ... TCLAP
|
||||
include_directories(SYSTEM "lib/tclap-1.2.1/include")
|
||||
|
||||
# ... Google Test
|
||||
add_subdirectory("lib/googletest")
|
||||
set_target_properties(gmock PROPERTIES FOLDER lib)
|
||||
set_target_properties(gmock_main PROPERTIES FOLDER lib)
|
||||
set_target_properties(gtest PROPERTIES FOLDER lib)
|
||||
set_target_properties(gtest_main PROPERTIES FOLDER lib)
|
||||
|
||||
# ... GSL
|
||||
include_directories(SYSTEM "lib/gsl/include")
|
||||
|
||||
# Define executable
|
||||
include_directories("src" "src/audio_input")
|
||||
configure_file(src/appInfo.cpp.in src/appInfo.cpp ESCAPE_QUOTES)
|
||||
set(SOURCE_FILES
|
||||
${CMAKE_CURRENT_BINARY_DIR}/src/appInfo.cpp
|
||||
src/main.cpp
|
||||
src/Phone.cpp src/Phone.h
|
||||
src/Shape.cpp src/Shape.h
|
||||
src/centiseconds.cpp src/centiseconds.h
|
||||
src/EnumConverter.h
|
||||
src/mouthAnimation.cpp src/mouthAnimation.h
|
||||
src/phoneExtraction.cpp src/phoneExtraction.h
|
||||
src/platformTools.cpp src/platformTools.h
|
||||
src/tools.cpp src/tools.h
|
||||
src/audio/AudioStream.cpp src/audio/AudioStream.h
|
||||
src/audio/DCOffset.cpp src/audio/DCOffset.h
|
||||
src/audio/SampleRateConverter.cpp src/audio/SampleRateConverter.h
|
||||
src/audio/UnboundedStream.cpp src/audio/UnboundedStream.h
|
||||
src/audio/voiceActivityDetection.cpp src/audio/voiceActivityDetection.h
|
||||
src/audio/WaveFileReader.cpp src/audio/WaveFileReader.h
|
||||
src/audio/waveFileWriting.cpp src/audio/waveFileWriting.h
|
||||
src/stringTools.cpp src/stringTools.h
|
||||
src/NiceCmdLineOutput.cpp src/NiceCmdLineOutput.h
|
||||
src/TablePrinter.cpp src/TablePrinter.h
|
||||
src/ProgressBar.cpp src/ProgressBar.h
|
||||
src/logging.cpp src/logging.h
|
||||
src/Timed.h
|
||||
src/TimeRange.cpp src/TimeRange.h
|
||||
src/Timeline.h
|
||||
src/Exporter.cpp src/Exporter.h
|
||||
)
|
||||
add_executable(rhubarb ${SOURCE_FILES})
|
||||
target_link_libraries(rhubarb ${Boost_LIBRARIES} cppFormat sphinxbase pocketSphinx)
|
||||
target_compile_options(rhubarb PUBLIC ${enableWarningsFlags})
|
||||
|
||||
# Configure CPack
|
||||
function(get_short_system_name variable)
|
||||
if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
|
||||
set(${variable} "macOS" PARENT_SCOPE)
|
||||
else()
|
||||
set(${variable} "${CMAKE_SYSTEM_NAME}" PARENT_SCOPE)
|
||||
endif()
|
||||
endfunction()
|
||||
# Define test project
|
||||
#include_directories("${gtest_SOURCE_DIR}/include")
|
||||
set(TEST_FILES
|
||||
tests/stringToolsTests.cpp
|
||||
tests/TimelineTests.cpp
|
||||
src/stringTools.cpp src/stringTools.h
|
||||
src/Timeline.h
|
||||
src/TimeRange.cpp src/TimeRange.h
|
||||
src/centiseconds.cpp src/centiseconds.h
|
||||
)
|
||||
add_executable(runTests ${TEST_FILES})
|
||||
target_link_libraries(runTests gtest gmock gmock_main)
|
||||
|
||||
set(CPACK_PACKAGE_NAME ${appName})
|
||||
string(REPLACE " " "-" CPACK_PACKAGE_NAME "${CPACK_PACKAGE_NAME}")
|
||||
get_short_system_name(CPACK_SYSTEM_NAME)
|
||||
if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
|
||||
set(CPACK_SYSTEM_NAME "OSX")
|
||||
endif()
|
||||
set(CPACK_PACKAGE_VERSION_MAJOR ${appVersionMajor})
|
||||
set(CPACK_PACKAGE_VERSION_MINOR ${appVersionMinor})
|
||||
set(CPACK_PACKAGE_VERSION_PATCH ${appVersionPatch})
|
||||
set(CPACK_PACKAGE_VERSION ${appVersion})
|
||||
set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${CPACK_SYSTEM_NAME}")
|
||||
set(CPACK_GENERATOR ZIP)
|
||||
|
||||
# Run CPack
|
||||
# Copy resource files at build time; install them at package time
|
||||
include(tools.cmake)
|
||||
set(modelDir "${CMAKE_SOURCE_DIR}/lib/pocketsphinx-5prealpha-2015-08-05/model")
|
||||
copy_and_install("${modelDir}/en-us/*" "res/sphinx")
|
||||
copy_and_install("${modelDir}/en-us/en-us/*" "res/sphinx/acoustic-model")
|
||||
|
||||
install(
|
||||
TARGETS rhubarb
|
||||
RUNTIME
|
||||
DESTINATION .
|
||||
)
|
||||
install(
|
||||
FILES README.md LICENSE.md VERSION.md
|
||||
DESTINATION .
|
||||
)
|
||||
|
||||
include(CPack)
|
||||
|
|
246
LICENSE.md
|
@ -2,16 +2,18 @@
|
|||
|
||||
## Summary
|
||||
|
||||
This summary is not legally binding. The actual license terms are defined by the license texts below.
|
||||
This summary is only meant to give you a quick overview. It is not legally binding. The actual license terms are defined by the quoted license texts below.
|
||||
|
||||
* Rhubarb Lip Sync is released under the MIT license. All its third-party dependencies (libraries, resources, etc.) are released under the MIT license, a BSD license, or a similar permissive license. This means that you can use Rhubarb Lip Sync in almost any way you want, including the creation of commercial software based on it.
|
||||
* When you run Rhubarb Lip Sync on an audio file, the resulting lip sync data belongs to you alone. This means that if you use Rhubarb Lip Sync in the production process of a video game, an animated cartoon, or a similar product *that doesn't ship with lip sync functionality*, you don't even have to care about the MIT license.
|
||||
* Rhubarb Lip Sync and all of its components (libraries, resources, etc.) are under the MIT license or a similar permissive license. This means that you can use Rhubarb Lip Sync in almost any way you want. You may even create commercial software based on it.
|
||||
* When you run Rhubarb Lip Sync on an audio file, the resulting lip-sync data belongs to you alone. This means that if you use Rhubarb Lip Sync in the production process of a video game, an animated cartoon, or a similar product *that doesn't ship with lip-sync functionality*, you don't even have to care about the MIT license.
|
||||
|
||||
## Rhubarb Lip Sync
|
||||
## Individual Licenses
|
||||
|
||||
[Rhubarb Lip Sync](https://github.com/DanielSWolf/rhubarb-lip-sync) is released under the **MIT License (MIT)**.
|
||||
### Rhubarb Lip Sync
|
||||
|
||||
> Copyright (c) 2015-2016 Daniel Wolf
|
||||
All parts of [Rhubarb Lip Sync](https://github.com/DanielSWolf/rhubarb-lip-sync) that are not listed with their own license below are released under the **MIT License (MIT)**.
|
||||
|
||||
> Copyright (c) 2015 Daniel Wolf
|
||||
>
|
||||
> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
>
|
||||
|
@ -19,9 +21,7 @@ This summary is not legally binding. The actual license terms are defined by the
|
|||
>
|
||||
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
## Third-party dependencies
|
||||
|
||||
### `[boost]` Boost
|
||||
### Boost
|
||||
|
||||
The [Boost](http://www.boost.org/) libraries are released under the **Boost Software License**.
|
||||
|
||||
|
@ -33,20 +33,7 @@ The [Boost](http://www.boost.org/) libraries are released under the **Boost Soft
|
|||
>
|
||||
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
### `[cmusphinx-en-us]` CMU Sphinx US English acoustic model
|
||||
|
||||
The [CMU Sphinx US English acoustic model](https://sourceforge.net/projects/cmusphinx/files/Acoustic%20and%20Language%20Models/US%20English/) is released under a variation of the **2-clause BSD License**.
|
||||
|
||||
> Copyright (c) 2015 Alpha Cephei Inc. All rights reserved.
|
||||
>
|
||||
> Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
>
|
||||
> 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
> 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
>
|
||||
> THIS SOFTWARE IS PROVIDED BY ALPHA CEPHEI INC. ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ALPHA CEPHEI INC. NOR ITS EMPLOYEES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
### `[cppformat]` C++ Format
|
||||
### C++ Format
|
||||
|
||||
The [C++ Format](https://github.com/cppformat/cppformat) library is released under the **2-clause BSD License**.
|
||||
|
||||
|
@ -61,84 +48,7 @@ The [C++ Format](https://github.com/cppformat/cppformat) library is released und
|
|||
>
|
||||
> THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
### `[flite]` Flite
|
||||
|
||||
The [CMU Flite](http://www.festvox.org/flite/) engine is released under a **BSD**-like license. For details see the license file in the Flite directory.
|
||||
|
||||
> Language Technologies Institute
|
||||
> Carnegie Mellon University
|
||||
> Copyright (c) 1999-2008
|
||||
> All Rights Reserved.
|
||||
>
|
||||
> Permission is hereby granted, free of charge, to use and distribute this software and its documentation without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of this work, and to permit persons to whom this work is furnished to do so, subject to the following conditions:
|
||||
>
|
||||
> 1. The code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
> 2. Any modifications must be clearly marked as such.
|
||||
> 3. Original authors' names are not deleted.
|
||||
> 4. The authors' names are not used to endorse or promote products derived from this software without specific prior written permission.
|
||||
>
|
||||
> CARNEGIE MELLON UNIVERSITY AND THE CONTRIBUTORS TO THIS WORK DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY NOR THE CONTRIBUTORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
### `[gsl]` Guidelines Support Library
|
||||
|
||||
The [Guidelines Support Library](https://github.com/Microsoft/GSL) is released under the **MIT License (MIT)**.
|
||||
|
||||
> Copyright (c) 2015 Microsoft Corporation. All rights reserved.
|
||||
>
|
||||
> This code is licensed under the MIT License (MIT).
|
||||
>
|
||||
> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
>
|
||||
> The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
>
|
||||
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
### `[ogg]` libogg
|
||||
|
||||
libogg is released under the **3-clause BSD license**.
|
||||
|
||||
> Copyright (c) 2002, Xiph.org Foundation
|
||||
>
|
||||
> Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
>
|
||||
> - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
>
|
||||
> - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
>
|
||||
> - Neither the name of the Xiph.org Foundation nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
||||
>
|
||||
> THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
### `[pocketsphinx]` PocketSphinx
|
||||
|
||||
The [PocketSphinx](https://github.com/cmusphinx/pocketsphinx) library is released under a variation of the **2-clause BSD License**.
|
||||
|
||||
> Copyright (c) 1999-2015 Carnegie Mellon University. All rights reserved.
|
||||
>
|
||||
> Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
>
|
||||
> 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
> 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
>
|
||||
> This work was supported in part by funding from the Defense Advanced Research Projects Agency and the National Science Foundation of the United States of America, and the CMU Sphinx Speech Consortium.
|
||||
>
|
||||
> THIS SOFTWARE IS PROVIDED BY CARNEGIE MELLON UNIVERSITY ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY NOR ITS EMPLOYEES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
### `[soundchange]` Sound Change Applier
|
||||
|
||||
The [Sound Change Applier](http://www.zompist.com/sounds.htm) and its [rule set for American English](http://www.zompist.com/spell.html) are released under the **MIT License (MIT)**.
|
||||
|
||||
> **The MIT License (MIT)**
|
||||
>
|
||||
> Copyright (c) 2000 Mark Rosenfelder
|
||||
>
|
||||
> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
>
|
||||
> The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
>
|
||||
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
### `[sphinxbase]` CMU Sphinx common libraries
|
||||
### CMU Sphinx common libraries (sphinxbase)
|
||||
|
||||
The [sphinxbase](https://github.com/cmusphinx/sphinxbase) library is released under a variation of the **2-clause BSD License**.
|
||||
|
||||
|
@ -153,7 +63,35 @@ The [sphinxbase](https://github.com/cmusphinx/sphinxbase) library is released un
|
|||
>
|
||||
> THIS SOFTWARE IS PROVIDED BY CARNEGIE MELLON UNIVERSITY ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY NOR ITS EMPLOYEES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
### `[tclap]` Templatized C++ Command Line Parser Library
|
||||
### PocketSphinx
|
||||
|
||||
The [PocketSphinx](https://github.com/cmusphinx/pocketsphinx) library is released under a variation of the **2-clause BSD License**.
|
||||
|
||||
> Copyright (c) 1999-2015 Carnegie Mellon University. All rights reserved.
|
||||
>
|
||||
> Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
>
|
||||
> 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
> 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
>
|
||||
> This work was supported in part by funding from the Defense Advanced Research Projects Agency and the National Science Foundation of the United States of America, and the CMU Sphinx Speech Consortium.
|
||||
>
|
||||
> THIS SOFTWARE IS PROVIDED BY CARNEGIE MELLON UNIVERSITY ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY NOR ITS EMPLOYEES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
### US english acoustic model
|
||||
|
||||
The US english acoustic model that is distributed along with the [PocketSphinx](https://github.com/cmusphinx/pocketsphinx) library is released under a variation of the **2-clause BSD License**.
|
||||
|
||||
> Copyright (c) 2015 Alpha Cephei Inc. All rights reserved.
|
||||
>
|
||||
> Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
>
|
||||
> 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
> 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
>
|
||||
> THIS SOFTWARE IS PROVIDED BY ALPHA CEPHEI INC. ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ALPHA CEPHEI INC. NOR ITS EMPLOYEES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
### Templatized C++ Command Line Parser Library (TCLAP)
|
||||
|
||||
The [TCLAP](http://tclap.sourceforge.net/) library is released under the **MIT License (MIT)**.
|
||||
|
||||
|
@ -165,108 +103,32 @@ The [TCLAP](http://tclap.sourceforge.net/) library is released under the **MIT L
|
|||
>
|
||||
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
### `[utfcpp]` UTF8-CPP
|
||||
### Google Test
|
||||
|
||||
The [UTF8-CPP](https://github.com/nemtrif/utfcpp) library is released under the **Boost Software License**.
|
||||
The [Google Test](https://github.com/google/googletest) framework is released under the **3-clause BSD License**.
|
||||
|
||||
> Copyright 2006 Nemanja Trifunovic
|
||||
>
|
||||
>Permission is hereby granted, free of charge, to any person or organization obtaining a copy of the software and accompanying documentation covered by this license (the "Software") to use, reproduce, display, distribute, execute, and transmit the Software, and to prepare derivative works of the Software, and to permit third-parties to whom the Software is furnished to do so, all subject to the following:
|
||||
>
|
||||
> The copyright notices in the Software and this entire statement, including the above license grant, this restriction and the following disclaimer, must be included in all copies of the Software, in whole or in part, and all derivative works of the Software, unless such copies or derivative works are solely in the form of machine-executable object code generated by a source language processor.
|
||||
>
|
||||
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
### `[utf8proc]` utf8proc
|
||||
|
||||
The [utf8proc](https://github.com/JuliaLang/utf8proc) library is released under the **MIT License (MIT)**, while some of its data is released under the **UNICODE License**.
|
||||
|
||||
#### utf8proc license
|
||||
|
||||
> **utf8proc** is a software package originally developed by Jan Behrens and the rest of the Public Software Group, who deserve nearly all of the credit for this library, that is now maintained by the Julia-language developers. Like the original utf8proc, whose copyright and license statements are reproduced below, all new work on the utf8proc library is licensed under the [MIT "expat" license](http://opensource.org/licenses/MIT):
|
||||
>
|
||||
> *Copyright © 2014-2015 by Steven G. Johnson, Jiahao Chen, Tony Kelman, Jonas Fonseca, and other contributors listed in the git history.*
|
||||
>
|
||||
> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
>
|
||||
> The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
>
|
||||
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
#### Original utf8proc license
|
||||
|
||||
> *Copyright (c) 2009, 2013 Public Software Group e. V., Berlin, Germany*
|
||||
>
|
||||
> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
>
|
||||
> The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
>
|
||||
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
#### Unicode data license
|
||||
|
||||
> This software distribution contains derived data from a modified version of the Unicode data files. The following license applies to that data:
|
||||
>
|
||||
> **COPYRIGHT AND PERMISSION NOTICE**
|
||||
>
|
||||
> *Copyright (c) 1991-2007 Unicode, Inc. All rights reserved. Distributed under the Terms of Use in http://www.unicode.org/copyright.html.*
|
||||
>
|
||||
> Permission is hereby granted, free of charge, to any person obtaining a copy of the Unicode data files and any associated documentation (the "Data Files") or Unicode software and any associated documentation (the "Software") to deal in the Data Files or Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, and/or sell copies of the Data Files or Software, and to permit persons to whom the Data Files or Software are furnished to do so, provided that (a) the above copyright notice(s) and this permission notice appear with all copies of the Data Files or Software, (b) both the above copyright notice(s) and this permission notice appear in associated documentation, and (c) there is clear notice in each modified Data File or in the Software as well as in the documentation associated with the Data File(s) or Software that the data or software has been modified.
|
||||
>
|
||||
> THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THE DATA FILES OR SOFTWARE.
|
||||
>
|
||||
> Except as contained in this notice, the name of a copyright holder shall not be used in advertising or otherwise to promote the sale, use or other dealings in these Data Files or Software without prior written authorization of the copyright holder.
|
||||
>
|
||||
> Unicode and the Unicode logo are trademarks of Unicode, Inc., and may be registered in some jurisdictions. All other trademarks and registered trademarks mentioned herein are the property of their respective owners.
|
||||
|
||||
### `[vorbis]` libvorbis
|
||||
|
||||
libvorbis is released under the **3-clause BSD license**.
|
||||
|
||||
> Copyright (c) 2002-2018 Xiph.org Foundation
|
||||
> Copyright 2008, Google Inc.
|
||||
> All rights reserved.
|
||||
>
|
||||
> Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
>
|
||||
> - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
>
|
||||
> - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
>
|
||||
> - Neither the name of the Xiph.org Foundation nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
||||
>
|
||||
> THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
### `[webrtc]` WebRTC
|
||||
|
||||
The [WebRTC](https://chromium.googlesource.com/external/webrtc) library is released under the **3-clause BSD License**.
|
||||
|
||||
> Copyright (c) 2011, The WebRTC project authors. All rights reserved.
|
||||
>
|
||||
> Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
>
|
||||
> * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
>* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
> * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
> * Neither the name of Google nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
||||
> * Neither the name of Google Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
||||
>
|
||||
> THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
> THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
### `[whereami]` Where Am I?
|
||||
### Guidelines Support Library (GSL)
|
||||
|
||||
The [Where Am I?](https://github.com/gpakosz/whereami) library is released under the **DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE**.
|
||||
The [Guidelines Support Library](https://github.com/Microsoft/GSL) is released under the **MIT License (MIT)**.
|
||||
|
||||
> DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
||||
> Version 2, December 2004
|
||||
> Copyright (c) 2015 Microsoft Corporation. All rights reserved.
|
||||
>
|
||||
> Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
|
||||
> This code is licensed under the MIT License (MIT).
|
||||
>
|
||||
> Everyone is permitted to copy and distribute verbatim or modified copies of this license document, and changing it is allowed as long as the name is changed.
|
||||
> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
>
|
||||
> DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
> The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
>
|
||||
> 0. You just DO WHAT THE FUCK YOU WANT TO.
|
||||
> 1. Bla bla bla
|
||||
> 2. Montesqieu et camembert, vive la France, zut alors!
|
||||
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
>
|
||||
> WTFPLv2 is very permissive, see http://www.wtfpl.net/faq/
|
||||
>
|
||||
> However, if this WTFPLV2 is REALLY a blocker and is the reason you can't use this project, contact me and I'll dual license it.
|
||||
|
||||
|
|
408
README.adoc
|
@ -1,408 +0,0 @@
|
|||
= Rhubarb Lip Sync
|
||||
:toc:
|
||||
:icons: font
|
||||
|
||||
:A: Ⓐ
|
||||
:B: Ⓑ
|
||||
:C: Ⓒ
|
||||
:D: Ⓓ
|
||||
:E: Ⓔ
|
||||
:F: Ⓕ
|
||||
:G: Ⓖ
|
||||
:H: Ⓗ
|
||||
:X: Ⓧ
|
||||
|
||||
image:https://img.shields.io/twitter/follow/RhubarbLipSync.svg?style=social&label=Follow["Twitter", link="https://twitter.com/RhubarbLipSync"]
|
||||
image:https://github.com/DanielSWolf/rhubarb-lip-sync/actions/workflows/ci.yml/badge.svg["Build status", link="https://github.com/DanielSWolf/rhubarb-lip-sync/actions/workflows/ci.yml"]
|
||||
|
||||
---
|
||||
|
||||
image:img/logo.png[align="center"]
|
||||
|
||||
---
|
||||
|
||||
Rhubarb Lip Sync allows you to quickly create 2D mouth animation from voice recordings. It analyzes your audio files, recognizes what is being said, then automatically generates lip sync information. You can use it for animating speech in computer games, animated cartoons, or any similar project.
|
||||
|
||||
Rhubarb Lip Sync integrates with the following applications:
|
||||
|
||||
* *Adobe After Effects* (see <<afterEffects,below>>)
|
||||
* *Moho* and *OpenToonz* (see <<moho,below>>)
|
||||
* *Spine* by Esoteric Software (see <<spine,below>>)
|
||||
* *Vegas Pro* by Magix (see <<vegas,below>>)
|
||||
* *Visionaire Studio* (see https://www.visionaire-studio.net/forum/thread/mouth-animation-using-rhubarb-lip-sync[external link])
|
||||
|
||||
In addition, you can use Rhubarb Lip Sync's command line interface (*CLI*) to generate files in various <<outputFormats,output formats>> (<<tsv,TSV>>/<<xml,XML>>/<<json,JSON>>).
|
||||
|
||||
== Demo video
|
||||
|
||||
Click the image for a demo video.
|
||||
|
||||
https://www.youtube.com/watch?v=zzdPSFJRlEo[image:http://img.youtube.com/vi/zzdPSFJRlEo/0.jpg[]]
|
||||
|
||||
== Integrations
|
||||
|
||||
[[afterEffects]]
|
||||
=== Adobe After Effects
|
||||
|
||||
You can use Rhubarb Lip Sync to animate dialog right from Adobe After Effects. For more information, <<extras/AdobeAfterEffects/README.adoc#,follow this link>> or see the directory `extras/AdobeAfterEffects`.
|
||||
|
||||
image:img/after-effects.png[]
|
||||
|
||||
[[moho]]
|
||||
=== Moho and OpenToonz
|
||||
|
||||
Rhubarb Lip Sync can create .dat switch data files, which are understood by Moho and OpenToonz. You can set the frame rate using the `--datFrameRate` option; to control the shape names, use the `--datUsePrestonBlair` flag. For more details, see <<options>>.
|
||||
|
||||
image:img/moho.png[]
|
||||
|
||||
[[spine]]
|
||||
=== Spine by Esoteric Software
|
||||
|
||||
Rhubarb Lip Sync for Spine is a graphical tool that allows you to import a Spine project, perform automatic lip sync, then re-import the result into Spine. For more information, <<extras/EsotericSoftwareSpine/README.adoc#,follow this link>> or see the directory `extras/EsotericSoftwareSpine` of the download.
|
||||
|
||||
image:img/spine.png[]
|
||||
|
||||
[[vegas]]
|
||||
=== Vegas Pro by Magix
|
||||
|
||||
Rhubarb Lip Sync also comes with two plugin scripts for Vegas Pro (previously Sony Vegas). For more information, <<extras/MagixVegas/README.adoc#,follow this link>> or see the directory `extras/MagixVegas` of the download.
|
||||
|
||||
image:img/vegas.png[]
|
||||
|
||||
[[mouth-shapes]]
|
||||
== Mouth shapes
|
||||
|
||||
Rhubarb Lip Sync can use between six and nine different mouth positions. The first six mouth shapes ({A}-{F}) are the _basic mouth shapes_ and the absolute minimum you have to draw for your character. These six mouth shapes were invented at the Hanna-Barbera studios for shows such as Scooby-Doo and The Flintstones. Since then, they have evolved into a _de-facto_ standard for 2D animation, and have been widely used by studios like Disney and Warner Bros.
|
||||
|
||||
In addition to the six basic mouth shapes, there are three _extended mouth shapes_: {G}, {H}, and {X}. These are optional. You may choose to draw all three of them, pick just one or two, or leave them out entirely.
|
||||
|
||||
[cols="1h,2,6"]
|
||||
|===
|
||||
|
||||
| {A} | image:img/lisa-A.png[]
|
||||
| Closed mouth for the "`P`", "`B`", and "`M`" sounds. This is almost identical to the {X} shape, but there is ever-so-slight pressure between the lips.
|
||||
|
||||
| {B} | image:img/lisa-B.png[]
|
||||
| Slightly open mouth with clenched teeth. This mouth shape is used for most consonants ("`K`", "`S`", "`T`", etc.). It's also used for some vowels such as the "`EE`" sound in b**ee**.
|
||||
|
||||
| {C} | image:img/lisa-C.png[]
|
||||
| Open mouth. This mouth shape is used for vowels like "`EH`" as in m**e**n and "`AE`" as in b**a**t. It's also used for some consonants, depending on context.
|
||||
|
||||
This shape is also used as an in-between when animating from {A} or {B} to {D}. So make sure the animations {A}{C}{D} and {B}{C}{D} look smooth!
|
||||
|
||||
| {D} | image:img/lisa-D.png[]
|
||||
| Wide open mouth. This mouth shapes is used for vowels like "`AA`" as in f**a**ther.
|
||||
|
||||
| {E} | image:img/lisa-E.png[]
|
||||
| Slightly rounded mouth. This mouth shape is used for vowels like "`AO`" as in **o**ff and "`ER`" as in b**ir**d.
|
||||
|
||||
This shape is also used as an in-between when animating from {C} or {D} to {F}. Make sure the mouth isn't wider open than for {C}. Both {C}{E}{F} and {D}{E}{F} should result in smooth animation.
|
||||
|
||||
| {F} | image:img/lisa-F.png[]
|
||||
| Puckered lips. This mouth shape is used for "`UW`" as in y**ou**, "`OW`" as in sh**ow**, and "`W`" as in **w**ay.
|
||||
|
||||
| {G} | image:img/lisa-G.png[]
|
||||
| Upper teeth touching the lower lip for "`F`" as in **f**or and "`V`" as in **v**ery.
|
||||
|
||||
*This extended mouth shape is optional.* If your art style is detailed enough, it greatly improves the overall look of the animation. If you decide not to use it, you can specify so using the <<extendedShapes,`extendedShapes`>> option.
|
||||
|
||||
| {H} | image:img/lisa-H.png[]
|
||||
| This shape is used for long "`L`" sounds, with the tongue raised behind the upper teeth. The mouth should be at least far open as in {C}, but not quite as far as in {D}.
|
||||
|
||||
*This extended mouth shape is optional.* Depending on your art style and the angle of the head, the tongue may not be visible at all. In this case, there is no point in drawing this extra shape. If you decide not to use it, you can specify so using the <<extendedShapes,`extendedShapes`>> option.
|
||||
|
||||
| {X} | image:img/lisa-X.png[]
|
||||
| Idle position. This mouth shape is used for pauses in speech. This should be the same mouth drawing you use when your character is walking around without talking. It is almost identical to {A}, but with slightly less pressure between the lips: For {X}, the lips should be closed but relaxed.
|
||||
|
||||
*This extended mouth shape is optional.* Whether there should be any visible difference between the rest position {X} and the closed talking mouth {A} depends on your art style and personal taste. If you decide not to use it, you can specify so using the <<extendedShapes,`extendedShapes`>> option.
|
||||
|===
|
||||
|
||||
== How to run Rhubarb Lip Sync
|
||||
|
||||
=== General usage ===
|
||||
|
||||
Rhubarb Lip Sync is a command-line tool that is currently available for Windows, macOS, and Linux.
|
||||
|
||||
* Download the https://github.com/DanielSWolf/rhubarb-lip-sync/releases[latest release] for your operating system and unpack the file anywhere on your computer.
|
||||
* On the command-line, call `rhubarb`, passing it an audio file as argument and telling it where to create the output file. In its simplest form, this might look like this: `rhubarb -o output.txt my-recording.wav`. There are additional <<options,command-line options>> you can specify in order to get better results.
|
||||
* Rhubarb Lip Sync will analyze the sound file, animate it, and create an output file containing the animation. If an error occurs, it will instead print an error message to `stderr` and exit with a non-zero exit code.
|
||||
|
||||
[[options]]
|
||||
=== Command-line options ===
|
||||
|
||||
==== Basic command-line options ====
|
||||
|
||||
The following command-line options are the most common:
|
||||
|
||||
[cols="2,5a"]
|
||||
|===
|
||||
| Option | Description
|
||||
|
||||
| _<input file>_
|
||||
| The audio file to be analyzed. This must be the last command-line argument. Supported file formats are WAVE (.wav) and Ogg Vorbis (.ogg).
|
||||
|
||||
| `-r` _<recognizer>_, `--recognizer` _<recognizer>_
|
||||
| Specifies how Rhubarb Lip Sync recognizes speech within the recording. Options: `pocketSphinx` (use for English recordings), `phonetic` (use for non-English recordings). For details, see <<recognizers>>.
|
||||
|
||||
_Default value: ``pocketSphinx``_
|
||||
|
||||
| `-f` _<format>_, `--exportFormat` _<format>_
|
||||
| The export format. Options: `tsv` (tab-separated values, see <<tsv,details>>), `xml` (see <<xml,details>>), `json` (see <<json,details>>), `dat` (see <<moho>>).
|
||||
|
||||
_Default value: ``tsv``_
|
||||
|
||||
| `-d` _<path>_, `--dialogFile` _<path>_
|
||||
| With this option, you can provide Rhubarb Lip Sync with the dialog text to get more reliable results. Specify the path to a plain-text file (in ASCII or UTF-8 format) containing the dialog contained in the audio file. Rhubarb Lip Sync will still perform word recognition internally, but it will prefer words and phrases that occur in the dialog file. This leads to better recognition results and thus more reliable animation.
|
||||
|
||||
For instance, let's say you're recording dialog for a computer game. The script says: "`That's all gobbledygook to me.`" But actually, the voice artist ends up saying "`That's _just_ gobbledygook to me,`" deviating from the dialog. If you specify a dialog file with the original line ("`That's all gobbledygook to me`"), this will still allow Rhubarb Lip Sync to produce better results, because it will watch out for the uncommon word "`gobbledygook`". Rhubarb Lip Sync will ignore the dialog file where it audibly differs from the recording, and benefit from it where it matches.
|
||||
|
||||
_It is always a good idea to specify the dialog text. This will usually lead to more reliable mouth animation, even if the text is not completely accurate._
|
||||
|
||||
[[extendedShapes]]
|
||||
| `--extendedShapes` _<string>_
|
||||
| As described in <<mouth-shapes>>, Rhubarb Lip Sync uses six basic mouth shapes and up to three _extended mouth shapes_, which are optional. Use this option to specify which extended mouth shapes should be used. For example, to use only the {G} and {X} extended mouth shapes, specify `GX`; to use only the six basic mouth shapes, specify an empty string: `""`.
|
||||
|
||||
_Default value: ``GHX``_
|
||||
|
||||
| `-o`, `--output` _<output file>_
|
||||
| The name of the output file to create. If the file already exists, it will be overwritten. If you don't specify an output file, the result will be written to `stdout`.
|
||||
|
||||
| `--version`
|
||||
| Displays version information and exits.
|
||||
|
||||
| `-h`, `--help`
|
||||
| Displays usage information and exits.
|
||||
|
||||
| `--datFrameRate` _number_
|
||||
| Only valid when using the `dat` export format. Controls the frame rate for the output file.
|
||||
|
||||
_Default value: 24_
|
||||
|
||||
| `--datUsePrestonBlair`
|
||||
| Only valid when using the `dat` export format. Uses Preston Blair mouth shapes names instead of the default alphabetical ones. This applies the following mapping:
|
||||
|
||||
!===
|
||||
! Alphabetic name ! Preston Blair name
|
||||
|
||||
! A ! MBP
|
||||
! B ! etc
|
||||
! C ! E
|
||||
! D ! AI
|
||||
! E ! O
|
||||
! F ! U
|
||||
! G ! FV
|
||||
! H ! L
|
||||
! X ! rest
|
||||
!===
|
||||
|
||||
*Caution:* This mapping is only applied when exporting, _after_ the recording has been animated. To control which mouth shapes to use, use the <<extendedShapes,`extendedShapes`>> option _with the alphabetic names_.
|
||||
|
||||
*Tip:* For optimal results, make sure your mouth drawings follow the guidelines in the <<mouth-shapes>> section. This is easier if you stick to the alphabetic names instead of the Preston Blair names. The only situation where you _need_ to use the Preston Blair names is when you're using OpenToonz, because OpenToonz only supports the Preston Blair names.
|
||||
|
||||
|===
|
||||
|
||||
==== Advanced command-line options ====
|
||||
|
||||
The following command-line options can be helpful in special situations, especially when automating Rhubarb Lip Sync.
|
||||
|
||||
[cols="2,5"]
|
||||
|===
|
||||
| Option | Description
|
||||
|
||||
[[quiet]]
|
||||
| `-q`, `--quiet`
|
||||
| By default, Rhubarb Lip Sync writes a number of progress messages to `stderr`. If you're using it as part of a batch process, this may clutter your console. If you specify the `--quiet` flag, there won't be any output to `stderr` unless an error occurred.
|
||||
|
||||
You can combine this option with the <<consoleLevel,`consoleLevel`>> option to change the minimum event level that is printed to `stderr`.
|
||||
|
||||
| `--machineReadable`
|
||||
a| This option is useful if you want to integrate Rhubarb Lip Sync with another (possibly graphical) application. All status messages to `stderr` will be in structured JSON format, allowing your program to parse them and display a graphical progress bar or something similar. For details, see <<machineReadable,Machine-readable status messages>>.
|
||||
|
||||
[[consoleLevel]]
|
||||
| `--consoleLevel` _<level>_
|
||||
| Sets the log level for reporting to the console (`stderr`). Options: `trace`, `debug`, `info`, `warning`, `error`, `fatal`.
|
||||
|
||||
If <<quiet,`--quiet`>> is also specified, only events with the specified level or higher will be printed. Otherwise, a small number of essential events (startup, progress, etc.) will be printed even if their levels are below the specified value.
|
||||
|
||||
_Default value: ``error``_
|
||||
|
||||
| `--logFile` _<path>_
|
||||
| Creates a log file with diagnostic information at the specified path.
|
||||
|
||||
|`--logLevel` _<level>_
|
||||
| Sets the log level for the log file. Only events with the specified level or higher will be logged. Options: `trace`, `debug`, `info`, `warning`, `error`, `fatal`.
|
||||
|
||||
_Default value: ``debug``_
|
||||
|
||||
| `--threads` _<number>_
|
||||
| Rhubarb Lip Sync uses multithreading to speed up processing. By default, it creates as many worker threads as there are cores on your CPU, which results in optimal processing speed. You may choose to specify a lower number if you feel that Rhubarb Lip Sync is slowing down other applications. Specifying a higher number is not recommended, as it won't result in any additional speed-up.
|
||||
|
||||
Note that for short audio files, Rhubarb Lip Sync may choose to use fewer threads than specified.
|
||||
|
||||
_Default value: as many threads as your CPU has cores_
|
||||
|===
|
||||
|
||||
[[recognizers]]
|
||||
== Recognizers
|
||||
|
||||
The first step in processing an audio file is determining what is being said. More specifically, Rhubarb Lip Sync uses speech recognition to figure out what sound is being said at what point in time. You can choose between two recognizers:
|
||||
|
||||
=== PocketSphinx
|
||||
|
||||
PocketSphinx is an open-source speech recognition library that generally gives good results. This is the default recognizer. The downside is that PocketSphinx only recognizes English dialog. So if your recordings are in a language other than English, this is not a good choice.
|
||||
|
||||
=== Phonetic
|
||||
|
||||
Rhubarb Lip Sync also comes with a phonetic recognizer. _Phonetic_ means that this recognizer won't try to understand entire (English) words and phrases. Instead, it will recognize individual sounds and syllables. The results are usually less precise than those from the PocketSphinx recognizer. The advantage is that this recognizer is language-independent. Use it if your recordings are not in English.
|
||||
|
||||
[[outputFormats]]
|
||||
== Output formats
|
||||
|
||||
The output of Rhubarb Lip Sync is a file that tells you which mouth shape to display at what time within the recording. You can choose between three file formats -- TSV, XML, and JSON. The following paragraphs show you what each of these formats looks like.
|
||||
|
||||
[[tsv]]
|
||||
=== Tab-separated values (`tsv`)
|
||||
|
||||
TSV is the simplest and most compact export format supported by Rhubarb Lip Sync. Each line starts with a timestamp (in seconds), followed by a tab, followed by the name of the mouth shape. The following is the output for a recording of a person saying 'Hi.'
|
||||
|
||||
[source]
|
||||
----
|
||||
0.00 X
|
||||
0.05 D
|
||||
0.27 C
|
||||
0.31 B
|
||||
0.43 X
|
||||
0.47 X
|
||||
----
|
||||
|
||||
Here's how to read it:
|
||||
|
||||
* At the beginning of the recording (0.00s), the mouth is closed (shape {X}). The very first output will always have the timestamp 0.00s.
|
||||
* 0.05s into the recording, the mouth opens wide (shape {D}) for the "`HH`" sound, anticipating the "`AY`" sound that will follow.
|
||||
* The second half of the "`AY`" diphtong (0.31s into the recording) requires clenched teeth (shape {B}). Before that, shape {C} is inserted as an in-between at 0.27s. This allows for a smoother animation from {D} to {B}.
|
||||
* 0.43s into the recording, the dialog is finished and the mouth closes again (shape {X}).
|
||||
* The last output line in TSV format is special: Its timestamp is always the very end of the recording (truncated to a multiple of 0.01s) and its value is always a closed mouth (shape {X} or {A}, depending on your <<extendedShapes,`extendedShapes`>> settings).
|
||||
|
||||
[[xml]]
|
||||
=== XML format (`xml`)
|
||||
|
||||
XML format is rather verbose. The following is the output for a person saying 'Hi,' the same recording as above.
|
||||
|
||||
[source,xml]
|
||||
----
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<rhubarbResult>
|
||||
<metadata>
|
||||
<soundFile>C:\Users\Daniel\Desktop\av\hi\hi.wav</soundFile>
|
||||
<duration>0.47</duration>
|
||||
</metadata>
|
||||
<mouthCues>
|
||||
<mouthCue start="0.00" end="0.05">X</mouthCue>
|
||||
<mouthCue start="0.05" end="0.27">D</mouthCue>
|
||||
<mouthCue start="0.27" end="0.31">C</mouthCue>
|
||||
<mouthCue start="0.31" end="0.43">B</mouthCue>
|
||||
<mouthCue start="0.43" end="0.47">X</mouthCue>
|
||||
</mouthCues>
|
||||
</rhubarbResult>
|
||||
----
|
||||
|
||||
The file starts with a `metadata` block containing the full path of the original recording and its duration (truncated to a multiple of 0.01s). After that, each `mouthCue` element indicates the start and end of a certain mouth shape, as explained for <<tsv,TSV format>>. Note that the end of each mouth cue is identical with the start of the following one. This is a bit redundant, but it means that we don't need a special final element like in TSV format.
|
||||
|
||||
[[json]]
|
||||
=== JSON format (`json`)
|
||||
|
||||
JSON format is very similar to <<xml,XML format>>. The choice mainly depends on the programming language you use, which may have built-in support for one format but not the other. The following is the output for a person saying 'Hi,' the same recording as above.
|
||||
|
||||
[source,json]
|
||||
----
|
||||
{
|
||||
"metadata": {
|
||||
"soundFile": "C:\\Users\\Daniel\\Desktop\\av\\hi\\hi.wav",
|
||||
"duration": 0.47
|
||||
},
|
||||
"mouthCues": [
|
||||
{ "start": 0.00, "end": 0.05, "value": "X" },
|
||||
{ "start": 0.05, "end": 0.27, "value": "D" },
|
||||
{ "start": 0.27, "end": 0.31, "value": "C" },
|
||||
{ "start": 0.31, "end": 0.43, "value": "B" },
|
||||
{ "start": 0.43, "end": 0.47, "value": "X" }
|
||||
]
|
||||
}
|
||||
----
|
||||
|
||||
There is nothing surprising here; everything said about XML format applies to JSON, too.
|
||||
|
||||
[[machineReadable]]
|
||||
== Machine-readable status messages
|
||||
|
||||
Use the `--machineReadable` command-line option to enable machine-readable status messages. In this mode, each line printed to `stderr` will be an object in JSON format. Every object contains the following:
|
||||
|
||||
* Property `type`: The type of the event. Currently, one of `"start"` (application start), `"progress"` (numeric progress), `"success"` (successful termination), `"failure"` (unsuccessful termination), and `"log"` (a log message without structured information).
|
||||
* Event-specific structured data. For instance, a `"progress"` event contains the property `value` with a numeric value between 0.0 and 1.0.
|
||||
* Property `log`: A log message describing the event, plus severity information. If you aren't interested in the structured data, you can display this as a fallback. For instance, a `"progress"` event with the structured information `"value": 0.69` may contain the following redundant log message: `"Progress: 69%"`.
|
||||
|
||||
You can combine this option with the <<consoleLevel,`consoleLevel`>> option. Note, however, that this only affects unstructured events of type `"log"` (not to be confused with the `log` property each event contains).
|
||||
|
||||
The following is an example output to `stderr` from a _successful_ run:
|
||||
|
||||
[source,json]
|
||||
----
|
||||
{ "type": "start", "file": "hi.wav", "log": { "level": "Info", "message": "Application startup. Input file: \"hi.wav\"." } }
|
||||
{ "type": "progress", "value": 0.00, "log": { "level": "Trace", "message": "Progress: 0%" } }
|
||||
{ "type": "progress", "value": 0.01, "log": { "level": "Trace", "message": "Progress: 1%" } }
|
||||
{ "type": "progress", "value": 0.03, "log": { "level": "Trace", "message": "Progress: 3%" } }
|
||||
{ "type": "progress", "value": 0.06, "log": { "level": "Trace", "message": "Progress: 6%" } }
|
||||
{ "type": "progress", "value": 0.69, "log": { "level": "Trace", "message": "Progress: 68%" } }
|
||||
{ "type": "progress", "value": 1.00, "log": { "level": "Trace", "message": "Progress: 100%" } }
|
||||
// Result data, printed to stdout...
|
||||
{ "type": "success", "log": { "level": "Info", "message": "Application terminating normally." } }
|
||||
----
|
||||
|
||||
The following is an example output to `stderr` from a _failed_ run:
|
||||
|
||||
[source,json]
|
||||
----
|
||||
{ "type": "start", "file": "no-such-file.wav", "log": { "level": "Info", "message": "Application startup. Input file: \"no-such-file.wav\"." } }
|
||||
{ "type": "failure", "reason": "Error processing file \"no-such-file.wav\".\nCould not open sound file \"no-such-file.wav\".\nNo such file or directory", "log": { "level": "Fatal", "message": "Application terminating with error: Error processing file \"no-such-file.wav\".\nCould not open sound file \"no-such-file.wav\".\nNo such file or directory" } }
|
||||
----
|
||||
|
||||
Note that the output format <<Versioning,adheres to SemVer>>. That means that the JSON output created after a minor upgrade will still be compatible. Note, however, that the following kinds of changes may occur at any time, because I consider them non-breaking:
|
||||
|
||||
* Additional types of progress events. Just ignore those events whose types you do not know or use their unstructured `log` property.
|
||||
* Additional properties in any object. Just ignore properties you aren't interested in.
|
||||
* Changes in JSON formatting, such as a re-ordering of properties or changes in whitespaces (except for line breaks -- every event will remain on a singe line)
|
||||
* Fewer or more events of type `"log"` or changes in the wording of log messages
|
||||
|
||||
[[versioning]]
|
||||
== Versioning (SemVer)
|
||||
|
||||
Rhubarb Lip Sync uses Semantic Versioning (SemVer) for its command-line interface. For general information on Semantic Versioning, have a look at the http://semver.org/[official SemVer website].
|
||||
|
||||
As a rule of thumb, everything you can use through the command-line interface adheres to SemVer. Everything else (i.e., the source code, integrations with third-party software, etc.) does not.
|
||||
|
||||
[[building-from-source]]
|
||||
== Building from source
|
||||
|
||||
To use Rhubarb Lip Sync on Windows, macOS, or Linux, you can just download the binary release for your operating system. If you want to modify the code or use Rhubarb on a less-common operating system, this section describes how to build it yourself.
|
||||
|
||||
You'll need the following software installed:
|
||||
|
||||
* CMake 3.10+
|
||||
* A C{plus}{plus} compiler that supports C{plus}{plus}17 +
|
||||
(Rhubarb Lip Sync is regularly built using Visual Studio 2019, Xcode 14, GCC 10, and Clang 12.)
|
||||
* A current version of Boost
|
||||
* JDK 8.x (for building Rhubarb for Spine)
|
||||
|
||||
Then, follow these steps:
|
||||
|
||||
. Create an empty directory `/build` within the Rhubarb repository
|
||||
. Move to the new `/build` directory
|
||||
. Configure CMake by running `cmake ..` +
|
||||
Optionally, pass flags for setting the generator, compiler etc.. For working examples, see `.github\workflows\ci.yml`.
|
||||
. Build Rhubarb Lip Sync by running `cmake --build . --config Release`
|
||||
|
||||
== I'd love to hear from you!
|
||||
|
||||
Have you created something great using Rhubarb Lip Sync? -- *https://twitter.com/RhubarbLipSync[Let me know on Twitter]* or *send me an email* at +++dwolf@dannad.de+++!
|
||||
|
||||
Do you need help? Have you spotted a bug? Do you have a suggestion? -- *https://github.com/DanielSWolf/rhubarb-lip-sync/issues[Create an issue!]*
|
|
@ -0,0 +1,119 @@
|
|||
# Rhubarb Lip-Sync
|
||||
|
||||
[Rhubarb Lip-Sync](https://github.com/DanielSWolf/rhubarb-lip-sync) is a command-line tool that automatically creates mouth animation from voice recordings. You can use it for characters in computer games, in animated cartoons, or in any other project that requires animating mouths based on existing recordings.
|
||||
|
||||
Rhubarb Lip-Sync produces output files in various text formats (TSV/XML/JSON). If you're a programmer, this makes it easy for you to use the output in whatever way you like. If you're not a programmer, there is currently no direct way to import the result into your favorite animation tool. If this is what you need, feel free to [create an issue](https://github.com/DanielSWolf/rhubarb-lip-sync/issues) telling me what tool you're using. I might add support for a few popular animation tools in the future.
|
||||
|
||||
## Mouth shapes
|
||||
|
||||
Rhubarb Lip-Sync uses a fixed set of eight mouth shapes, named from A-H. These mouth shapes are based on the six mouth shapes (A-F) originally developed at the Hanna-Barbera animation studios for classic shows such as Scooby-Doo and The Flintstones.
|
||||
|
||||
| Name | Image | Description |
|
||||
| ---- | ----- | ----------- |
|
||||
| A |  | Closed mouth for rest position and the *P*, *B*, and *M* sounds. |
|
||||
| B |  | Slightly open mouth with clenched teeth. Used for most consonants as well as the *EE* sound in b**ee** or sh**e**. |
|
||||
| C |  | Open mouth for the vowels *EH* as in r**e**d, m**e**n; *IH* as in b**i**g, w**i**n; *AH* as in b**u**t, s**u**n, **a**lone; and *EY* as in s**a**y, **e**ight. |
|
||||
| D |  | Wide open mouth for the vowels *AA* as in f**a**ther; *AE* as in **a**t, b**a**t; *AY* as in m**y**, wh**y**, r**i**de; and *AW* as in h**o**w, n**o**w. |
|
||||
| E |  | Slightly rounded mouth for the vowels *AO* as in **o**ff, f**a**ll; *UH* as in sh**ou**ld, c**ou**ld; *OW* as in sh**o**w, c**o**at; and *ER* as in h**er**, b**ir**d. |
|
||||
| F |  | Small rounded mouth for *UW* as in y**ou**, n**ew**; *OY* as in b**o**y, t**o**y; and *W* as in **w**ay. |
|
||||
| G |  | Biting the lower lip for the *F* and *V* sounds. |
|
||||
| H |  | The *L* sound with the tongue slightly visible. |
|
||||
|
||||
## How to run Rhubarb Lip-Sync
|
||||
|
||||
Rhubarb Lip-Sync is a command-line tool that is currently available for Windows and OS X.
|
||||
|
||||
* Download the [latest release](https://github.com/DanielSWolf/rhubarb-lip-sync/releases) and unzip the file anywhere on your computer.
|
||||
* Call `rhubarb`, passing it a WAVE file as argument, and redirecting the output to a file. This might look like this: `rhubarb my-recording.wav > output.txt`.
|
||||
* Rhubarb Lip-Sync will analyze the sound file and print the result to `stdout`. If you've redirected `stdout` to a file like above, you will now have an XML file containing the lip-sync data.
|
||||
|
||||
The following is a complete list of available command-line options.
|
||||
|
||||
| Option | Description |
|
||||
| ------ | ----------- |
|
||||
| `-f` *format*,<br/>`--exportFormat` *format* | The export format. Options: `tsv` (tab-separated values), `xml`, `json`. Default value: `tsv` |
|
||||
| `-d` *text*,<br/>`--dialog` *text* | Allows you to explicitly specify the text of the dialog rather than relying on Rhubarb Lip-Sync's automatic recognition. This is an experimental feature. Currently, the main limitation is that each word must be contained in Rhubarb Lip-Sync's internal dictionary, or the program will fail. |
|
||||
| `--logFile` *path* | Creates a log file with diagnostic information at the specified path. |
|
||||
| `--logLevel` *level* | Sets the log level for the log file. Options: `trace`, `debug`, `info`, `warning`, `error`, `fatal`. Default value: `debug` |
|
||||
| `--version` | Displays version information and exits. |
|
||||
| `-h`,<br/>`--help` | Displays usage information and exits. |
|
||||
| *input file* | The input file to be analyzed. Must be an sound file in WAVE format. ||
|
||||
|
||||
## How to use the output
|
||||
|
||||
The output of Rhubarb Lip-Sync is a file that tells you which mouth shape to display at what time within the recording. You can choose between three file formats -- TSV, XML, and JSON. The following paragraphs show you what each of these formats looks like.
|
||||
|
||||
### Tab-separated values (`tsv`)
|
||||
|
||||
TSV is the simplest and most compact export format supported by Rhubarb Lip-Sync. Each line starts with a timestamp (in seconds), followed by a tab, followed by the name of the mouth shape. The following is the output for a recording of a person saying 'Hi.'
|
||||
|
||||
```
|
||||
0.00 A
|
||||
0.09 C
|
||||
0.17 D
|
||||
0.38 A
|
||||
0.47 A
|
||||
```
|
||||
|
||||
You see that at the beginning of the recording, the mouth is closed (shape A). 0.09s into the recording, the mouth opens (shape C); a little later, it opens even wider (shape D). 0.38s into the recording, it closes again (shape A).
|
||||
|
||||
The last output line in TSV format is special: Its timestamp is always the very end of the recording (truncated to a multiple of 0.01s) and its value is always a closed mouth (shape A).
|
||||
|
||||
### XML format (`xml`)
|
||||
|
||||
XML format is rather verbose. The following is the output for a person saying 'Hi,' the same recording as above.
|
||||
|
||||
```xml
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<rhubarbResult>
|
||||
<metadata>
|
||||
<soundFile>C:\Users\Daniel\Desktop\audio-test\hi.wav</soundFile>
|
||||
<duration>0.47</duration>
|
||||
</metadata>
|
||||
<mouthCues>
|
||||
<mouthCue start="0.00" end="0.09">A</mouthCue>
|
||||
<mouthCue start="0.09" end="0.17">C</mouthCue>
|
||||
<mouthCue start="0.17" end="0.38">D</mouthCue>
|
||||
<mouthCue start="0.38" end="0.47">A</mouthCue>
|
||||
</mouthCues>
|
||||
</rhubarbResult>
|
||||
```
|
||||
|
||||
The file starts with a `metadata` block containing the full path of the original recording and its duration (truncated to a multiple of 0.01s). After that, each `mouthCue` element indicates the start and end of a certain mouth shape, as explained for TSV format. Note that the end of each mouth cue is identical with the start of the following one. This is a bit redundant, but it means that we don't need a special final element like in TSV format.
|
||||
|
||||
### JSON format (`json`)
|
||||
|
||||
JSON format is very similar to XML format -- the choice mainly depends on which is better supported by your programming language. The following is the output for a person saying 'Hi,' the same recording as above.
|
||||
|
||||
```json
|
||||
{
|
||||
"metadata": {
|
||||
"soundFile": "C:\\Users\\Daniel\\Desktop\\audio-test\\hi.wav",
|
||||
"duration": 0.47
|
||||
},
|
||||
"mouthCues": [
|
||||
{ "start": 0.00, "end": 0.09, "value": "A" },
|
||||
{ "start": 0.09, "end": 0.17, "value": "C" },
|
||||
{ "start": 0.17, "end": 0.38, "value": "D" },
|
||||
{ "start": 0.38, "end": 0.47, "value": "A" }
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
There is nothing surprising here; everything said about XML format applies to JSON, too.
|
||||
|
||||
## Limitations
|
||||
|
||||
Rhubarb Lip-Sync has some limitations you should be aware of.
|
||||
|
||||
### English only
|
||||
|
||||
Rhubarb Lip-Sync only produces good results when you give it recordings in English. You'll get best results with American English.
|
||||
|
||||
### Fixed set of mouth shapes
|
||||
|
||||
Rhubarb Lip-Sync uses a fixed set of eight mouth shapes, as shown above. If you want to use fewer shapes, you can apply a custom mapping in your own code.
|
||||
|
||||
## Tell me what you think!
|
||||
|
||||
Right now, Rhubarb Lip-Sync is very much work in progress. If you need help or have any suggestions, feel free to [create an issue](https://github.com/DanielSWolf/rhubarb-lip-sync/issues).
|
|
@ -0,0 +1,13 @@
|
|||
# Version history
|
||||
|
||||
## Version 0.2
|
||||
|
||||
* Multiple output formats: TSV, XML, JSON
|
||||
* Experimental option to supply dialog text
|
||||
* Improved error handling and error messages
|
||||
|
||||
## Version 0.1
|
||||
|
||||
* Two-pass phone detection using [CMU PocketSphinx](http://cmusphinx.sourceforge.net/)
|
||||
* Fixed set of eight mouth shapes, based on the Hanna-Barbera shapes
|
||||
* Naive (but well-tuned) mapping from phones to mouth shapes
|
|
@ -1,8 +0,0 @@
|
|||
cmake_minimum_required(VERSION 3.24)
|
||||
|
||||
set(appName "Rhubarb Lip Sync")
|
||||
set(appVersionMajor 1)
|
||||
set(appVersionMinor 13)
|
||||
set(appVersionPatch 0)
|
||||
set(appVersionSuffix "")
|
||||
set(appVersion "${appVersionMajor}.${appVersionMinor}.${appVersionPatch}${appVersionSuffix}")
|
|
@ -1,11 +0,0 @@
|
|||
cmake_minimum_required(VERSION 3.24)
|
||||
|
||||
set(afterEffectsFiles
|
||||
"Rhubarb Lip Sync.jsx"
|
||||
"README.adoc"
|
||||
)
|
||||
|
||||
install(
|
||||
FILES ${afterEffectsFiles}
|
||||
DESTINATION "extras/AdobeAfterEffects"
|
||||
)
|
|
@ -1,29 +0,0 @@
|
|||
= Animation script for Adobe After Effects
|
||||
|
||||
The script in this directory generates After Effects compositions with mouth animation.
|
||||
|
||||
== How to install
|
||||
|
||||
=== 1. Download and extract
|
||||
|
||||
Download the archive file containing Rhubarb Lip Sync, then extract in a directory on your computer.
|
||||
|
||||
=== 2. Make Rhubarb available to After Effects
|
||||
|
||||
On *Windows*, add the Rhubarb directory (the directory containing `rhubarb.exe`) to your `PATH` environment variable.
|
||||
|
||||
On *OS X*, create a symbolic link to the executable (`rhubarb`) in `/usr/local/bin/`. You can do that by executing `ln -s /rhubarb-directory/rhubarb /usr/local/bin/` (make sure to replace `rhubarb-directory` with the actual directory).
|
||||
|
||||
=== 3. Install After Effects script
|
||||
|
||||
Copy (or symlink) the script file `Rhubarb Lip Sync.jsx` into your After Effects scripts directory.
|
||||
|
||||
On *Windows*, that directory is usually `C:\Program Files\Adobe\Adobe After Effects <version>\Support Files\Scripts`.
|
||||
|
||||
On *OS X*, that directory is usually `Applications/Adobe After Effects <version>/Scripts`.
|
||||
|
||||
=== 4. (Re-)start After Effects
|
||||
|
||||
== How to use
|
||||
|
||||
In After Effects, select _File > Scripts > Rhubarb Lip Sync.jsx_. That will open a dialog window where you can specify the audio file with the dialog recording and a number of other options. To get information about any input field, just hover above it with your mouse and you’ll see a tooltip.
|
|
@ -1,758 +0,0 @@
|
|||
// Polyfill for Object.assign
|
||||
"function"!=typeof Object.assign&&(Object.assign=function(a,b){"use strict";if(null==a)throw new TypeError("Cannot convert undefined or null to object");for(var c=Object(a),d=1;d<arguments.length;d++){var e=arguments[d];if(null!=e)for(var f in e)Object.prototype.hasOwnProperty.call(e,f)&&(c[f]=e[f])}return c});
|
||||
|
||||
// Polyfill for Array.isArray
|
||||
Array.isArray||(Array.isArray=function(r){return"[object Array]"===Object.prototype.toString.call(r)});
|
||||
|
||||
// Polyfill for Array.prototype.map
|
||||
Array.prototype.map||(Array.prototype.map=function(r){var t,n,o;if(null==this)throw new TypeError("this is null or not defined");var e=Object(this),i=e.length>>>0;if("function"!=typeof r)throw new TypeError(r+" is not a function");for(arguments.length>1&&(t=arguments[1]),n=new Array(i),o=0;o<i;){var a,p;o in e&&(a=e[o],p=r.call(t,a,o,e),n[o]=p),o++}return n});
|
||||
|
||||
// Polyfill for Array.prototype.every
|
||||
Array.prototype.every||(Array.prototype.every=function(r,t){"use strict";var e,n;if(null==this)throw new TypeError("this is null or not defined");var o=Object(this),i=o.length>>>0;if("function"!=typeof r)throw new TypeError;for(arguments.length>1&&(e=t),n=0;n<i;){var y;if(n in o&&(y=o[n],!r.call(e,y,n,o)))return!1;n++}return!0});
|
||||
|
||||
// Polyfill for Array.prototype.find
|
||||
Array.prototype.find||(Array.prototype.find=function(r){if(null===this)throw new TypeError("Array.prototype.find called on null or undefined");if("function"!=typeof r)throw new TypeError("callback must be a function");for(var n=Object(this),t=n.length>>>0,o=arguments[1],e=0;e<t;e++){var f=n[e];if(r.call(o,f,e,n))return f}});
|
||||
|
||||
// Polyfill for Array.prototype.filter
|
||||
Array.prototype.filter||(Array.prototype.filter=function(r){"use strict";if(void 0===this||null===this)throw new TypeError;var t=Object(this),e=t.length>>>0;if("function"!=typeof r)throw new TypeError;for(var i=[],o=arguments.length>=2?arguments[1]:void 0,n=0;n<e;n++)if(n in t){var f=t[n];r.call(o,f,n,t)&&i.push(f)}return i});
|
||||
|
||||
// Polyfill for Array.prototype.forEach
|
||||
Array.prototype.forEach||(Array.prototype.forEach=function(a,b){var c,d;if(null===this)throw new TypeError(" this is null or not defined");var e=Object(this),f=e.length>>>0;if("function"!=typeof a)throw new TypeError(a+" is not a function");for(arguments.length>1&&(c=b),d=0;d<f;){var g;d in e&&(g=e[d],a.call(c,g,d,e)),d++}});
|
||||
|
||||
// Polyfill for Array.prototype.includes
|
||||
Array.prototype.includes||(Array.prototype.includes=function(r,t){if(null==this)throw new TypeError('"this" is null or not defined');var e=Object(this),n=e.length>>>0;if(0===n)return!1;for(var i=0|t,o=Math.max(i>=0?i:n-Math.abs(i),0);o<n;){if(function(r,t){return r===t||"number"==typeof r&&"number"==typeof t&&isNaN(r)&&isNaN(t)}(e[o],r))return!0;o++}return!1});
|
||||
|
||||
// Polyfill for Array.prototype.indexOf
|
||||
Array.prototype.indexOf||(Array.prototype.indexOf=function(r,t){var n;if(null==this)throw new TypeError('"this" is null or not defined');var e=Object(this),i=e.length>>>0;if(0===i)return-1;var o=0|t;if(o>=i)return-1;for(n=Math.max(o>=0?o:i-Math.abs(o),0);n<i;){if(n in e&&e[n]===r)return n;n++}return-1});
|
||||
|
||||
// Polyfill for Array.prototype.some
|
||||
Array.prototype.some||(Array.prototype.some=function(r){"use strict";if(null==this)throw new TypeError("Array.prototype.some called on null or undefined");if("function"!=typeof r)throw new TypeError;for(var e=Object(this),o=e.length>>>0,t=arguments.length>=2?arguments[1]:void 0,n=0;n<o;n++)if(n in e&&r.call(t,e[n],n,e))return!0;return!1});
|
||||
|
||||
// Polyfill for String.prototype.trim
|
||||
String.prototype.trim||(String.prototype.trim=function(){return this.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")});
|
||||
|
||||
// Polyfill for JSON
|
||||
"object"!=typeof JSON&&(JSON={}),function(){"use strict";function f(a){return a<10?"0"+a:a}function this_value(){return this.valueOf()}function quote(a){return rx_escapable.lastIndex=0,rx_escapable.test(a)?'"'+a.replace(rx_escapable,function(a){var b=meta[a];return"string"==typeof b?b:"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+a+'"'}function str(a,b){var c,d,e,f,h,g=gap,i=b[a];switch(i&&"object"==typeof i&&"function"==typeof i.toJSON&&(i=i.toJSON(a)),"function"==typeof rep&&(i=rep.call(b,a,i)),typeof i){case"string":return quote(i);case"number":return isFinite(i)?String(i):"null";case"boolean":case"null":return String(i);case"object":if(!i)return"null";if(gap+=indent,h=[],"[object Array]"===Object.prototype.toString.apply(i)){for(f=i.length,c=0;c<f;c+=1)h[c]=str(c,i)||"null";return e=0===h.length?"[]":gap?"[\n"+gap+h.join(",\n"+gap)+"\n"+g+"]":"["+h.join(",")+"]",gap=g,e}if(rep&&"object"==typeof rep)for(f=rep.length,c=0;c<f;c+=1)"string"==typeof rep[c]&&(d=rep[c],(e=str(d,i))&&h.push(quote(d)+(gap?": ":":")+e));else for(d in i)Object.prototype.hasOwnProperty.call(i,d)&&(e=str(d,i))&&h.push(quote(d)+(gap?": ":":")+e);return e=0===h.length?"{}":gap?"{\n"+gap+h.join(",\n"+gap)+"\n"+g+"}":"{"+h.join(",")+"}",gap=g,e}}var rx_one=/^[\],:{}\s]*$/,rx_two=/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,rx_three=/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,rx_four=/(?:^|:|,)(?:\s*\[)+/g,rx_escapable=/[\\"\u0000-\u001f\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,rx_dangerous=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g;"function"!=typeof Date.prototype.toJSON&&(Date.prototype.toJSON=function(){return isFinite(this.valueOf())?this.getUTCFullYear()+"-"+f(this.getUTCMonth()+1)+"-"+f(this.getUTCDate())+"T"+f(this.getUTCHours())+":"+f(this.getUTCMinutes())+":"+f(this.getUTCSeconds())+"Z":null},Boolean.prototype.toJSON=this_value,Number.prototype.toJSON=this_value,String.prototype.toJSON=this_value);var gap,indent,meta,rep;"function"!=typeof JSON.stringify&&(meta={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},JSON.stringify=function(a,b,c){var d;if(gap="",indent="","number"==typeof c)for(d=0;d<c;d+=1)indent+=" ";else"string"==typeof c&&(indent=c);if(rep=b,b&&"function"!=typeof b&&("object"!=typeof b||"number"!=typeof b.length))throw new Error("JSON.stringify");return str("",{"":a})}),"function"!=typeof JSON.parse&&(JSON.parse=function(text,reviver){function walk(a,b){var c,d,e=a[b];if(e&&"object"==typeof e)for(c in e)Object.prototype.hasOwnProperty.call(e,c)&&(d=walk(e,c),void 0!==d?e[c]=d:delete e[c]);return reviver.call(a,b,e)}var j;if(text=String(text),rx_dangerous.lastIndex=0,rx_dangerous.test(text)&&(text=text.replace(rx_dangerous,function(a){return"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)})),rx_one.test(text.replace(rx_two,"@").replace(rx_three,"]").replace(rx_four,"")))return j=eval("("+text+")"),"function"==typeof reviver?walk({"":j},""):j;throw new SyntaxError("JSON.parse")})}();
|
||||
|
||||
function last(array) {
|
||||
return array[array.length - 1];
|
||||
}
|
||||
|
||||
function createGuid() {
|
||||
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
|
||||
var r = Math.random() * 16 | 0;
|
||||
var v = c == 'x' ? r : (r & 0x3 | 0x8);
|
||||
return v.toString(16);
|
||||
});
|
||||
}
|
||||
|
||||
function toArray(list) {
|
||||
var result = [];
|
||||
for (var i = 0; i < list.length; i++) {
|
||||
result.push(list[i]);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
function toArrayBase1(list) {
|
||||
var result = [];
|
||||
for (var i = 1; i <= list.length; i++) {
|
||||
result.push(list[i]);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
function pad(n, width, z) {
|
||||
z = z || '0';
|
||||
n = String(n);
|
||||
return n.length >= width ? n : new Array(width - n.length + 1).join(z) + n;
|
||||
}
|
||||
|
||||
// Checks whether scripts are allowed to write files by creating and deleting a dummy file
|
||||
function canWriteFiles() {
|
||||
try {
|
||||
var file = new File();
|
||||
file.open('w');
|
||||
file.writeln('');
|
||||
file.close();
|
||||
file.remove();
|
||||
return true;
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function frameToTime(frameNumber, compItem) {
|
||||
return frameNumber * compItem.frameDuration;
|
||||
}
|
||||
|
||||
function timeToFrame(time, compItem) {
|
||||
return time * compItem.frameRate;
|
||||
}
|
||||
|
||||
// To prevent rounding errors
|
||||
var epsilon = 0.001;
|
||||
|
||||
function isFrameVisible(compItem, frameNumber) {
|
||||
if (!compItem) return false;
|
||||
|
||||
var time = frameToTime(frameNumber + epsilon, compItem);
|
||||
var videoLayers = toArrayBase1(compItem.layers).filter(function(layer) {
|
||||
return layer.hasVideo;
|
||||
});
|
||||
var result = videoLayers.find(function(layer) {
|
||||
return layer.activeAtTime(time);
|
||||
});
|
||||
return Boolean(result);
|
||||
}
|
||||
|
||||
var appName = 'Rhubarb Lip Sync';
|
||||
|
||||
var settingsFilePath = Folder.userData.fullName + '/rhubarb-ae-settings.json';
|
||||
|
||||
function readTextFile(fileOrPath) {
|
||||
var filePath = fileOrPath.fsName || fileOrPath;
|
||||
var file = new File(filePath);
|
||||
function check() {
|
||||
if (file.error) throw new Error('Error reading file "' + filePath + '": ' + file.error);
|
||||
}
|
||||
try {
|
||||
file.open('r'); check();
|
||||
file.encoding = 'UTF-8'; check();
|
||||
var result = file.read(); check();
|
||||
return result;
|
||||
} finally {
|
||||
file.close(); check();
|
||||
}
|
||||
}
|
||||
|
||||
function writeTextFile(fileOrPath, text) {
|
||||
var filePath = fileOrPath.fsName || fileOrPath;
|
||||
var file = new File(filePath);
|
||||
function check() {
|
||||
if (file.error) throw new Error('Error writing file "' + filePath + '": ' + file.error);
|
||||
}
|
||||
try {
|
||||
file.open('w'); check();
|
||||
file.encoding = 'UTF-8'; check();
|
||||
file.write(text); check();
|
||||
} finally {
|
||||
file.close(); check();
|
||||
}
|
||||
}
|
||||
|
||||
function readSettingsFile() {
|
||||
try {
|
||||
return JSON.parse(readTextFile(settingsFilePath));
|
||||
} catch (e) {
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
function writeSettingsFile(settings) {
|
||||
try {
|
||||
writeTextFile(settingsFilePath, JSON.stringify(settings, null, 2));
|
||||
} catch (e) {
|
||||
alert('Error persisting settings. ' + e.message);
|
||||
}
|
||||
}
|
||||
|
||||
var osIsWindows = (system.osName || $.os).match(/windows/i);
|
||||
|
||||
// Depending on the operating system, the syntax for escaping command-line arguments differs.
|
||||
function cliEscape(argument) {
|
||||
return osIsWindows
|
||||
? '"' + argument + '"'
|
||||
: "'" + argument.replace(/'/g, "'\\''") + "'";
|
||||
}
|
||||
|
||||
function exec(command) {
|
||||
return system.callSystem(command);
|
||||
}
|
||||
|
||||
function execInWindow(command) {
|
||||
if (osIsWindows) {
|
||||
system.callSystem('cmd /C "' + command + '"');
|
||||
} else {
|
||||
// I didn't think it could be so complicated on OS X to open a new Terminal window,
|
||||
// execute a command, then close the Terminal window.
|
||||
// If you know a better solution, let me know!
|
||||
var escapedCommand = command.replace(/"/g, '\\"');
|
||||
var appleScript = '\
|
||||
tell application "Terminal" \
|
||||
-- Quit terminal \
|
||||
-- Yes, that\'s undesirable if there was an open window before. \
|
||||
-- But all solutions I could find were at least as hacky. \
|
||||
quit \
|
||||
-- Open terminal \
|
||||
activate \
|
||||
-- Run command in new tab \
|
||||
set newTab to do script ("' + escapedCommand + '") \
|
||||
-- Wait until command is done \
|
||||
tell newTab \
|
||||
repeat while busy \
|
||||
delay 0.1 \
|
||||
end repeat \
|
||||
end tell \
|
||||
quit \
|
||||
end tell';
|
||||
exec('osascript -e ' + cliEscape(appleScript));
|
||||
}
|
||||
}
|
||||
|
||||
var rhubarbPath = osIsWindows ? 'rhubarb.exe' : '/usr/local/bin/rhubarb';
|
||||
|
||||
// ExtendScript's resource strings are a pain to write.
|
||||
// This function allows them to be written in JSON notation, then converts them into the required
|
||||
// format.
|
||||
// For instance, this string: '{ "__type__": "StaticText", "text": "Hello world" }'
|
||||
// is converted to this: 'StaticText { "text": "Hello world" }'.
|
||||
// This code relies on the fact that, contrary to the language specification, all major JavaScript
|
||||
// implementations keep object properties in insertion order.
|
||||
function createResourceString(tree) {
|
||||
var result = JSON.stringify(tree, null, 2);
|
||||
result = result.replace(/(\{\s*)"__type__":\s*"(\w+)",?\s*/g, '$2 $1');
|
||||
return result;
|
||||
}
|
||||
|
||||
// Object containing functions to create control description trees.
|
||||
// For instance, `controls.StaticText({ text: 'Hello world' })`
|
||||
// returns `{ __type__: StaticText, text: 'Hello world' }`.
|
||||
var controlFunctions = (function() {
|
||||
var controlTypes = [
|
||||
// Strangely, 'dialog' and 'palette' need to start with a lower-case character
|
||||
['Dialog', 'dialog'], ['Palette', 'palette'],
|
||||
'Panel', 'Group', 'TabbedPanel', 'Tab', 'Button', 'IconButton', 'Image', 'StaticText',
|
||||
'EditText', 'Checkbox', 'RadioButton', 'Progressbar', 'Slider', 'Scrollbar', 'ListBox',
|
||||
'DropDownList', 'TreeView', 'ListItem', 'FlashPlayer'
|
||||
];
|
||||
var result = {};
|
||||
controlTypes.forEach(function(type){
|
||||
var isArray = Array.isArray(type);
|
||||
var key = isArray ? type[0] : type;
|
||||
var value = isArray ? type[1] : type;
|
||||
result[key] = function(options) {
|
||||
return Object.assign({ __type__: value }, options);
|
||||
};
|
||||
});
|
||||
return result;
|
||||
})();
|
||||
|
||||
// Returns the path of a project item within the project
|
||||
function getItemPath(item) {
|
||||
if (item === app.project.rootFolder) {
|
||||
return '/';
|
||||
}
|
||||
|
||||
var result = item.name;
|
||||
while (item.parentFolder !== app.project.rootFolder) {
|
||||
result = item.parentFolder.name + ' / ' + result;
|
||||
item = item.parentFolder;
|
||||
}
|
||||
return '/ ' + result;
|
||||
}
|
||||
|
||||
// Selects the item within an item control whose text matches the specified text.
|
||||
// If no such item exists, selects the first item, if present.
|
||||
function selectByTextOrFirst(itemControl, text) {
|
||||
var targetItem = toArray(itemControl.items).find(function(item) {
|
||||
return item.text === text;
|
||||
});
|
||||
if (!targetItem && itemControl.items.length) {
|
||||
targetItem = itemControl.items[0];
|
||||
}
|
||||
if (targetItem) {
|
||||
itemControl.selection = targetItem;
|
||||
}
|
||||
}
|
||||
|
||||
function getAudioFileProjectItems() {
|
||||
var result = toArrayBase1(app.project.items).filter(function(item) {
|
||||
var isAudioFootage = item instanceof FootageItem && item.hasAudio && !item.hasVideo;
|
||||
return isAudioFootage;
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
var mouthShapeNames = 'ABCDEFGHX'.split('');
|
||||
var basicMouthShapeCount = 6;
|
||||
var mouthShapeCount = mouthShapeNames.length;
|
||||
var basicMouthShapeNames = mouthShapeNames.slice(0, basicMouthShapeCount);
|
||||
var extendedMouthShapeNames = mouthShapeNames.slice(basicMouthShapeCount);
|
||||
|
||||
function getMouthCompHelpTip() {
|
||||
var result = 'A composition containing the mouth shapes, one drawing per frame. They must be '
|
||||
+ 'arranged as follows:\n';
|
||||
mouthShapeNames.forEach(function(mouthShapeName, i) {
|
||||
var isOptional = i >= basicMouthShapeCount;
|
||||
result += '\n00:' + pad(i, 2) + '\t' + mouthShapeName + (isOptional ? ' (optional)' : '');
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
function createExtendedShapeCheckboxes() {
|
||||
var result = {};
|
||||
extendedMouthShapeNames.forEach(function(shapeName) {
|
||||
result[shapeName.toLowerCase()] = controlFunctions.Checkbox({
|
||||
text: shapeName,
|
||||
helpTip: 'Controls whether to use the optional ' + shapeName + ' shape.'
|
||||
});
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
function createDialogWindow() {
|
||||
var resourceString;
|
||||
with (controlFunctions) {
|
||||
resourceString = createResourceString(
|
||||
Dialog({
|
||||
text: appName,
|
||||
settings: Group({
|
||||
orientation: 'column',
|
||||
alignChildren: ['left', 'top'],
|
||||
audioFile: Group({
|
||||
label: StaticText({
|
||||
text: 'Audio file:',
|
||||
// If I don't explicitly activate a control, After Effects has trouble
|
||||
// with keyboard focus, so I can't type in the text edit field below.
|
||||
active: true
|
||||
}),
|
||||
value: DropDownList({
|
||||
helpTip: 'An audio file containing recorded dialog.\n'
|
||||
+ 'This field shows all audio files that exist in '
|
||||
+ 'your After Effects project.'
|
||||
})
|
||||
}),
|
||||
recognizer: Group({
|
||||
label: StaticText({ text: 'Recognizer:' }),
|
||||
value: DropDownList({
|
||||
helpTip: 'The dialog recognizer.'
|
||||
})
|
||||
}),
|
||||
dialogText: Group({
|
||||
label: StaticText({ text: 'Dialog text (optional):' }),
|
||||
value: EditText({
|
||||
properties: { multiline: true },
|
||||
characters: 60,
|
||||
minimumSize: [0, 100],
|
||||
helpTip: 'For better animation results, you can specify the text of '
|
||||
+ 'the recording here. This field is optional.'
|
||||
})
|
||||
}),
|
||||
mouthComp: Group({
|
||||
label: StaticText({ text: 'Mouth composition:' }),
|
||||
value: DropDownList({ helpTip: getMouthCompHelpTip() })
|
||||
}),
|
||||
extendedMouthShapes: Group(
|
||||
Object.assign(
|
||||
{ label: StaticText({ text: 'Extended mouth shapes:' }) },
|
||||
createExtendedShapeCheckboxes()
|
||||
)
|
||||
),
|
||||
targetFolder: Group({
|
||||
label: StaticText({ text: 'Target folder:' }),
|
||||
value: DropDownList({
|
||||
helpTip: 'The project folder in which to create the animation '
|
||||
+ 'composition. The composition will be named like the audio file.'
|
||||
})
|
||||
}),
|
||||
frameRate: Group({
|
||||
label: StaticText({ text: 'Frame rate:' }),
|
||||
value: EditText({
|
||||
characters: 8,
|
||||
helpTip: 'The frame rate for the animation.'
|
||||
}),
|
||||
auto: Checkbox({
|
||||
text: 'From mouth composition',
|
||||
helpTip: 'If checked, the animation will use the same frame rate as '
|
||||
+ 'the mouth composition.'
|
||||
})
|
||||
})
|
||||
}),
|
||||
separator: Group({ preferredSize: ['', 3] }),
|
||||
buttons: Group({
|
||||
alignment: 'right',
|
||||
animate: Button({
|
||||
properties: { name: 'ok' },
|
||||
text: 'Animate'
|
||||
}),
|
||||
cancel: Button({
|
||||
properties: { name: 'cancel' },
|
||||
text: 'Cancel'
|
||||
})
|
||||
})
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
// Create window and child controls
|
||||
var window = new Window(resourceString);
|
||||
var controls = {
|
||||
audioFile: window.settings.audioFile.value,
|
||||
dialogText: window.settings.dialogText.value,
|
||||
recognizer: window.settings.recognizer.value,
|
||||
mouthComp: window.settings.mouthComp.value,
|
||||
targetFolder: window.settings.targetFolder.value,
|
||||
frameRate: window.settings.frameRate.value,
|
||||
autoFrameRate: window.settings.frameRate.auto,
|
||||
animateButton: window.buttons.animate,
|
||||
cancelButton: window.buttons.cancel
|
||||
};
|
||||
extendedMouthShapeNames.forEach(function(shapeName) {
|
||||
controls['mouthShape' + shapeName] =
|
||||
window.settings.extendedMouthShapes[shapeName.toLowerCase()];
|
||||
});
|
||||
|
||||
// Add audio file options
|
||||
getAudioFileProjectItems().forEach(function(projectItem) {
|
||||
var listItem = controls.audioFile.add('item', getItemPath(projectItem));
|
||||
listItem.projectItem = projectItem;
|
||||
});
|
||||
|
||||
// Add recognizer options
|
||||
const recognizerOptions = [
|
||||
{ text: 'PocketSphinx (use for English recordings)', value: 'pocketSphinx' },
|
||||
{ text: 'Phonetic (use for non-English recordings)', value: 'phonetic' }
|
||||
];
|
||||
recognizerOptions.forEach(function(option) {
|
||||
var listItem = controls.recognizer.add('item', option.text);
|
||||
listItem.value = option.value;
|
||||
});
|
||||
|
||||
// Add mouth composition options
|
||||
var comps = toArrayBase1(app.project.items).filter(function (item) {
|
||||
return item instanceof CompItem;
|
||||
});
|
||||
comps.forEach(function(projectItem) {
|
||||
var listItem = controls.mouthComp.add('item', getItemPath(projectItem));
|
||||
listItem.projectItem = projectItem;
|
||||
});
|
||||
|
||||
// Add target folder options
|
||||
var projectFolders = toArrayBase1(app.project.items).filter(function (item) {
|
||||
return item instanceof FolderItem;
|
||||
});
|
||||
projectFolders.unshift(app.project.rootFolder);
|
||||
projectFolders.forEach(function(projectFolder) {
|
||||
var listItem = controls.targetFolder.add('item', getItemPath(projectFolder));
|
||||
listItem.projectItem = projectFolder;
|
||||
});
|
||||
|
||||
// Load persisted settings
|
||||
var settings = readSettingsFile();
|
||||
selectByTextOrFirst(controls.audioFile, settings.audioFile);
|
||||
controls.dialogText.text = settings.dialogText || '';
|
||||
selectByTextOrFirst(controls.recognizer, settings.recognizer);
|
||||
selectByTextOrFirst(controls.mouthComp, settings.mouthComp);
|
||||
extendedMouthShapeNames.forEach(function(shapeName) {
|
||||
controls['mouthShape' + shapeName].value =
|
||||
(settings.extendedMouthShapes || {})[shapeName.toLowerCase()];
|
||||
});
|
||||
selectByTextOrFirst(controls.targetFolder, settings.targetFolder);
|
||||
controls.frameRate.text = settings.frameRate || '';
|
||||
controls.autoFrameRate.value = settings.autoFrameRate;
|
||||
|
||||
// Align controls
|
||||
window.onShow = function() {
|
||||
// Give uniform width to all labels
|
||||
var groups = toArray(window.settings.children);
|
||||
var labelWidths = groups.map(function(group) { return group.children[0].size.width; });
|
||||
var maxLabelWidth = Math.max.apply(Math, labelWidths);
|
||||
groups.forEach(function (group) {
|
||||
group.children[0].size.width = maxLabelWidth;
|
||||
});
|
||||
|
||||
// Give uniform width to inputs
|
||||
var valueWidths = groups.map(function(group) {
|
||||
return last(group.children).bounds.right - group.children[1].bounds.left;
|
||||
});
|
||||
var maxValueWidth = Math.max.apply(Math, valueWidths);
|
||||
groups.forEach(function (group) {
|
||||
var multipleControls = group.children.length > 2;
|
||||
if (!multipleControls) {
|
||||
group.children[1].size.width = maxValueWidth;
|
||||
}
|
||||
});
|
||||
|
||||
window.layout.layout(true);
|
||||
};
|
||||
|
||||
var updating = false;
|
||||
|
||||
function update() {
|
||||
if (updating) return;
|
||||
|
||||
updating = true;
|
||||
try {
|
||||
// Handle auto frame rate
|
||||
var autoFrameRate = controls.autoFrameRate.value;
|
||||
controls.frameRate.enabled = !autoFrameRate;
|
||||
if (autoFrameRate) {
|
||||
// Take frame rate from mouth comp
|
||||
var mouthComp = (controls.mouthComp.selection || {}).projectItem;
|
||||
controls.frameRate.text = mouthComp ? mouthComp.frameRate : '';
|
||||
} else {
|
||||
// Sanitize frame rate
|
||||
var sanitizedFrameRate = controls.frameRate.text.match(/\d*\.?\d*/)[0];
|
||||
if (sanitizedFrameRate !== controls.frameRate.text) {
|
||||
controls.frameRate.text = sanitizedFrameRate;
|
||||
}
|
||||
}
|
||||
|
||||
// Store settings
|
||||
var settings = {
|
||||
audioFile: (controls.audioFile.selection || {}).text,
|
||||
recognizer: (controls.recognizer.selection || {}).text,
|
||||
dialogText: controls.dialogText.text,
|
||||
mouthComp: (controls.mouthComp.selection || {}).text,
|
||||
extendedMouthShapes: {},
|
||||
targetFolder: (controls.targetFolder.selection || {}).text,
|
||||
frameRate: Number(controls.frameRate.text),
|
||||
autoFrameRate: controls.autoFrameRate.value
|
||||
};
|
||||
extendedMouthShapeNames.forEach(function(shapeName) {
|
||||
settings.extendedMouthShapes[shapeName.toLowerCase()] =
|
||||
controls['mouthShape' + shapeName].value;
|
||||
});
|
||||
writeSettingsFile(settings);
|
||||
} finally {
|
||||
updating = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Validate user input. Possible return values:
|
||||
// * Non-empty string: Validation failed. Show error message.
|
||||
// * Empty string: Validation failed. Don't show error message.
|
||||
// * Undefined: Validation succeeded.
|
||||
function validate() {
|
||||
// Check input values
|
||||
if (!controls.audioFile.selection) return 'Please select an audio file.';
|
||||
if (!controls.mouthComp.selection) return 'Please select a mouth composition.';
|
||||
if (!controls.targetFolder.selection) return 'Please select a target folder.';
|
||||
if (Number(controls.frameRate.text) < 12) {
|
||||
return 'Please enter a frame rate of at least 12 fps.';
|
||||
}
|
||||
|
||||
// Check mouth shape visibility
|
||||
var comp = controls.mouthComp.selection.projectItem;
|
||||
for (var i = 0; i < mouthShapeCount; i++) {
|
||||
var shapeName = mouthShapeNames[i];
|
||||
var required = i < basicMouthShapeCount || controls['mouthShape' + shapeName].value;
|
||||
if (required && !isFrameVisible(comp, i)) {
|
||||
return 'The mouth comp does not seem to contain an image for shape '
|
||||
+ shapeName + ' at frame ' + i + '.';
|
||||
}
|
||||
}
|
||||
|
||||
if (!comp.preserveNestedFrameRate) {
|
||||
var fix = Window.confirm(
|
||||
'The setting "Preserve frame rate when nested or in render queue" is not active '
|
||||
+ 'for the mouth composition. This can result in incorrect animation.\n\n'
|
||||
+ 'Activate this setting now?',
|
||||
false,
|
||||
'Fix composition setting?');
|
||||
if (fix) {
|
||||
app.beginUndoGroup(appName + ': Mouth composition setting');
|
||||
comp.preserveNestedFrameRate = true;
|
||||
app.endUndoGroup();
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
// Check for correct Rhubarb version
|
||||
var version = exec(rhubarbPath + ' --version') || '';
|
||||
var match = version.match(/Rhubarb Lip Sync version ((\d+)\.(\d+).(\d+)(-[0-9A-Za-z-.]+)?)/);
|
||||
if (!match) {
|
||||
var instructions = osIsWindows
|
||||
? 'Make sure your PATH environment variable contains the ' + appName + ' '
|
||||
+ 'application directory.'
|
||||
: 'Make sure you have created this file as a symbolic link to the ' + appName + ' '
|
||||
+ 'executable (rhubarb).';
|
||||
return 'Cannot find executable file "' + rhubarbPath + '". \n' + instructions;
|
||||
}
|
||||
var versionString = match[1];
|
||||
var major = Number(match[2]);
|
||||
var minor = Number(match[3]);
|
||||
var requiredMajor = 1;
|
||||
var minRequiredMinor = 9;
|
||||
if (major != requiredMajor || minor < minRequiredMinor) {
|
||||
return 'This script requires ' + appName + ' ' + requiredMajor + '.' + minRequiredMinor
|
||||
+ '.0 or a later ' + requiredMajor + '.x version. '
|
||||
+ 'Your installed version is ' + versionString + ', which is not compatible.';
|
||||
}
|
||||
}
|
||||
|
||||
function generateMouthCues(audioFileFootage, recognizer, dialogText, mouthComp, extendedMouthShapeNames,
|
||||
targetProjectFolder, frameRate)
|
||||
{
|
||||
var basePath = Folder.temp.fsName + '/' + createGuid();
|
||||
var dialogFile = new File(basePath + '.txt');
|
||||
var logFile = new File(basePath + '.log');
|
||||
var jsonFile = new File(basePath + '.json');
|
||||
try {
|
||||
// Create text file containing dialog
|
||||
writeTextFile(dialogFile, dialogText);
|
||||
|
||||
// Create command line
|
||||
var commandLine = rhubarbPath
|
||||
+ ' --dialogFile ' + cliEscape(dialogFile.fsName)
|
||||
+ ' --recognizer ' + recognizer
|
||||
+ ' --exportFormat json'
|
||||
+ ' --extendedShapes ' + cliEscape(extendedMouthShapeNames.join(''))
|
||||
+ ' --logFile ' + cliEscape(logFile.fsName)
|
||||
+ ' --logLevel fatal'
|
||||
+ ' --output ' + cliEscape(jsonFile.fsName)
|
||||
+ ' ' + cliEscape(audioFileFootage.file.fsName);
|
||||
|
||||
// Run Rhubarb
|
||||
execInWindow(commandLine);
|
||||
|
||||
// Check log for fatal errors
|
||||
if (logFile.exists) {
|
||||
var fatalLog = readTextFile(logFile).trim();
|
||||
if (fatalLog) {
|
||||
// Try to extract only the actual error message
|
||||
var match = fatalLog.match(/\[Fatal\] ([\s\S]*)/);
|
||||
var message = match ? match[1] : fatalLog;
|
||||
throw new Error('Error running ' + appName + '.\n' + message);
|
||||
}
|
||||
}
|
||||
|
||||
var result;
|
||||
try {
|
||||
result = JSON.parse(readTextFile(jsonFile));
|
||||
} catch (e) {
|
||||
throw new Error('No animation result. Animation was probably canceled.');
|
||||
}
|
||||
return result;
|
||||
} finally {
|
||||
dialogFile.remove();
|
||||
logFile.remove();
|
||||
jsonFile.remove();
|
||||
}
|
||||
}
|
||||
|
||||
function animateMouthCues(mouthCues, audioFileFootage, mouthComp, targetProjectFolder,
|
||||
frameRate)
|
||||
{
|
||||
// Find an unconflicting comp name
|
||||
// ... strip extension, if present
|
||||
var baseName = audioFileFootage.name.match(/^(.*?)(\..*)?$/i)[1];
|
||||
var compName = baseName;
|
||||
// ... add numeric suffix, if needed
|
||||
var existingItems = toArrayBase1(targetProjectFolder.items);
|
||||
var counter = 1;
|
||||
while (existingItems.some(function(item) { return item.name === compName; })) {
|
||||
counter++;
|
||||
compName = baseName + ' ' + counter;
|
||||
}
|
||||
|
||||
// Create new comp
|
||||
var comp = targetProjectFolder.items.addComp(compName, mouthComp.width, mouthComp.height,
|
||||
mouthComp.pixelAspect, audioFileFootage.duration, frameRate);
|
||||
|
||||
// Show new comp
|
||||
comp.openInViewer();
|
||||
|
||||
// Add audio layer
|
||||
comp.layers.add(audioFileFootage);
|
||||
|
||||
// Add mouth layer
|
||||
var mouthLayer = comp.layers.add(mouthComp);
|
||||
mouthLayer.timeRemapEnabled = true;
|
||||
mouthLayer.outPoint = comp.duration;
|
||||
|
||||
// Animate mouth layer
|
||||
var timeRemap = mouthLayer['Time Remap'];
|
||||
// Enabling time remapping automatically adds two keys. Remove the second.
|
||||
timeRemap.removeKey(2);
|
||||
mouthCues.mouthCues.forEach(function(mouthCue) {
|
||||
// Round down keyframe time. In animation, earlier is better than later.
|
||||
// Set keyframe time to *just before* the exact frame to prevent rounding errors
|
||||
var frame = Math.floor(timeToFrame(mouthCue.start, comp));
|
||||
var time = frame !== 0 ? frameToTime(frame - epsilon, comp) : 0;
|
||||
// Set remapped time to *just after* the exact frame to prevent rounding errors
|
||||
var mouthCompFrame = mouthShapeNames.indexOf(mouthCue.value);
|
||||
var remappedTime = frameToTime(mouthCompFrame + epsilon, mouthComp);
|
||||
timeRemap.setValueAtTime(time, remappedTime);
|
||||
});
|
||||
for (var i = 1; i <= timeRemap.numKeys; i++) {
|
||||
timeRemap.setInterpolationTypeAtKey(i, KeyframeInterpolationType.HOLD);
|
||||
}
|
||||
}
|
||||
|
||||
function animate(audioFileFootage, recognizer, dialogText, mouthComp, extendedMouthShapeNames,
|
||||
targetProjectFolder, frameRate)
|
||||
{
|
||||
try {
|
||||
var mouthCues = generateMouthCues(audioFileFootage, recognizer, dialogText, mouthComp,
|
||||
extendedMouthShapeNames, targetProjectFolder, frameRate);
|
||||
|
||||
app.beginUndoGroup(appName + ': Animation');
|
||||
animateMouthCues(mouthCues, audioFileFootage, mouthComp, targetProjectFolder,
|
||||
frameRate);
|
||||
app.endUndoGroup();
|
||||
} catch (e) {
|
||||
Window.alert(e.message, appName, true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Handle changes
|
||||
update();
|
||||
controls.audioFile.onChange = update;
|
||||
controls.recognizer.onChange = update;
|
||||
controls.dialogText.onChanging = update;
|
||||
controls.mouthComp.onChange = update;
|
||||
extendedMouthShapeNames.forEach(function(shapeName) {
|
||||
controls['mouthShape' + shapeName].onClick = update;
|
||||
});
|
||||
controls.targetFolder.onChange = update;
|
||||
controls.frameRate.onChanging = update;
|
||||
controls.autoFrameRate.onClick = update;
|
||||
|
||||
// Handle animation
|
||||
controls.animateButton.onClick = function() {
|
||||
var validationError = validate();
|
||||
if (typeof validationError === 'string') {
|
||||
if (validationError) {
|
||||
Window.alert(validationError, appName, true);
|
||||
}
|
||||
} else {
|
||||
window.close();
|
||||
animate(
|
||||
controls.audioFile.selection.projectItem,
|
||||
controls.recognizer.selection.value,
|
||||
controls.dialogText.text || '',
|
||||
controls.mouthComp.selection.projectItem,
|
||||
extendedMouthShapeNames.filter(function(shapeName) {
|
||||
return controls['mouthShape' + shapeName].value;
|
||||
}),
|
||||
controls.targetFolder.selection.projectItem,
|
||||
Number(controls.frameRate.text)
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
// Handle cancelation
|
||||
controls.cancelButton.onClick = function() {
|
||||
window.close();
|
||||
};
|
||||
|
||||
return window;
|
||||
}
|
||||
|
||||
function checkPreconditions() {
|
||||
if (!canWriteFiles()) {
|
||||
Window.alert('This script requires file system access.\n\n'
|
||||
+ 'Please enable Preferences > General > Allow Scripts to Write Files and Access Network.',
|
||||
appName, true);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
if (checkPreconditions()) {
|
||||
createDialogWindow().show();
|
||||
}
|
|
@ -1,8 +0,0 @@
|
|||
# Directory is generated when importing Gradle project
|
||||
/.idea/
|
||||
|
||||
*.iml
|
||||
/.gradle/
|
||||
/build/
|
||||
/out/
|
||||
/tmp/
|
|
@ -1,18 +0,0 @@
|
|||
cmake_minimum_required(VERSION 3.24)
|
||||
|
||||
add_custom_target(
|
||||
rhubarbForSpine ALL
|
||||
"./gradlew" "build"
|
||||
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
|
||||
COMMENT "Building Rhubarb for Spine through Gradle."
|
||||
)
|
||||
|
||||
install(
|
||||
DIRECTORY "build/libs/"
|
||||
DESTINATION "extras/EsotericSoftwareSpine"
|
||||
)
|
||||
|
||||
install(
|
||||
FILES README.adoc
|
||||
DESTINATION "extras/EsotericSoftwareSpine"
|
||||
)
|
|
@ -1,51 +0,0 @@
|
|||
= Rhubarb Lip Sync for Spine
|
||||
|
||||
Rhubarb Lip Sync for Spine is a graphical tool that allows you to import a Spine project, perform automatic lip sync, then re-import the result into Spine.
|
||||
|
||||
image:../../img/spine.png[image]
|
||||
|
||||
== Installation
|
||||
|
||||
https://github.com/DanielSWolf/rhubarb-lip-sync/releases[Download Rhubarb Lip Sync] for your platform, then extract the archive file in a directory on your computer. You’ll find Rhubarb Lip Sync for Spine in the directory `extras/EsotericSoftwareSpine`.
|
||||
|
||||
To create lip sync animation, you’ll need Spine 3.7 or better.
|
||||
|
||||
== Preparing your Spine project
|
||||
|
||||
You can add lip-sync’ed dialog to any Spine skeleton. First, make sure it has a dedicated slot for its mouth. I’m naming the slot `mouth`, but you can choose any name you like.
|
||||
|
||||
Next, add image attachments to the mouth slot, one attachment per mouth shape. For details about the expected mouth shapes, https://github.com/DanielSWolf/rhubarb-lip-sync#user-content-mouth-shapes[refer to the Rhubarb Lip Sync documentation]. You’ll need at least the six basic mouth shapes A-F. If you add any of the extended mouth shapes, Rhubarb will automatically use them to create better-looking animation. I’m naming the attachments `mouth_a`, `mouth_b`, `mouth_c`, etc. You can choose any naming scheme you like and Rhubarb will detect it, as long as it’s consistent (including upper and lower case). For instance, `A-Lips`, `B-Lips`, `C-Lips`, … is fine; `mouth a`, `mouth B`, `Mouth-C`, … isn’t.
|
||||
|
||||
Finally, you need to add some audio events, that is, events with associated audio path. These audio events will be the basis for animation.
|
||||
|
||||
_Optionally_, you can enter the dialog text into each event’s string property. If you do, this will help Rhubarb to create more reliable animation. But don’t worry: If you don’t enter the dialog text or if you already use the string property for something else, the results will normally still be good. For more information, see the https://github.com/DanielSWolf/rhubarb-lip-sync#user-content-options[documentation on the `--dialogFile` option].
|
||||
|
||||
== Exporting a JSON file
|
||||
|
||||
Export the skeleton(s) by selecting _Spine_ | _Export…_.
|
||||
|
||||
Choose JSON format. Make sure the output folder is the same folder that contains your `.spine` file, or Rhubarb won’t be able to locate your audio files. Also, make sure to check the _Nonessential data_ checkbox. Despite the name, Rhubarb needs this information. Finally, click _Export_. This will create a file with the same name as your skeleton and the extension `.json`.
|
||||
|
||||
== Performing lip sync
|
||||
|
||||
Open Rhubarb Lip Sync for Spine by double-clicking `rhubarb-for-spine.jar` in the Windows Explorer (Windows) or Finder (OS X). Specify the input settings as follows:
|
||||
|
||||
* *Spine JSON file:* This is the file you just exported. The most convenient way to fill this field is to drag-and-drop the JSON file anywhere onto the application window. Alternatively, you can use the `…' button or manually enter the file path.
|
||||
* *Mouth slot:* This tells Rhubarb which of your Spine slots represents the mouth. The dropdown shows all the slots on your skeleton. If your mouth slot contains the word `mouth', Rhubarb will automatically select it for you. Otherwise, select it manually.
|
||||
* *Mouth naming:* Rhubarb will automatically detect the naming scheme you used for your mouth attachments and display it here. This is for your information only.
|
||||
* *Mouth shapes:* This group of checkboxes tells you which mouth shapes were found. At least the basic mouth shapes A-F need to be present. This, too, is informational only.
|
||||
* *Animation naming:* When animating, Rhubarb will create new Spine animations based on your existing audio events. The two text fields allow you to fine-tune the animation naming.
|
||||
|
||||
At the bottom of the window, there is a grid with one row per audio event. To animate any audio event, click the corresponding _Animate_ button. Animation jobs are queued, so the next animation job starts once the previous one has finished.
|
||||
|
||||
Each time an animation job finishes, the JSON file is updated with the new animation. When you are done animating, you can close Rhubarb Lip Sync for Spine.
|
||||
|
||||
== Importing the animated results
|
||||
|
||||
Rhubarb Lip Sync for Spine has only changed the exported `.json` file, not your original `.spine` project file. To do that, switch back to Spine.
|
||||
|
||||
Delete your skeleton by selecting it in the hierarchy tree and clicking the _Delete_ button. If you don’t, Spine will complain in the next step that a skeleton with this name already exists.
|
||||
|
||||
Select _Spine_ | _Import Data…_. Make sure the JSON file path is correct. Also make sure the checkbox _New project_ is *not checked*, or else Spine will start confusing paths. Click OK to re-import the skeleton from the JSON file.
|
||||
|
||||
If everything went well, you will now have a number of new, lip-sync’ed animations on your skeleton!
|
|
@ -1,57 +0,0 @@
|
|||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||
import java.io.File
|
||||
|
||||
plugins {
|
||||
kotlin("jvm") version "1.6.0"
|
||||
id("org.openjfx.javafxplugin") version "0.0.10"
|
||||
}
|
||||
|
||||
fun getVersion(): String {
|
||||
// Dynamically read version from CMake file
|
||||
val file = File(rootDir.parentFile.parentFile, "appInfo.cmake")
|
||||
val text = file.readText()
|
||||
val major = Regex("""appVersionMajor\s+(\d+)""").find(text)!!.groupValues[1]
|
||||
val minor = Regex("""appVersionMinor\s+(\d+)""").find(text)!!.groupValues[1]
|
||||
val patch = Regex("""appVersionPatch\s+(\d+)""").find(text)!!.groupValues[1]
|
||||
val suffix = Regex("""appVersionSuffix\s+"(.*?)"""").find(text)!!.groupValues[1]
|
||||
return "$major.$minor.$patch$suffix"
|
||||
}
|
||||
|
||||
group = "com.rhubarb_lip_sync"
|
||||
version = getVersion()
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
jcenter()
|
||||
maven("https://oss.sonatype.org/content/repositories/snapshots")
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.0")
|
||||
implementation("com.beust:klaxon:5.5")
|
||||
implementation("org.apache.commons:commons-lang3:3.12.0")
|
||||
implementation("no.tornado:tornadofx:2.0.0-SNAPSHOT")
|
||||
testImplementation("org.junit.jupiter:junit-jupiter:5.8.1")
|
||||
testImplementation("org.assertj:assertj-core:3.21.0")
|
||||
}
|
||||
|
||||
javafx {
|
||||
version = "15.0.1"
|
||||
modules("javafx.controls")
|
||||
}
|
||||
|
||||
tasks.withType<KotlinCompile> {
|
||||
kotlinOptions.jvmTarget = "1.8"
|
||||
}
|
||||
|
||||
tasks.test {
|
||||
useJUnitPlatform()
|
||||
}
|
||||
|
||||
tasks.withType<Jar> {
|
||||
manifest {
|
||||
attributes("Main-Class" to "com.rhubarb_lip_sync.rhubarb_for_spine.MainKt")
|
||||
}
|
||||
|
||||
from(configurations.compileClasspath.get().map { if (it.isDirectory) it else zipTree(it) })
|
||||
}
|
|
@ -1,5 +0,0 @@
|
|||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.9-all.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
|
@ -1,172 +0,0 @@
|
|||
#!/usr/bin/env sh
|
||||
|
||||
##############################################################################
|
||||
##
|
||||
## Gradle start up script for UN*X
|
||||
##
|
||||
##############################################################################
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
# Resolve links: $0 may be a link
|
||||
PRG="$0"
|
||||
# Need this for relative symlinks.
|
||||
while [ -h "$PRG" ] ; do
|
||||
ls=`ls -ld "$PRG"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
PRG="$link"
|
||||
else
|
||||
PRG=`dirname "$PRG"`"/$link"
|
||||
fi
|
||||
done
|
||||
SAVED="`pwd`"
|
||||
cd "`dirname \"$PRG\"`/" >/dev/null
|
||||
APP_HOME="`pwd -P`"
|
||||
cd "$SAVED" >/dev/null
|
||||
|
||||
APP_NAME="Gradle"
|
||||
APP_BASE_NAME=`basename "$0"`
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS=""
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD="maximum"
|
||||
|
||||
warn () {
|
||||
echo "$*"
|
||||
}
|
||||
|
||||
die () {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
}
|
||||
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
nonstop=false
|
||||
case "`uname`" in
|
||||
CYGWIN* )
|
||||
cygwin=true
|
||||
;;
|
||||
Darwin* )
|
||||
darwin=true
|
||||
;;
|
||||
MINGW* )
|
||||
msys=true
|
||||
;;
|
||||
NONSTOP* )
|
||||
nonstop=true
|
||||
;;
|
||||
esac
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||
else
|
||||
JAVACMD="$JAVA_HOME/bin/java"
|
||||
fi
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD="java"
|
||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
|
||||
MAX_FD_LIMIT=`ulimit -H -n`
|
||||
if [ $? -eq 0 ] ; then
|
||||
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
||||
MAX_FD="$MAX_FD_LIMIT"
|
||||
fi
|
||||
ulimit -n $MAX_FD
|
||||
if [ $? -ne 0 ] ; then
|
||||
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
||||
fi
|
||||
else
|
||||
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
||||
fi
|
||||
fi
|
||||
|
||||
# For Darwin, add options to specify how the application appears in the dock
|
||||
if $darwin; then
|
||||
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
||||
fi
|
||||
|
||||
# For Cygwin, switch paths to Windows format before running java
|
||||
if $cygwin ; then
|
||||
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||
JAVACMD=`cygpath --unix "$JAVACMD"`
|
||||
|
||||
# We build the pattern for arguments to be converted via cygpath
|
||||
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
||||
SEP=""
|
||||
for dir in $ROOTDIRSRAW ; do
|
||||
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
||||
SEP="|"
|
||||
done
|
||||
OURCYGPATTERN="(^($ROOTDIRS))"
|
||||
# Add a user-defined pattern to the cygpath arguments
|
||||
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
||||
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
||||
fi
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
i=0
|
||||
for arg in "$@" ; do
|
||||
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
||||
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
||||
|
||||
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
||||
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
||||
else
|
||||
eval `echo args$i`="\"$arg\""
|
||||
fi
|
||||
i=$((i+1))
|
||||
done
|
||||
case $i in
|
||||
(0) set -- ;;
|
||||
(1) set -- "$args0" ;;
|
||||
(2) set -- "$args0" "$args1" ;;
|
||||
(3) set -- "$args0" "$args1" "$args2" ;;
|
||||
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
||||
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
||||
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
||||
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
||||
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
||||
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
# Escape application args
|
||||
save () {
|
||||
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
||||
echo " "
|
||||
}
|
||||
APP_ARGS=$(save "$@")
|
||||
|
||||
# Collect all arguments for the java command, following the shell quoting and substitution rules
|
||||
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
|
||||
|
||||
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
|
||||
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
|
||||
cd "$(dirname "$0")"
|
||||
fi
|
||||
|
||||
exec "$JAVACMD" "$@"
|
|
@ -1,84 +0,0 @@
|
|||
@if "%DEBUG%" == "" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%" == "" set DIRNAME=.
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS=
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if "%ERRORLEVEL%" == "0" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:init
|
||||
@rem Get command-line arguments, handling Windows variants
|
||||
|
||||
if not "%OS%" == "Windows_NT" goto win9xME_args
|
||||
|
||||
:win9xME_args
|
||||
@rem Slurp the command line arguments.
|
||||
set CMD_LINE_ARGS=
|
||||
set _SKIP=2
|
||||
|
||||
:win9xME_args_slurp
|
||||
if "x%~1" == "x" goto execute
|
||||
|
||||
set CMD_LINE_ARGS=%*
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||
exit /b 1
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
|
@ -1 +0,0 @@
|
|||
rootProject.name = "rhubarb-for-spine"
|
|
@ -1,125 +0,0 @@
|
|||
package com.rhubarb_lip_sync.rhubarb_for_spine
|
||||
|
||||
import javafx.beans.binding.BooleanBinding
|
||||
import javafx.beans.property.SimpleBooleanProperty
|
||||
import javafx.beans.property.SimpleListProperty
|
||||
import javafx.beans.property.SimpleObjectProperty
|
||||
import javafx.beans.property.SimpleStringProperty
|
||||
import javafx.collections.ObservableList
|
||||
import tornadofx.asObservable
|
||||
import java.nio.file.Path
|
||||
import tornadofx.getValue
|
||||
import tornadofx.observable
|
||||
import tornadofx.setValue
|
||||
import java.util.concurrent.ExecutorService
|
||||
|
||||
class AnimationFileModel(val parentModel: MainModel, animationFilePath: Path, private val executor: ExecutorService) {
|
||||
val spineJson = SpineJson(animationFilePath)
|
||||
|
||||
val slotsProperty = SimpleObjectProperty<ObservableList<String>>()
|
||||
private var slots: ObservableList<String> by slotsProperty
|
||||
|
||||
val mouthSlotProperty: SimpleStringProperty = SimpleStringProperty().alsoListen {
|
||||
val mouthSlot = this.mouthSlot
|
||||
val mouthNaming = if (mouthSlot != null)
|
||||
MouthNaming.guess(spineJson.getSlotAttachmentNames(mouthSlot))
|
||||
else null
|
||||
this.mouthNaming = mouthNaming
|
||||
|
||||
mouthShapes = if (mouthSlot != null && mouthNaming != null) {
|
||||
val mouthNames = spineJson.getSlotAttachmentNames(mouthSlot)
|
||||
MouthShape.values().filter { mouthNames.contains(mouthNaming.getName(it)) }
|
||||
} else listOf()
|
||||
|
||||
mouthSlotError = if (mouthSlot != null)
|
||||
null
|
||||
else
|
||||
"No slot with mouth drawings specified."
|
||||
}
|
||||
private var mouthSlot: String? by mouthSlotProperty
|
||||
|
||||
val mouthSlotErrorProperty = SimpleStringProperty()
|
||||
private var mouthSlotError: String? by mouthSlotErrorProperty
|
||||
|
||||
val mouthNamingProperty = SimpleObjectProperty<MouthNaming>()
|
||||
private var mouthNaming: MouthNaming? by mouthNamingProperty
|
||||
|
||||
val mouthShapesProperty = SimpleObjectProperty<List<MouthShape>>().alsoListen {
|
||||
mouthShapesError = getMouthShapesErrorString()
|
||||
}
|
||||
var mouthShapes: List<MouthShape> by mouthShapesProperty
|
||||
private set
|
||||
|
||||
val mouthShapesErrorProperty = SimpleStringProperty()
|
||||
private var mouthShapesError: String? by mouthShapesErrorProperty
|
||||
|
||||
val audioFileModelsProperty = SimpleListProperty<AudioFileModel>(
|
||||
spineJson.audioEvents
|
||||
.map { event ->
|
||||
var audioFileModel: AudioFileModel? = null
|
||||
val reportResult: (List<MouthCue>) -> Unit =
|
||||
{ result -> saveAnimation(audioFileModel!!.animationName, event.name, result) }
|
||||
audioFileModel = AudioFileModel(event, this, executor, reportResult)
|
||||
return@map audioFileModel
|
||||
}
|
||||
.asObservable()
|
||||
)
|
||||
val audioFileModels: ObservableList<AudioFileModel> by audioFileModelsProperty
|
||||
|
||||
val busyProperty = SimpleBooleanProperty().apply {
|
||||
bind(object : BooleanBinding() {
|
||||
init {
|
||||
for (audioFileModel in audioFileModels) {
|
||||
super.bind(audioFileModel.busyProperty)
|
||||
}
|
||||
}
|
||||
override fun computeValue(): Boolean {
|
||||
return audioFileModels.any { it.busy }
|
||||
}
|
||||
})
|
||||
}
|
||||
val busy by busyProperty
|
||||
|
||||
val validProperty = SimpleBooleanProperty().apply {
|
||||
val errorProperties = arrayOf(mouthSlotErrorProperty, mouthShapesErrorProperty)
|
||||
bind(object : BooleanBinding() {
|
||||
init {
|
||||
super.bind(*errorProperties)
|
||||
}
|
||||
override fun computeValue(): Boolean {
|
||||
return errorProperties.all { it.value == null }
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
private fun saveAnimation(animationName: String, audioEventName: String, mouthCues: List<MouthCue>) {
|
||||
spineJson.createOrUpdateAnimation(mouthCues, audioEventName, animationName, mouthSlot!!, mouthNaming!!)
|
||||
spineJson.save()
|
||||
}
|
||||
|
||||
init {
|
||||
slots = spineJson.slots.asObservable()
|
||||
mouthSlot = spineJson.guessMouthSlot()
|
||||
}
|
||||
|
||||
private fun getMouthShapesErrorString(): String? {
|
||||
val missingBasicShapes = MouthShape.basicShapes
|
||||
.filter{ !mouthShapes.contains(it) }
|
||||
if (missingBasicShapes.isEmpty()) return null
|
||||
|
||||
val result = StringBuilder()
|
||||
val missingShapesString = missingBasicShapes.joinToString()
|
||||
result.appendln(
|
||||
if (missingBasicShapes.count() > 1)
|
||||
"Mouth shapes $missingShapesString are missing."
|
||||
else
|
||||
"Mouth shape $missingShapesString is missing."
|
||||
)
|
||||
|
||||
val first = MouthShape.basicShapes.first()
|
||||
val last = MouthShape.basicShapes.last()
|
||||
result.append("At least the basic mouth shapes $first-$last need corresponding image attachments.")
|
||||
return result.toString()
|
||||
}
|
||||
|
||||
}
|
|
@ -1,196 +0,0 @@
|
|||
package com.rhubarb_lip_sync.rhubarb_for_spine
|
||||
|
||||
import javafx.application.Platform
|
||||
import javafx.beans.binding.BooleanBinding
|
||||
import javafx.beans.binding.ObjectBinding
|
||||
import javafx.beans.binding.StringBinding
|
||||
import javafx.beans.property.SimpleBooleanProperty
|
||||
import javafx.beans.property.SimpleObjectProperty
|
||||
import javafx.beans.property.SimpleStringProperty
|
||||
import javafx.scene.control.Alert
|
||||
import javafx.scene.control.ButtonType
|
||||
import tornadofx.getValue
|
||||
import tornadofx.setValue
|
||||
import java.nio.file.Path
|
||||
import java.util.concurrent.ExecutorService
|
||||
import java.util.concurrent.Future
|
||||
|
||||
class AudioFileModel(
|
||||
audioEvent: SpineJson.AudioEvent,
|
||||
private val parentModel: AnimationFileModel,
|
||||
private val executor: ExecutorService,
|
||||
private val reportResult: (List<MouthCue>) -> Unit
|
||||
) {
|
||||
private val spineJson = parentModel.spineJson
|
||||
|
||||
private val audioFilePath: Path = spineJson.audioDirectoryPath.resolve(audioEvent.relativeAudioFilePath)
|
||||
|
||||
val eventNameProperty = SimpleStringProperty(audioEvent.name)
|
||||
val eventName: String by eventNameProperty
|
||||
|
||||
val displayFilePathProperty = SimpleStringProperty(audioEvent.relativeAudioFilePath)
|
||||
|
||||
val animationNameProperty = SimpleStringProperty().apply {
|
||||
val mainModel = parentModel.parentModel
|
||||
bind(object : ObjectBinding<String>() {
|
||||
init {
|
||||
super.bind(
|
||||
mainModel.animationPrefixProperty,
|
||||
eventNameProperty,
|
||||
mainModel.animationSuffixProperty
|
||||
)
|
||||
}
|
||||
override fun computeValue(): String {
|
||||
return mainModel.animationPrefix + eventName + mainModel.animationSuffix
|
||||
}
|
||||
})
|
||||
}
|
||||
val animationName: String by animationNameProperty
|
||||
|
||||
val dialogProperty = SimpleStringProperty(audioEvent.dialog)
|
||||
private val dialog: String? by dialogProperty
|
||||
|
||||
val animationProgressProperty = SimpleObjectProperty<Double?>(null)
|
||||
var animationProgress: Double? by animationProgressProperty
|
||||
private set
|
||||
|
||||
private val animatedProperty = SimpleBooleanProperty().apply {
|
||||
bind(object : ObjectBinding<Boolean>() {
|
||||
init {
|
||||
super.bind(animationNameProperty, parentModel.spineJson.animationNames)
|
||||
}
|
||||
override fun computeValue(): Boolean {
|
||||
return parentModel.spineJson.animationNames.contains(animationName)
|
||||
}
|
||||
})
|
||||
}
|
||||
private var animated by animatedProperty
|
||||
|
||||
private val futureProperty = SimpleObjectProperty<Future<*>?>()
|
||||
private var future by futureProperty
|
||||
|
||||
val audioFileStateProperty = SimpleObjectProperty<AudioFileState>().apply {
|
||||
bind(object : ObjectBinding<AudioFileState>() {
|
||||
init {
|
||||
super.bind(animatedProperty, futureProperty, animationProgressProperty)
|
||||
}
|
||||
override fun computeValue(): AudioFileState {
|
||||
return if (future != null) {
|
||||
if (animationProgress != null)
|
||||
if (future!!.isCancelled)
|
||||
AudioFileState(AudioFileStatus.Canceling)
|
||||
else
|
||||
AudioFileState(AudioFileStatus.Animating, animationProgress)
|
||||
else
|
||||
AudioFileState(AudioFileStatus.Pending)
|
||||
} else {
|
||||
if (animated)
|
||||
AudioFileState(AudioFileStatus.Done)
|
||||
else
|
||||
AudioFileState(AudioFileStatus.NotAnimated)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
val busyProperty = SimpleBooleanProperty().apply {
|
||||
bind(object : BooleanBinding() {
|
||||
init {
|
||||
super.bind(futureProperty)
|
||||
}
|
||||
override fun computeValue(): Boolean {
|
||||
return future != null
|
||||
}
|
||||
|
||||
})
|
||||
}
|
||||
val busy by busyProperty
|
||||
|
||||
val actionLabelProperty = SimpleStringProperty().apply {
|
||||
bind(object : StringBinding() {
|
||||
init {
|
||||
super.bind(futureProperty)
|
||||
}
|
||||
override fun computeValue(): String {
|
||||
return if (future != null)
|
||||
"Cancel"
|
||||
else
|
||||
"Animate"
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
fun performAction() {
|
||||
if (future == null) {
|
||||
if (animated) {
|
||||
Alert(Alert.AlertType.CONFIRMATION).apply {
|
||||
headerText = "Animation '$animationName' already exists."
|
||||
contentText = "Do you want to replace the existing animation?"
|
||||
val result = showAndWait()
|
||||
if (result.get() != ButtonType.OK) {
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
startAnimation()
|
||||
} else {
|
||||
cancelAnimation()
|
||||
}
|
||||
}
|
||||
|
||||
private fun startAnimation() {
|
||||
val wrapperTask = Runnable {
|
||||
val recognizer = parentModel.parentModel.recognizer.value
|
||||
val extendedMouthShapes = parentModel.mouthShapes.filter { it.isExtended }.toSet()
|
||||
val reportProgress: (Double?) -> Unit = {
|
||||
progress -> runAndWait { this@AudioFileModel.animationProgress = progress }
|
||||
}
|
||||
val rhubarbTask = RhubarbTask(audioFilePath, recognizer, dialog, extendedMouthShapes, reportProgress)
|
||||
try {
|
||||
try {
|
||||
val result = rhubarbTask.call()
|
||||
runAndWait {
|
||||
reportResult(result)
|
||||
}
|
||||
} finally {
|
||||
runAndWait {
|
||||
animationProgress = null
|
||||
future = null
|
||||
}
|
||||
}
|
||||
} catch (e: InterruptedException) {
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace(System.err)
|
||||
|
||||
Platform.runLater {
|
||||
Alert(Alert.AlertType.ERROR).apply {
|
||||
headerText = "Error performing lip sync for event '$eventName'."
|
||||
contentText = if (e is EndUserException)
|
||||
e.message
|
||||
else
|
||||
("An internal error occurred.\n"
|
||||
+ "Please report an issue, including the following information.\n"
|
||||
+ getStackTrace(e))
|
||||
show()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
future = executor.submit(wrapperTask)
|
||||
}
|
||||
|
||||
private fun cancelAnimation() {
|
||||
future?.cancel(true)
|
||||
}
|
||||
}
|
||||
|
||||
enum class AudioFileStatus {
|
||||
NotAnimated,
|
||||
Pending,
|
||||
Animating,
|
||||
Canceling,
|
||||
Done
|
||||
}
|
||||
|
||||
data class AudioFileState(val status: AudioFileStatus, val progress: Double? = null)
|
|
@ -1,4 +0,0 @@
|
|||
package com.rhubarb_lip_sync.rhubarb_for_spine
|
||||
|
||||
// An exception with a human-readable message that can be shown to the end user
|
||||
class EndUserException(message: String): Exception(message)
|
|
@ -1,80 +0,0 @@
|
|||
package com.rhubarb_lip_sync.rhubarb_for_spine
|
||||
|
||||
import javafx.beans.property.SimpleStringProperty
|
||||
import javafx.beans.property.StringProperty
|
||||
import javafx.beans.value.ObservableValue
|
||||
import javafx.scene.Group
|
||||
import javafx.scene.Node
|
||||
import javafx.scene.Parent
|
||||
import javafx.scene.control.Tooltip
|
||||
import javafx.scene.paint.Color
|
||||
import tornadofx.addChildIfPossible
|
||||
import tornadofx.circle
|
||||
import tornadofx.rectangle
|
||||
import tornadofx.removeFromParent
|
||||
|
||||
fun renderErrorIndicator(): Node {
|
||||
return Group().apply {
|
||||
isManaged = false
|
||||
circle {
|
||||
radius = 7.0
|
||||
fill = Color.ORANGERED
|
||||
}
|
||||
rectangle {
|
||||
x = -1.0
|
||||
y = -5.0
|
||||
width = 2.0
|
||||
height = 7.0
|
||||
fill = Color.WHITE
|
||||
}
|
||||
rectangle {
|
||||
x = -1.0
|
||||
y = 3.0
|
||||
width = 2.0
|
||||
height = 2.0
|
||||
fill = Color.WHITE
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun Parent.errorProperty() : StringProperty {
|
||||
return properties.getOrPut("rhubarb.errorProperty", {
|
||||
val errorIndicator: Node = renderErrorIndicator()
|
||||
val tooltip = Tooltip()
|
||||
val property = SimpleStringProperty()
|
||||
|
||||
fun updateTooltipVisibility() {
|
||||
if (tooltip.text.isNotEmpty() && isFocused) {
|
||||
val bounds = localToScreen(boundsInLocal)
|
||||
tooltip.show(scene.window, bounds.minX + 5, bounds.maxY + 2)
|
||||
} else {
|
||||
tooltip.hide()
|
||||
}
|
||||
}
|
||||
|
||||
focusedProperty().addListener({
|
||||
_: ObservableValue<out Boolean>, _: Boolean, _: Boolean ->
|
||||
updateTooltipVisibility()
|
||||
})
|
||||
|
||||
property.addListener({
|
||||
_: ObservableValue<out String?>, _: String?, newValue: String? ->
|
||||
|
||||
if (newValue != null) {
|
||||
this.addChildIfPossible(errorIndicator)
|
||||
|
||||
tooltip.text = newValue
|
||||
Tooltip.install(this, tooltip)
|
||||
updateTooltipVisibility()
|
||||
} else {
|
||||
errorIndicator.removeFromParent()
|
||||
|
||||
tooltip.text = ""
|
||||
tooltip.hide()
|
||||
Tooltip.uninstall(this, tooltip)
|
||||
updateTooltipVisibility()
|
||||
}
|
||||
})
|
||||
return@getOrPut property
|
||||
}) as StringProperty
|
||||
}
|
|
@ -1,42 +0,0 @@
|
|||
package com.rhubarb_lip_sync.rhubarb_for_spine
|
||||
|
||||
import javafx.scene.image.Image
|
||||
import javafx.stage.Stage
|
||||
import tornadofx.App
|
||||
import tornadofx.addStageIcon
|
||||
import java.lang.reflect.Method
|
||||
import javax.swing.ImageIcon
|
||||
|
||||
class MainApp : App(MainView::class) {
|
||||
override fun start(stage: Stage) {
|
||||
super.start(stage)
|
||||
setIcon()
|
||||
}
|
||||
|
||||
private fun setIcon() {
|
||||
// Set icon for windows
|
||||
for (iconSize in listOf(16, 20, 24, 32, 48, 64, 256)) {
|
||||
addStageIcon(Image(this.javaClass.getResourceAsStream("/icon-$iconSize.png")))
|
||||
}
|
||||
|
||||
// OS X requires the dock icon to be changed separately.
|
||||
// Not all JDKs contain the class com.apple.eawt.Application, so we have to use reflection.
|
||||
val classLoader = this.javaClass.classLoader
|
||||
try {
|
||||
val iconURL = this.javaClass.getResource("/icon-256.png")
|
||||
val image: java.awt.Image = ImageIcon(iconURL).image
|
||||
|
||||
// The following is reflection code for the line
|
||||
// Application.getApplication().setDockIconImage(image)
|
||||
val applicationClass: Class<*> = classLoader.loadClass("com.apple.eawt.Application")
|
||||
val getApplicationMethod: Method = applicationClass.getMethod("getApplication")
|
||||
val application: Any = getApplicationMethod.invoke(null)
|
||||
val setDockIconImageMethod: Method =
|
||||
applicationClass.getMethod("setDockIconImage", java.awt.Image::class.java)
|
||||
setDockIconImageMethod.invoke(application, image);
|
||||
} catch (e: Exception) {
|
||||
// Works only on OS X
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,63 +0,0 @@
|
|||
package com.rhubarb_lip_sync.rhubarb_for_spine
|
||||
|
||||
import javafx.beans.property.SimpleObjectProperty
|
||||
import javafx.beans.property.SimpleStringProperty
|
||||
import javafx.collections.FXCollections
|
||||
import javafx.collections.ObservableList
|
||||
import tornadofx.FX
|
||||
import tornadofx.getValue
|
||||
import tornadofx.setValue
|
||||
import java.nio.file.Files
|
||||
import java.nio.file.InvalidPathException
|
||||
import java.nio.file.Paths
|
||||
import java.util.concurrent.ExecutorService
|
||||
|
||||
class MainModel(private val executor: ExecutorService) {
|
||||
val filePathStringProperty = SimpleStringProperty(getDefaultPathString()).alsoListen { value ->
|
||||
filePathError = getExceptionMessage {
|
||||
animationFileModel = null
|
||||
if (value.isNullOrBlank()) {
|
||||
throw EndUserException("No input file specified.")
|
||||
}
|
||||
|
||||
val path = try {
|
||||
val trimmed = value.removeSurrounding("\"")
|
||||
Paths.get(trimmed)
|
||||
} catch (e: InvalidPathException) {
|
||||
throw EndUserException("Not a valid file path.")
|
||||
}
|
||||
|
||||
if (!Files.exists(path)) {
|
||||
throw EndUserException("File does not exist.")
|
||||
}
|
||||
|
||||
animationFileModel = AnimationFileModel(this, path, executor)
|
||||
}
|
||||
}
|
||||
|
||||
val filePathErrorProperty = SimpleStringProperty()
|
||||
private var filePathError: String? by filePathErrorProperty
|
||||
|
||||
val animationFileModelProperty = SimpleObjectProperty<AnimationFileModel?>()
|
||||
var animationFileModel by animationFileModelProperty
|
||||
private set
|
||||
|
||||
val recognizersProperty = SimpleObjectProperty<ObservableList<Recognizer>>(FXCollections.observableArrayList(
|
||||
Recognizer("pocketSphinx", "PocketSphinx (use for English recordings)"),
|
||||
Recognizer("phonetic", "Phonetic (use for non-English recordings)")
|
||||
))
|
||||
private var recognizers: ObservableList<Recognizer> by recognizersProperty
|
||||
|
||||
val recognizerProperty = SimpleObjectProperty<Recognizer>(recognizers[0])
|
||||
var recognizer: Recognizer by recognizerProperty
|
||||
|
||||
val animationPrefixProperty = SimpleStringProperty("say_")
|
||||
var animationPrefix: String by animationPrefixProperty
|
||||
|
||||
val animationSuffixProperty = SimpleStringProperty("")
|
||||
var animationSuffix: String by animationSuffixProperty
|
||||
|
||||
private fun getDefaultPathString() = FX.application.parameters.raw.firstOrNull()
|
||||
}
|
||||
|
||||
class Recognizer(val value: String, val description: String)
|
|
@ -1,257 +0,0 @@
|
|||
package com.rhubarb_lip_sync.rhubarb_for_spine
|
||||
|
||||
import javafx.beans.property.Property
|
||||
import javafx.beans.property.SimpleBooleanProperty
|
||||
import javafx.beans.property.SimpleObjectProperty
|
||||
import javafx.beans.property.SimpleStringProperty
|
||||
import javafx.event.ActionEvent
|
||||
import javafx.event.EventHandler
|
||||
import javafx.event.EventTarget
|
||||
import javafx.geometry.Pos
|
||||
import javafx.scene.control.*
|
||||
import javafx.scene.input.DragEvent
|
||||
import javafx.scene.input.TransferMode
|
||||
import javafx.scene.layout.*
|
||||
import javafx.scene.paint.Color
|
||||
import javafx.scene.text.Font
|
||||
import javafx.scene.text.FontWeight
|
||||
import javafx.scene.text.Text
|
||||
import javafx.stage.FileChooser
|
||||
import javafx.util.StringConverter
|
||||
import tornadofx.*
|
||||
import java.io.File
|
||||
import java.util.concurrent.Executors
|
||||
|
||||
class MainView : View() {
|
||||
private val executor = Executors.newSingleThreadExecutor()
|
||||
private val mainModel = MainModel(executor)
|
||||
|
||||
init {
|
||||
title = "Rhubarb Lip Sync for Spine"
|
||||
}
|
||||
|
||||
override val root = form {
|
||||
var filePathTextField: TextField? = null
|
||||
var filePathButton: Button? = null
|
||||
|
||||
val fileModelProperty = mainModel.animationFileModelProperty
|
||||
|
||||
minWidth = 800.0
|
||||
prefWidth = 1000.0
|
||||
fieldset("Settings") {
|
||||
disableProperty().bind(fileModelProperty.select { it!!.busyProperty })
|
||||
field("Spine JSON file") {
|
||||
filePathTextField = textfield {
|
||||
textProperty().bindBidirectional(mainModel.filePathStringProperty)
|
||||
errorProperty().bind(mainModel.filePathErrorProperty)
|
||||
}
|
||||
filePathButton = button("...")
|
||||
}
|
||||
field("Mouth slot") {
|
||||
combobox<String> {
|
||||
itemsProperty().bind(fileModelProperty.select { it!!.slotsProperty })
|
||||
valueProperty().bindBidirectional(fileModelProperty.select { it!!.mouthSlotProperty })
|
||||
errorProperty().bind(fileModelProperty.select { it!!.mouthSlotErrorProperty })
|
||||
}
|
||||
}
|
||||
field("Mouth naming") {
|
||||
label {
|
||||
textProperty().bind(
|
||||
fileModelProperty
|
||||
.select { it!!.mouthNamingProperty }
|
||||
.select { SimpleStringProperty(it.displayString) }
|
||||
)
|
||||
}
|
||||
}
|
||||
field("Mouth shapes") {
|
||||
hbox {
|
||||
errorProperty().bind(fileModelProperty.select { it!!.mouthShapesErrorProperty })
|
||||
gridpane {
|
||||
hgap = 10.0
|
||||
vgap = 3.0
|
||||
row {
|
||||
label("Basic:")
|
||||
for (shape in MouthShape.basicShapes) {
|
||||
renderShapeCheckbox(shape, fileModelProperty, this)
|
||||
}
|
||||
}
|
||||
row {
|
||||
label("Extended:")
|
||||
for (shape in MouthShape.extendedShapes) {
|
||||
renderShapeCheckbox(shape, fileModelProperty, this)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
field("Dialog recognizer") {
|
||||
combobox<Recognizer> {
|
||||
itemsProperty().bind(mainModel.recognizersProperty)
|
||||
this.converter = object : StringConverter<Recognizer>() {
|
||||
override fun toString(recognizer: Recognizer?): String {
|
||||
return recognizer?.description ?: ""
|
||||
}
|
||||
override fun fromString(string: String?): Recognizer {
|
||||
throw NotImplementedError()
|
||||
}
|
||||
}
|
||||
valueProperty().bindBidirectional(mainModel.recognizerProperty)
|
||||
}
|
||||
}
|
||||
field("Animation naming") {
|
||||
textfield {
|
||||
maxWidth = 100.0
|
||||
textProperty().bindBidirectional(mainModel.animationPrefixProperty)
|
||||
}
|
||||
label("<audio event name>")
|
||||
textfield {
|
||||
maxWidth = 100.0
|
||||
textProperty().bindBidirectional(mainModel.animationSuffixProperty)
|
||||
}
|
||||
}
|
||||
}
|
||||
fieldset("Audio events") {
|
||||
tableview<AudioFileModel> {
|
||||
placeholder = Label("There are no events with associated audio files.")
|
||||
columnResizePolicy = SmartResize.POLICY
|
||||
column("Event", AudioFileModel::eventNameProperty)
|
||||
.weightedWidth(1.0)
|
||||
column("Animation name", AudioFileModel::animationNameProperty)
|
||||
.weightedWidth(1.0)
|
||||
column("Audio file", AudioFileModel::displayFilePathProperty)
|
||||
.weightedWidth(1.0)
|
||||
column("Dialog", AudioFileModel::dialogProperty).apply {
|
||||
weightedWidth(3.0)
|
||||
// Make dialog column wrap
|
||||
setCellFactory { tableColumn ->
|
||||
return@setCellFactory TableCell<AudioFileModel, String>().also { cell ->
|
||||
cell.graphic = Text().apply {
|
||||
textProperty().bind(cell.itemProperty())
|
||||
fillProperty().bind(cell.textFillProperty())
|
||||
val widthProperty = tableColumn.widthProperty()
|
||||
.minus(cell.paddingLeftProperty)
|
||||
.minus(cell.paddingRightProperty)
|
||||
wrappingWidthProperty().bind(widthProperty)
|
||||
}
|
||||
cell.prefHeight = Control.USE_COMPUTED_SIZE
|
||||
}
|
||||
}
|
||||
}
|
||||
column("Status", AudioFileModel::audioFileStateProperty).apply {
|
||||
weightedWidth(1.0)
|
||||
setCellFactory {
|
||||
return@setCellFactory object : TableCell<AudioFileModel, AudioFileState>() {
|
||||
override fun updateItem(state: AudioFileState?, empty: Boolean) {
|
||||
super.updateItem(state, empty)
|
||||
graphic = if (state != null) {
|
||||
when (state.status) {
|
||||
AudioFileStatus.NotAnimated -> Text("Not animated").apply {
|
||||
fill = Color.GRAY
|
||||
}
|
||||
AudioFileStatus.Pending,
|
||||
AudioFileStatus.Animating -> HBox().apply {
|
||||
val progress: Double? = state.progress
|
||||
val indeterminate = -1.0
|
||||
val bar = progressbar(progress ?: indeterminate) {
|
||||
maxWidth = Double.MAX_VALUE
|
||||
}
|
||||
HBox.setHgrow(bar, Priority.ALWAYS)
|
||||
hbox {
|
||||
minWidth = 30.0
|
||||
if (progress != null) {
|
||||
text("${(progress * 100).toInt()}%") {
|
||||
alignment = Pos.BASELINE_RIGHT
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
AudioFileStatus.Canceling -> Text("Canceling")
|
||||
AudioFileStatus.Done -> Text("Done").apply {
|
||||
font = Font.font(font.family, FontWeight.BOLD, font.size)
|
||||
}
|
||||
}
|
||||
} else null
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
column("", AudioFileModel::actionLabelProperty).apply {
|
||||
weightedWidth(1.0)
|
||||
// Show button
|
||||
setCellFactory {
|
||||
return@setCellFactory object : TableCell<AudioFileModel, String>() {
|
||||
override fun updateItem(item: String?, empty: Boolean) {
|
||||
super.updateItem(item, empty)
|
||||
graphic = if (!empty)
|
||||
Button(item).apply {
|
||||
this.maxWidth = Double.MAX_VALUE
|
||||
setOnAction {
|
||||
val audioFileModel = this@tableview.items[index]
|
||||
audioFileModel.performAction()
|
||||
}
|
||||
val invalidProperty: Property<Boolean> = fileModelProperty
|
||||
.select { it!!.validProperty }
|
||||
.select { SimpleBooleanProperty(!it) }
|
||||
disableProperty().bind(invalidProperty)
|
||||
}
|
||||
else
|
||||
null
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
itemsProperty().bind(fileModelProperty.select { it!!.audioFileModelsProperty })
|
||||
}
|
||||
}
|
||||
|
||||
onDragOver = EventHandler<DragEvent> { event ->
|
||||
if (event.dragboard.hasFiles() && mainModel.animationFileModel?.busy != true) {
|
||||
event.acceptTransferModes(TransferMode.COPY)
|
||||
event.consume()
|
||||
}
|
||||
}
|
||||
onDragDropped = EventHandler<DragEvent> { event ->
|
||||
if (event.dragboard.hasFiles() && mainModel.animationFileModel?.busy != true) {
|
||||
filePathTextField!!.text = event.dragboard.files.firstOrNull()?.path
|
||||
event.isDropCompleted = true
|
||||
event.consume()
|
||||
}
|
||||
}
|
||||
|
||||
whenUndocked {
|
||||
executor.shutdownNow()
|
||||
}
|
||||
|
||||
filePathButton!!.onAction = EventHandler<ActionEvent> {
|
||||
val fileChooser = FileChooser().apply {
|
||||
title = "Open Spine JSON file"
|
||||
extensionFilters.addAll(
|
||||
FileChooser.ExtensionFilter("Spine JSON file (*.json)", "*.json"),
|
||||
FileChooser.ExtensionFilter("All files (*.*)", "*.*")
|
||||
)
|
||||
val lastDirectory = filePathTextField!!.text?.let { File(it).parentFile }
|
||||
if (lastDirectory != null && lastDirectory.isDirectory) {
|
||||
initialDirectory = lastDirectory
|
||||
}
|
||||
}
|
||||
val file = fileChooser.showOpenDialog(this@MainView.primaryStage)
|
||||
if (file != null) {
|
||||
filePathTextField!!.text = file.path
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun renderShapeCheckbox(shape: MouthShape, fileModelProperty: SimpleObjectProperty<AnimationFileModel?>, parent: EventTarget) {
|
||||
parent.label {
|
||||
textProperty().bind(
|
||||
fileModelProperty
|
||||
.select { it!!.mouthShapesProperty }
|
||||
.select { mouthShapes ->
|
||||
val hairSpace = "\u200A"
|
||||
val result = shape.toString() + hairSpace + if (mouthShapes.contains(shape)) "☑" else "☐"
|
||||
return@select SimpleStringProperty(result)
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,3 +0,0 @@
|
|||
package com.rhubarb_lip_sync.rhubarb_for_spine
|
||||
|
||||
data class MouthCue(val time: Double, val mouthShape: MouthShape)
|
|
@ -1,55 +0,0 @@
|
|||
package com.rhubarb_lip_sync.rhubarb_for_spine
|
||||
|
||||
import java.util.*
|
||||
|
||||
class MouthNaming(private val prefix: String, private val suffix: String, private val mouthShapeCasing: MouthShapeCasing) {
|
||||
|
||||
companion object {
|
||||
fun guess(mouthNames: List<String>): MouthNaming {
|
||||
if (mouthNames.isEmpty()) {
|
||||
return MouthNaming("", "", guessMouthShapeCasing(""))
|
||||
}
|
||||
|
||||
val commonPrefix = mouthNames.commonPrefix
|
||||
val commonSuffix = mouthNames.commonSuffix
|
||||
val firstMouthName = mouthNames.first()
|
||||
if (commonPrefix.length + commonSuffix.length >= firstMouthName.length) {
|
||||
return MouthNaming(commonPrefix, "", guessMouthShapeCasing(""))
|
||||
}
|
||||
|
||||
val shapeName = firstMouthName.substring(
|
||||
commonPrefix.length,
|
||||
firstMouthName.length - commonSuffix.length)
|
||||
val mouthShapeCasing = guessMouthShapeCasing(shapeName)
|
||||
return MouthNaming(commonPrefix, commonSuffix, mouthShapeCasing)
|
||||
}
|
||||
|
||||
private fun guessMouthShapeCasing(shapeName: String): MouthShapeCasing {
|
||||
return if (shapeName.isBlank() || shapeName[0].isLowerCase())
|
||||
MouthShapeCasing.Lower
|
||||
else
|
||||
MouthShapeCasing.Upper
|
||||
}
|
||||
}
|
||||
|
||||
fun getName(mouthShape: MouthShape): String {
|
||||
val name = if (mouthShapeCasing == MouthShapeCasing.Upper)
|
||||
mouthShape.toString()
|
||||
else
|
||||
mouthShape.toString().toLowerCase(Locale.ROOT)
|
||||
return "$prefix$name$suffix"
|
||||
}
|
||||
|
||||
val displayString: String get() {
|
||||
val casing = if (mouthShapeCasing == MouthShapeCasing.Upper)
|
||||
"<UPPER-CASE SHAPE NAME>"
|
||||
else
|
||||
"<lower-case shape name>"
|
||||
return "\"$prefix$casing$suffix\""
|
||||
}
|
||||
}
|
||||
|
||||
enum class MouthShapeCasing {
|
||||
Upper,
|
||||
Lower
|
||||
}
|
|
@ -1,19 +0,0 @@
|
|||
package com.rhubarb_lip_sync.rhubarb_for_spine
|
||||
|
||||
enum class MouthShape {
|
||||
A, B, C, D, E, F, G, H, X;
|
||||
|
||||
val isBasic: Boolean
|
||||
get() = this.ordinal < basicShapeCount
|
||||
|
||||
val isExtended: Boolean
|
||||
get() = !this.isBasic
|
||||
|
||||
companion object {
|
||||
const val basicShapeCount = 6
|
||||
|
||||
val basicShapes = MouthShape.values().take(basicShapeCount)
|
||||
|
||||
val extendedShapes = MouthShape.values().drop(basicShapeCount)
|
||||
}
|
||||
}
|
|
@ -1,166 +0,0 @@
|
|||
package com.rhubarb_lip_sync.rhubarb_for_spine
|
||||
|
||||
import com.beust.klaxon.JsonObject
|
||||
import com.beust.klaxon.Parser as JsonParser
|
||||
import org.apache.commons.lang3.SystemUtils.IS_OS_WINDOWS
|
||||
import java.io.*
|
||||
import java.nio.charset.StandardCharsets
|
||||
import java.nio.file.Files
|
||||
import java.nio.file.Path
|
||||
import java.util.concurrent.Callable
|
||||
|
||||
class RhubarbTask(
|
||||
val audioFilePath: Path,
|
||||
val recognizer: String,
|
||||
val dialog: String?,
|
||||
val extendedMouthShapes: Set<MouthShape>,
|
||||
val reportProgress: (Double?) -> Unit
|
||||
) : Callable<List<MouthCue>> {
|
||||
|
||||
override fun call(): List<MouthCue> {
|
||||
if (Thread.currentThread().isInterrupted) {
|
||||
throw InterruptedException()
|
||||
}
|
||||
if (!Files.exists(audioFilePath)) {
|
||||
throw EndUserException("File '$audioFilePath' does not exist.")
|
||||
}
|
||||
|
||||
val dialogFile = if (dialog != null) TemporaryTextFile(dialog) else null
|
||||
val outputFile = TemporaryTextFile()
|
||||
dialogFile.use { outputFile.use {
|
||||
val processBuilder = ProcessBuilder(createProcessBuilderArgs(dialogFile?.filePath)).apply {
|
||||
// See http://java-monitor.com/forum/showthread.php?t=4067
|
||||
redirectOutput(outputFile.filePath.toFile())
|
||||
}
|
||||
val process: Process = processBuilder.start()
|
||||
val stderr = BufferedReader(InputStreamReader(process.errorStream, StandardCharsets.UTF_8))
|
||||
try {
|
||||
while (true) {
|
||||
val line = stderr.interruptibleReadLine()
|
||||
val message = parseJsonObject(line)
|
||||
when (message.string("type")!!) {
|
||||
"progress" -> {
|
||||
reportProgress(message.double("value")!!)
|
||||
}
|
||||
"success" -> {
|
||||
reportProgress(1.0)
|
||||
val resultString = String(Files.readAllBytes(outputFile.filePath), StandardCharsets.UTF_8)
|
||||
return parseRhubarbResult(resultString)
|
||||
}
|
||||
"failure" -> {
|
||||
throw EndUserException(message.string("reason") ?: "Rhubarb failed without reason.")
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (e: InterruptedException) {
|
||||
process.destroyForcibly()
|
||||
throw e
|
||||
} catch (e: EOFException) {
|
||||
throw EndUserException("Rhubarb terminated unexpectedly.")
|
||||
} finally {
|
||||
process.waitFor()
|
||||
}
|
||||
}}
|
||||
|
||||
throw EndUserException("Audio file processing terminated in an unexpected way.")
|
||||
}
|
||||
|
||||
private fun parseRhubarbResult(jsonString: String): List<MouthCue> {
|
||||
val json = parseJsonObject(jsonString)
|
||||
val mouthCues = json.array<JsonObject>("mouthCues")!!
|
||||
return mouthCues.map { mouthCue ->
|
||||
val time = mouthCue.double("start")!!
|
||||
val mouthShape = MouthShape.valueOf(mouthCue.string("value")!!)
|
||||
return@map MouthCue(time, mouthShape)
|
||||
}
|
||||
}
|
||||
|
||||
private val jsonParser = JsonParser.default()
|
||||
private fun parseJsonObject(jsonString: String): JsonObject {
|
||||
return jsonParser.parse(StringReader(jsonString)) as JsonObject
|
||||
}
|
||||
|
||||
private fun createProcessBuilderArgs(dialogFilePath: Path?): List<String> {
|
||||
val extendedMouthShapesString =
|
||||
if (extendedMouthShapes.any()) extendedMouthShapes.joinToString(separator = "")
|
||||
else "\"\""
|
||||
return mutableListOf(
|
||||
rhubarbBinFilePath.toString(),
|
||||
"--machineReadable",
|
||||
"--recognizer", recognizer,
|
||||
"--exportFormat", "json",
|
||||
"--extendedShapes", extendedMouthShapesString
|
||||
).apply {
|
||||
if (dialogFilePath != null) {
|
||||
addAll(listOf(
|
||||
"--dialogFile", dialogFilePath.toString()
|
||||
))
|
||||
}
|
||||
}.apply {
|
||||
add(audioFilePath.toString())
|
||||
}
|
||||
}
|
||||
|
||||
private val guiBinDirectory: Path by lazy {
|
||||
val path = urlToPath(getLocation(RhubarbTask::class.java))
|
||||
return@lazy if (Files.isDirectory(path)) path.parent else path
|
||||
}
|
||||
|
||||
private val rhubarbBinFilePath: Path by lazy {
|
||||
val rhubarbBinName = if (IS_OS_WINDOWS) "rhubarb.exe" else "rhubarb"
|
||||
var currentDirectory: Path? = guiBinDirectory
|
||||
while (currentDirectory != null) {
|
||||
val candidate: Path = currentDirectory.resolve(rhubarbBinName)
|
||||
if (Files.exists(candidate)) {
|
||||
return@lazy candidate
|
||||
}
|
||||
currentDirectory = currentDirectory.parent
|
||||
}
|
||||
throw EndUserException("Could not find Rhubarb Lip Sync executable '$rhubarbBinName'."
|
||||
+ " Expected to find it in '$guiBinDirectory' or any directory above.")
|
||||
}
|
||||
|
||||
private class TemporaryTextFile(text: String = "") : AutoCloseable {
|
||||
val filePath: Path = Files.createTempFile(null, null).also {
|
||||
Files.write(it, text.toByteArray(StandardCharsets.UTF_8))
|
||||
}
|
||||
|
||||
override fun close() {
|
||||
Files.delete(filePath)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Same as readLine, but can be interrupted.
|
||||
// Note that this function handles linebreak characters differently from readLine.
|
||||
// It only consumes the first linebreak character before returning and swallows any leading
|
||||
// linebreak characters.
|
||||
// This behavior is much easier to implement and doesn't make any difference for our purposes.
|
||||
private fun BufferedReader.interruptibleReadLine(): String {
|
||||
val result = StringBuilder()
|
||||
while (true) {
|
||||
val char = interruptibleReadChar()
|
||||
if (char == '\r' || char == '\n') {
|
||||
if (result.isNotEmpty()) return result.toString()
|
||||
} else {
|
||||
result.append(char)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun BufferedReader.interruptibleReadChar(): Char {
|
||||
while (true) {
|
||||
if (Thread.currentThread().isInterrupted) {
|
||||
throw InterruptedException()
|
||||
}
|
||||
if (ready()) {
|
||||
val result: Int = read()
|
||||
if (result == -1) {
|
||||
throw EOFException()
|
||||
}
|
||||
return result.toChar()
|
||||
}
|
||||
Thread.yield()
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,163 +0,0 @@
|
|||
package com.rhubarb_lip_sync.rhubarb_for_spine
|
||||
|
||||
import com.beust.klaxon.*
|
||||
import javafx.collections.FXCollections.observableSet
|
||||
import java.nio.charset.StandardCharsets
|
||||
import java.nio.file.Files
|
||||
import java.nio.file.Path
|
||||
|
||||
class SpineJson(private val filePath: Path) {
|
||||
private val fileDirectoryPath: Path = filePath.parent
|
||||
private val json: JsonObject
|
||||
private val skeleton: JsonObject
|
||||
|
||||
init {
|
||||
if (!Files.exists(filePath)) {
|
||||
throw EndUserException("File '$filePath' does not exist.")
|
||||
}
|
||||
try {
|
||||
json = Parser.default().parse(filePath.toString()) as JsonObject
|
||||
} catch (e: Exception) {
|
||||
throw EndUserException("Wrong file format. This is not a valid JSON file.")
|
||||
}
|
||||
skeleton = json.obj("skeleton") ?: throw EndUserException("JSON file is corrupted.")
|
||||
|
||||
validateProperties()
|
||||
}
|
||||
|
||||
private fun validateProperties() {
|
||||
imagesDirectoryPath
|
||||
audioDirectoryPath
|
||||
}
|
||||
|
||||
private val imagesDirectoryPath: Path get() {
|
||||
val relativeImagesDirectory = skeleton.string("images")
|
||||
?: throw EndUserException("JSON file is incomplete: Images path is missing."
|
||||
+ " Make sure to check 'Nonessential data' when exporting.")
|
||||
|
||||
val imagesDirectoryPath = fileDirectoryPath.resolve(relativeImagesDirectory).normalize()
|
||||
if (!Files.exists(imagesDirectoryPath)) {
|
||||
throw EndUserException("Could not find images directory relative to the JSON file."
|
||||
+ " Make sure the JSON file is in the same directory as the original Spine file.")
|
||||
}
|
||||
|
||||
return imagesDirectoryPath
|
||||
}
|
||||
|
||||
val audioDirectoryPath: Path get() {
|
||||
val relativeAudioDirectory = skeleton.string("audio")
|
||||
?: throw EndUserException("JSON file is incomplete: Audio path is missing."
|
||||
+ " Make sure to check 'Nonessential data' when exporting.")
|
||||
|
||||
val audioDirectoryPath = fileDirectoryPath.resolve(relativeAudioDirectory).normalize()
|
||||
if (!Files.exists(audioDirectoryPath)) {
|
||||
throw EndUserException("Could not find audio directory relative to the JSON file."
|
||||
+ " Make sure the JSON file is in the same directory as the original Spine file.")
|
||||
}
|
||||
|
||||
return audioDirectoryPath
|
||||
}
|
||||
|
||||
val frameRate: Double get() {
|
||||
return skeleton.double("fps") ?: 30.0
|
||||
}
|
||||
|
||||
val slots: List<String> get() {
|
||||
val slots = json.array("slots") ?: listOf<JsonObject>()
|
||||
return slots.mapNotNull { it.string("name") }
|
||||
}
|
||||
|
||||
fun guessMouthSlot(): String? {
|
||||
return slots.firstOrNull { it.contains("mouth", ignoreCase = true) }
|
||||
?: slots.firstOrNull()
|
||||
}
|
||||
|
||||
data class AudioEvent(val name: String, val relativeAudioFilePath: String, val dialog: String?)
|
||||
|
||||
val audioEvents: List<AudioEvent> get() {
|
||||
val events = json.obj("events") ?: JsonObject()
|
||||
val result = mutableListOf<AudioEvent>()
|
||||
for ((name, value) in events) {
|
||||
if (value !is JsonObject) throw EndUserException("Invalid event found.")
|
||||
|
||||
val relativeAudioFilePath = value.string("audio") ?: continue
|
||||
|
||||
val dialog = value.string("string")
|
||||
result.add(AudioEvent(name, relativeAudioFilePath, dialog))
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
fun getSlotAttachmentNames(slotName: String): List<String> {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
val skins: Collection<JsonObject> = when (val skinsObject = json["skins"]) {
|
||||
is JsonObject -> skinsObject.values as Collection<JsonObject>
|
||||
is JsonArray<*> -> skinsObject as Collection<JsonObject>
|
||||
else -> emptyList()
|
||||
}
|
||||
|
||||
// Get attachment names for all skins
|
||||
return skins
|
||||
.flatMap { skin ->
|
||||
skin.obj(slotName)?.keys?.toList()
|
||||
?: skin.obj("attachments")?.obj(slotName)?.keys?.toList()
|
||||
?: emptyList<String>()
|
||||
}
|
||||
.distinct()
|
||||
}
|
||||
|
||||
val animationNames = observableSet<String>(
|
||||
json.obj("animations")?.map{ it.key }?.toMutableSet() ?: mutableSetOf()
|
||||
)
|
||||
|
||||
fun createOrUpdateAnimation(mouthCues: List<MouthCue>, eventName: String, animationName: String,
|
||||
mouthSlot: String, mouthNaming: MouthNaming
|
||||
) {
|
||||
if (!json.containsKey("animations")) {
|
||||
json["animations"] = JsonObject()
|
||||
}
|
||||
val animations: JsonObject = json.obj("animations")!!
|
||||
|
||||
// Round times to full frames. Always round down.
|
||||
// If events coincide, prefer the latest one.
|
||||
val keyframes = mutableMapOf<Int, MouthShape>()
|
||||
for (mouthCue in mouthCues) {
|
||||
val frameNumber = (mouthCue.time * frameRate).toInt()
|
||||
keyframes[frameNumber] = mouthCue.mouthShape
|
||||
}
|
||||
|
||||
animations[animationName] = JsonObject().apply {
|
||||
this["slots"] = JsonObject().apply {
|
||||
this[mouthSlot] = JsonObject().apply {
|
||||
this["attachment"] = JsonArray(
|
||||
keyframes
|
||||
.toSortedMap()
|
||||
.map { (frameNumber, mouthShape) ->
|
||||
JsonObject().apply {
|
||||
this["time"] = frameNumber / frameRate
|
||||
this["name"] = mouthNaming.getName(mouthShape)
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
this["events"] = JsonArray(
|
||||
JsonObject().apply {
|
||||
this["time"] = 0.0
|
||||
this["name"] = eventName
|
||||
this["string"] = ""
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
animationNames.add(animationName)
|
||||
}
|
||||
|
||||
override fun toString(): String {
|
||||
return json.toJsonString(prettyPrint = true)
|
||||
}
|
||||
|
||||
fun save() {
|
||||
Files.write(filePath, listOf(toString()), StandardCharsets.UTF_8)
|
||||
}
|
||||
}
|
|
@ -1,92 +0,0 @@
|
|||
package com.rhubarb_lip_sync.rhubarb_for_spine
|
||||
|
||||
import java.io.FileInputStream
|
||||
import java.net.MalformedURLException
|
||||
import java.net.URISyntaxException
|
||||
import java.net.URL
|
||||
import org.apache.commons.lang3.SystemUtils.IS_OS_WINDOWS
|
||||
import java.nio.file.Path
|
||||
import java.nio.file.Paths
|
||||
|
||||
// The following code is adapted from https://stackoverflow.com/a/12733172/52041
|
||||
|
||||
/**
|
||||
* Gets the base location of the given class.
|
||||
*
|
||||
* If the class is directly on the file system (e.g.,
|
||||
* "/path/to/my/package/MyClass.class") then it will return the base directory
|
||||
* (e.g., "file:/path/to").
|
||||
*
|
||||
* If the class is within a JAR file (e.g.,
|
||||
* "/path/to/my-jar.jar!/my/package/MyClass.class") then it will return the
|
||||
* path to the JAR (e.g., "file:/path/to/my-jar.jar").
|
||||
*
|
||||
* @param c The class whose location is desired.
|
||||
*/
|
||||
fun getLocation(c: Class<*>): URL {
|
||||
// Try the easy way first
|
||||
try {
|
||||
val codeSourceLocation = c.protectionDomain.codeSource.location
|
||||
if (codeSourceLocation != null) return codeSourceLocation
|
||||
} catch (e: SecurityException) {
|
||||
// Cannot access protection domain
|
||||
} catch (e: NullPointerException) {
|
||||
// Protection domain or code source is null
|
||||
}
|
||||
|
||||
// The easy way failed, so we try the hard way. We ask for the class
|
||||
// itself as a resource, then strip the class's path from the URL string,
|
||||
// leaving the base path.
|
||||
|
||||
// Get the class's raw resource path
|
||||
val classResource = c.getResource(c.simpleName + ".class")
|
||||
?: throw Exception("Cannot find class resource.")
|
||||
|
||||
val url = classResource.toString()
|
||||
val suffix = c.canonicalName.replace('.', '/') + ".class"
|
||||
if (!url.endsWith(suffix)) throw Exception("Malformed URL.")
|
||||
|
||||
// strip the class's path from the URL string
|
||||
val base = url.substring(0, url.length - suffix.length)
|
||||
|
||||
var path = base
|
||||
|
||||
// remove the "jar:" prefix and "!/" suffix, if present
|
||||
if (path.startsWith("jar:")) path = path.substring(4, path.length - 2)
|
||||
|
||||
return URL(path)
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the given URL to its corresponding [Path].
|
||||
*
|
||||
* @param url The URL to convert.
|
||||
* @return A file path suitable for use with e.g. [FileInputStream]
|
||||
*/
|
||||
fun urlToPath(url: URL): Path {
|
||||
var pathString = url.toString()
|
||||
|
||||
if (pathString.startsWith("jar:")) {
|
||||
// Remove "jar:" prefix and "!/" suffix
|
||||
val index = pathString.indexOf("!/")
|
||||
pathString = pathString.substring(4, index)
|
||||
}
|
||||
|
||||
try {
|
||||
if (IS_OS_WINDOWS && pathString.matches("file:[A-Za-z]:.*".toRegex())) {
|
||||
pathString = "file:/" + pathString.substring(5)
|
||||
}
|
||||
return Paths.get(URL(pathString).toURI())
|
||||
} catch (e: MalformedURLException) {
|
||||
// URL is not completely well-formed.
|
||||
} catch (e: URISyntaxException) {
|
||||
// URL is not completely well-formed.
|
||||
}
|
||||
|
||||
if (pathString.startsWith("file:")) {
|
||||
// Pass through the URL as-is, minus "file:" prefix
|
||||
pathString = pathString.substring(5)
|
||||
return Paths.get(pathString)
|
||||
}
|
||||
throw IllegalArgumentException("Invalid URL: $url")
|
||||
}
|
|
@ -1,7 +0,0 @@
|
|||
package com.rhubarb_lip_sync.rhubarb_for_spine
|
||||
|
||||
import javafx.application.Application
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
Application.launch(MainApp::class.java, *args)
|
||||
}
|
|
@ -1,75 +0,0 @@
|
|||
package com.rhubarb_lip_sync.rhubarb_for_spine
|
||||
|
||||
import javafx.application.Platform
|
||||
import javafx.beans.property.Property
|
||||
import java.util.concurrent.locks.ReentrantLock
|
||||
import kotlin.concurrent.withLock
|
||||
import java.io.PrintWriter
|
||||
import java.io.StringWriter
|
||||
|
||||
val List<String>.commonPrefix: String get() {
|
||||
return if (isEmpty()) "" else this.reduce { result, string -> result.commonPrefixWith(string) }
|
||||
}
|
||||
|
||||
val List<String>.commonSuffix: String get() {
|
||||
return if (isEmpty()) "" else this.reduce { result, string -> result.commonSuffixWith(string) }
|
||||
}
|
||||
|
||||
fun <TValue, TProperty : Property<TValue>> TProperty.alsoListen(listener: (TValue) -> Unit) : TProperty {
|
||||
// Notify the listener of the initial value.
|
||||
// If we did this synchronously, the listener's state would have to be fully initialized the
|
||||
// moment this function is called. So calling this function during object initialization might
|
||||
// result in access to uninitialized state.
|
||||
Platform.runLater { listener(this.value) }
|
||||
|
||||
addListener({ _, _, newValue -> listener(newValue)})
|
||||
return this
|
||||
}
|
||||
|
||||
fun getExceptionMessage(action: () -> Unit): String? {
|
||||
try {
|
||||
action()
|
||||
} catch (e: Exception) {
|
||||
return e.message
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
/**
|
||||
* Invokes a Runnable on the JFX thread and waits until it's finished.
|
||||
* Similar to SwingUtilities.invokeAndWait.
|
||||
* Based on http://www.guigarage.com/2013/01/invokeandwait-for-javafx/
|
||||
*
|
||||
* @throws InterruptedException Execution was interrupted
|
||||
* @throws Throwable An exception occurred in the run method of the Runnable
|
||||
*/
|
||||
fun runAndWait(action: () -> Unit) {
|
||||
if (Platform.isFxApplicationThread()) {
|
||||
action()
|
||||
} else {
|
||||
val lock = ReentrantLock()
|
||||
lock.withLock {
|
||||
val doneCondition = lock.newCondition()
|
||||
var throwable: Throwable? = null
|
||||
Platform.runLater {
|
||||
lock.withLock {
|
||||
try {
|
||||
action()
|
||||
} catch (e: Throwable) {
|
||||
throwable = e
|
||||
} finally {
|
||||
doneCondition.signal()
|
||||
}
|
||||
}
|
||||
}
|
||||
doneCondition.await()
|
||||
throwable?.let { throw it }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun getStackTrace(e: Exception): String {
|
||||
val stringWriter = StringWriter()
|
||||
e.printStackTrace(PrintWriter(stringWriter))
|
||||
return stringWriter.toString()
|
||||
}
|
Before Width: | Height: | Size: 742 B |
Before Width: | Height: | Size: 847 B |
Before Width: | Height: | Size: 1.0 KiB |
Before Width: | Height: | Size: 12 KiB |
Before Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 2.1 KiB |
Before Width: | Height: | Size: 2.9 KiB |
|
@ -1,121 +0,0 @@
|
|||
{
|
||||
"skeleton": { "hash": "voNIQumqp3+UQAl32SwHzLMEDaI", "spine": "3.7.04-beta", "width": 795, "height": 1249.62 },
|
||||
"bones": [
|
||||
{ "name": "root" },
|
||||
{ "name": "torso", "parent": "root", "length": 394.49, "rotation": 90, "y": 100 },
|
||||
{ "name": "head", "parent": "torso", "length": 515.83, "x": 390 },
|
||||
{ "name": "legs", "parent": "torso", "length": 79.85, "rotation": 180, "x": -6 }
|
||||
],
|
||||
"slots": [
|
||||
{ "name": "legs", "bone": "legs", "attachment": "legs" },
|
||||
{ "name": "torso", "bone": "torso", "attachment": "torso" },
|
||||
{ "name": "head", "bone": "head", "attachment": "head" },
|
||||
{ "name": "mouth", "bone": "head", "attachment": "mouth_d" }
|
||||
],
|
||||
"skins": {
|
||||
"default": {
|
||||
"head": {
|
||||
"head": { "x": 305.19, "y": -3.37, "rotation": -90, "width": 795, "height": 908 }
|
||||
},
|
||||
"legs": {
|
||||
"legs": { "x": 20.93, "y": 9.45, "rotation": 90, "width": 602, "height": 147 }
|
||||
},
|
||||
"mouth": {
|
||||
"mouth_a": { "x": -53.21, "y": -2.6, "rotation": -90, "width": 118, "height": 27 },
|
||||
"mouth_b": { "x": -38.68, "y": -0.88, "rotation": -90, "width": 170, "height": 59 },
|
||||
"mouth_c": { "x": -45.57, "y": -2.21, "rotation": -90, "width": 145, "height": 71 },
|
||||
"mouth_d": { "x": -50.58, "y": -16.55, "rotation": -90, "width": 122, "height": 91 },
|
||||
"mouth_e": { "x": -47.51, "y": 1.69, "rotation": -90, "width": 105, "height": 73 },
|
||||
"mouth_f": { "x": -42.7, "y": -1.9, "rotation": -90, "width": 55, "height": 54 },
|
||||
"mouth_g": { "x": -42.77, "y": 2.56, "rotation": -90, "width": 141, "height": 37 },
|
||||
"mouth_h": { "x": -44.53, "y": 1.07, "rotation": -90, "width": 141, "height": 71 }
|
||||
},
|
||||
"torso": {
|
||||
"torso": { "x": 185.9, "y": 0.39, "rotation": -90, "width": 741, "height": 449 }
|
||||
}
|
||||
}
|
||||
},
|
||||
"events": {
|
||||
"doornail": {
|
||||
"string": "Marley was dead: to begin with. There is no doubt whatever about that. The register of his burial was signed by the clergyman, the clerk, the undertaker, and the chief mourner. Scrooge signed it: and Scrooge's name was good upon 'Change, for anything he chose to put his hand to. Old Marley was as dead as a door-nail.Mind! I don't mean to say that I know, of my own knowledge, what there is particularly dead about a door-nail. I might have been inclined, myself, to regard a coffin-nail as the deadest piece of ironmongery in the trade. But the wisdom of our ancestors is in the simile; and my unhallowed hands shall not disturb it, or the Country's done for. You will therefore permit me to repeat, emphatically, that Marley was as dead as a door-nail.",
|
||||
"audio": "doornail.wav"
|
||||
},
|
||||
"hi": { "audio": "hi.wav" }
|
||||
},
|
||||
"animations": {
|
||||
"say_test": {
|
||||
"slots": {
|
||||
"mouth": {
|
||||
"attachment": [
|
||||
{ "time": 0, "name": "mouth_a" },
|
||||
{ "time": 0.1, "name": "mouth_b" },
|
||||
{ "time": 0.2, "name": "mouth_c" },
|
||||
{ "time": 0.2667, "name": "mouth_d" },
|
||||
{ "time": 0.3667, "name": "mouth_c" },
|
||||
{ "time": 0.4333, "name": "mouth_a" },
|
||||
{ "time": 0.5333, "name": "mouth_e" },
|
||||
{ "time": 0.6, "name": "mouth_f" },
|
||||
{ "time": 0.7, "name": "mouth_e" },
|
||||
{ "time": 0.8, "name": "mouth_g" },
|
||||
{ "time": 0.8667, "name": "mouth_c" },
|
||||
{ "time": 0.9667, "name": "mouth_h" },
|
||||
{ "time": 1.0667, "name": "mouth_a" }
|
||||
]
|
||||
}
|
||||
},
|
||||
"events": [
|
||||
{ "time": 0.8667, "name": "doornail", "string": "" }
|
||||
]
|
||||
},
|
||||
"shake_head": {
|
||||
"bones": {
|
||||
"head": {
|
||||
"rotate": [
|
||||
{
|
||||
"time": 0,
|
||||
"angle": 0,
|
||||
"curve": [ 0.25, 0, 0.75, 1 ]
|
||||
},
|
||||
{
|
||||
"time": 0.1667,
|
||||
"angle": 10.02,
|
||||
"curve": [ 0.25, 0, 0.75, 1 ]
|
||||
},
|
||||
{
|
||||
"time": 0.5,
|
||||
"angle": -9.37,
|
||||
"curve": [ 0.25, 0, 0.75, 1 ]
|
||||
},
|
||||
{
|
||||
"time": 0.8333,
|
||||
"angle": 10.39,
|
||||
"curve": [ 0.574, 0, 0.666, 1 ]
|
||||
},
|
||||
{ "time": 1.5, "angle": 0 }
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"walk": {
|
||||
"bones": {
|
||||
"torso": {
|
||||
"translate": [
|
||||
{
|
||||
"time": 0,
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"curve": [ 0, 0.5, 0.75, 1 ]
|
||||
},
|
||||
{
|
||||
"time": 0.1333,
|
||||
"x": 0,
|
||||
"y": 30,
|
||||
"curve": [ 0.25, 0, 1, 0.49 ]
|
||||
},
|
||||
{ "time": 0.2667, "x": 0, "y": 0 }
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,95 +0,0 @@
|
|||
{
|
||||
"skeleton": { "hash": "nWA5IiZBBeDJ6tKyTnjtIfu1GXE", "spine": "3.7.94", "width": 795, "height": 1249.62, "images": "./images/", "audio": "./audio/" },
|
||||
"bones": [
|
||||
{ "name": "root" },
|
||||
{ "name": "torso", "parent": "root", "length": 394.49, "rotation": 90, "y": 100 },
|
||||
{ "name": "head", "parent": "torso", "length": 515.83, "x": 390 },
|
||||
{ "name": "legs", "parent": "torso", "length": 79.85, "rotation": 180, "x": -6 }
|
||||
],
|
||||
"slots": [
|
||||
{ "name": "legs", "bone": "legs", "attachment": "legs" },
|
||||
{ "name": "torso", "bone": "torso", "attachment": "torso" },
|
||||
{ "name": "head", "bone": "head", "attachment": "head" },
|
||||
{ "name": "mouth", "bone": "head", "attachment": "mouth_c" }
|
||||
],
|
||||
"skins": {
|
||||
"default": {
|
||||
"head": {
|
||||
"head": { "x": 305.19, "y": -3.37, "rotation": -90, "width": 795, "height": 908 }
|
||||
},
|
||||
"legs": {
|
||||
"legs": { "x": 20.93, "y": 9.45, "rotation": 90, "width": 602, "height": 147 }
|
||||
},
|
||||
"mouth": {
|
||||
"mouth_a": { "x": -53.21, "y": -2.6, "rotation": -90, "width": 118, "height": 27 },
|
||||
"mouth_b": { "x": -38.68, "y": -0.88, "rotation": -90, "width": 170, "height": 59 },
|
||||
"mouth_c": { "x": -45.57, "y": -2.21, "rotation": -90, "width": 145, "height": 71 },
|
||||
"mouth_d": { "x": -50.58, "y": -16.55, "rotation": -90, "width": 122, "height": 91 },
|
||||
"mouth_e": { "x": -47.51, "y": 1.69, "rotation": -90, "width": 105, "height": 73 },
|
||||
"mouth_f": { "x": -42.7, "y": -1.9, "rotation": -90, "width": 55, "height": 54 },
|
||||
"mouth_g": { "x": -42.77, "y": 2.56, "rotation": -90, "width": 141, "height": 37 },
|
||||
"mouth_h": { "x": -44.53, "y": 1.07, "rotation": -90, "width": 141, "height": 71 }
|
||||
},
|
||||
"torso": {
|
||||
"torso": { "x": 185.9, "y": 0.39, "rotation": -90, "width": 741, "height": 449 }
|
||||
}
|
||||
}
|
||||
},
|
||||
"events": {
|
||||
"1-have-you-heard": { "audio": "1-have-you-heard.wav" },
|
||||
"2-it's-a-tool": { "audio": "2-it's-a-tool.wav" },
|
||||
"3-and-now-you-can": { "audio": "3-and-now-you-can.wav" }
|
||||
},
|
||||
"animations": {
|
||||
"shake_head": {
|
||||
"bones": {
|
||||
"head": {
|
||||
"rotate": [
|
||||
{
|
||||
"time": 0,
|
||||
"angle": 0,
|
||||
"curve": [ 0.25, 0, 0.75, 1 ]
|
||||
},
|
||||
{
|
||||
"time": 0.1667,
|
||||
"angle": 10.02,
|
||||
"curve": [ 0.25, 0, 0.75, 1 ]
|
||||
},
|
||||
{
|
||||
"time": 0.5,
|
||||
"angle": -9.37,
|
||||
"curve": [ 0.25, 0, 0.75, 1 ]
|
||||
},
|
||||
{
|
||||
"time": 0.8333,
|
||||
"angle": 10.39,
|
||||
"curve": [ 0.574, 0, 0.666, 1 ]
|
||||
},
|
||||
{ "time": 1.5, "angle": 0 }
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"walk": {
|
||||
"bones": {
|
||||
"torso": {
|
||||
"translate": [
|
||||
{
|
||||
"time": 0,
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"curve": [ 0, 0.5, 0.75, 1 ]
|
||||
},
|
||||
{
|
||||
"time": 0.1333,
|
||||
"x": 0,
|
||||
"y": 30,
|
||||
"curve": [ 0.25, 0, 1, 0.49 ]
|
||||
},
|
||||
{ "time": 0.2667, "x": 0, "y": 0 }
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,72 +0,0 @@
|
|||
{
|
||||
"skeleton": { "hash": "rSEJPpMBeapC2jv56cUew+IkQd0", "spine": "3.8.42-beta", "x": -394.13, "y": -0.43, "width": 795, "height": 1249.62 },
|
||||
"bones": [
|
||||
{ "name": "root" },
|
||||
{ "name": "torso", "parent": "root", "length": 394.49, "rotation": 90, "y": 100 },
|
||||
{ "name": "head", "parent": "torso", "length": 515.83, "x": 390 },
|
||||
{ "name": "legs", "parent": "torso", "length": 79.85, "rotation": 180, "x": -6 }
|
||||
],
|
||||
"slots": [
|
||||
{ "name": "legs", "bone": "legs", "attachment": "legs" },
|
||||
{ "name": "torso", "bone": "torso", "attachment": "torso" },
|
||||
{ "name": "head", "bone": "head", "attachment": "head" },
|
||||
{ "name": "mouth", "bone": "head", "attachment": "mouth_c" }
|
||||
],
|
||||
"skins": [
|
||||
{
|
||||
"name": "default",
|
||||
"attachments": {
|
||||
"mouth": {
|
||||
"mouth_a": { "x": -53.21, "y": -2.6, "rotation": -90, "width": 118, "height": 27 },
|
||||
"mouth_b": { "x": -38.68, "y": -0.88, "rotation": -90, "width": 170, "height": 59 },
|
||||
"mouth_c": { "x": -45.57, "y": -2.21, "rotation": -90, "width": 145, "height": 71 },
|
||||
"mouth_d": { "x": -50.58, "y": -16.55, "rotation": -90, "width": 122, "height": 91 },
|
||||
"mouth_e": { "x": -47.51, "y": 1.69, "rotation": -90, "width": 105, "height": 73 },
|
||||
"mouth_f": { "x": -42.7, "y": -1.9, "rotation": -90, "width": 55, "height": 54 },
|
||||
"mouth_g": { "x": -42.77, "y": 2.56, "rotation": -90, "width": 141, "height": 37 },
|
||||
"mouth_h": { "x": -44.53, "y": 1.07, "rotation": -90, "width": 141, "height": 71 }
|
||||
},
|
||||
"head": {
|
||||
"head": { "x": 305.19, "y": -3.37, "rotation": -90, "width": 795, "height": 908 }
|
||||
},
|
||||
"legs": {
|
||||
"legs": { "x": 20.93, "y": 9.45, "rotation": 90, "width": 602, "height": 147 }
|
||||
},
|
||||
"torso": {
|
||||
"torso": { "x": 185.9, "y": 0.39, "rotation": -90, "width": 741, "height": 449 }
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"events": {
|
||||
"1-have-you-heard": { "audio": "1-have-you-heard.wav" },
|
||||
"2-it's-a-tool": { "audio": "2-it's-a-tool.wav" },
|
||||
"3-and-now-you-can": { "audio": "3-and-now-you-can.wav" }
|
||||
},
|
||||
"animations": {
|
||||
"shake_head": {
|
||||
"bones": {
|
||||
"head": {
|
||||
"rotate": [
|
||||
{ "curve": 0.25, "c3": 0.75 },
|
||||
{ "time": 0.1667, "angle": 10.02, "curve": 0.25, "c3": 0.75 },
|
||||
{ "time": 0.5, "angle": -9.37, "curve": 0.25, "c3": 0.75 },
|
||||
{ "time": 0.8333, "angle": 10.39, "curve": 0.574, "c3": 0.666 },
|
||||
{ "time": 1.5 }
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"walk": {
|
||||
"bones": {
|
||||
"torso": {
|
||||
"translate": [
|
||||
{ "curve": 0, "c2": 0.5, "c3": 0.75 },
|
||||
{ "time": 0.1333, "y": 30, "curve": 0.25, "c4": 0.49 },
|
||||
{ "time": 0.2667 }
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,81 +0,0 @@
|
|||
{
|
||||
"skeleton": {
|
||||
"hash": "sH1atSHvppLIr/A6E6H7PXWiU4s",
|
||||
"spine": "3.8.42-beta",
|
||||
"x": -394.13,
|
||||
"y": -0.43,
|
||||
"width": 795,
|
||||
"height": 1249.62,
|
||||
"images": "./images/",
|
||||
"audio": "./audio/"
|
||||
},
|
||||
"bones": [
|
||||
{ "name": "root" },
|
||||
{ "name": "torso", "parent": "root", "length": 394.49, "rotation": 90, "y": 100 },
|
||||
{ "name": "head", "parent": "torso", "length": 515.83, "x": 390 },
|
||||
{ "name": "legs", "parent": "torso", "length": 79.85, "rotation": 180, "x": -6 }
|
||||
],
|
||||
"slots": [
|
||||
{ "name": "legs", "bone": "legs", "attachment": "legs" },
|
||||
{ "name": "torso", "bone": "torso", "attachment": "torso" },
|
||||
{ "name": "head", "bone": "head", "attachment": "head" },
|
||||
{ "name": "mouth", "bone": "head", "attachment": "mouth_c" }
|
||||
],
|
||||
"skins": [
|
||||
{
|
||||
"name": "default",
|
||||
"attachments": {
|
||||
"mouth": {
|
||||
"mouth_a": { "x": -53.21, "y": -2.6, "rotation": -90, "width": 118, "height": 27 },
|
||||
"mouth_b": { "x": -38.68, "y": -0.88, "rotation": -90, "width": 170, "height": 59 },
|
||||
"mouth_c": { "x": -45.57, "y": -2.21, "rotation": -90, "width": 145, "height": 71 },
|
||||
"mouth_d": { "x": -50.58, "y": -16.55, "rotation": -90, "width": 122, "height": 91 },
|
||||
"mouth_e": { "x": -47.51, "y": 1.69, "rotation": -90, "width": 105, "height": 73 },
|
||||
"mouth_f": { "x": -42.7, "y": -1.9, "rotation": -90, "width": 55, "height": 54 },
|
||||
"mouth_g": { "x": -42.77, "y": 2.56, "rotation": -90, "width": 141, "height": 37 },
|
||||
"mouth_h": { "x": -44.53, "y": 1.07, "rotation": -90, "width": 141, "height": 71 }
|
||||
},
|
||||
"head": {
|
||||
"head": { "x": 305.19, "y": -3.37, "rotation": -90, "width": 795, "height": 908 }
|
||||
},
|
||||
"legs": {
|
||||
"legs": { "x": 20.93, "y": 9.45, "rotation": 90, "width": 602, "height": 147 }
|
||||
},
|
||||
"torso": {
|
||||
"torso": { "x": 185.9, "y": 0.39, "rotation": -90, "width": 741, "height": 449 }
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"events": {
|
||||
"1-have-you-heard": { "audio": "1-have-you-heard.wav" },
|
||||
"2-it's-a-tool": { "audio": "2-it's-a-tool.wav" },
|
||||
"3-and-now-you-can": { "audio": "3-and-now-you-can.wav" }
|
||||
},
|
||||
"animations": {
|
||||
"shake_head": {
|
||||
"bones": {
|
||||
"head": {
|
||||
"rotate": [
|
||||
{ "curve": 0.25, "c3": 0.75 },
|
||||
{ "time": 0.1667, "angle": 10.02, "curve": 0.25, "c3": 0.75 },
|
||||
{ "time": 0.5, "angle": -9.37, "curve": 0.25, "c3": 0.75 },
|
||||
{ "time": 0.8333, "angle": 10.39, "curve": 0.574, "c3": 0.666 },
|
||||
{ "time": 1.5 }
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"walk": {
|
||||
"bones": {
|
||||
"torso": {
|
||||
"translate": [
|
||||
{ "curve": 0, "c2": 0.5, "c3": 0.75 },
|
||||
{ "time": 0.1333, "y": 30, "curve": 0.25, "c4": 0.49 },
|
||||
{ "time": 0.2667 }
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,69 +0,0 @@
|
|||
package com.rhubarb_lip_sync.rhubarb_for_spine
|
||||
|
||||
import org.junit.jupiter.api.Nested
|
||||
import org.junit.jupiter.api.Test
|
||||
import java.nio.file.Paths
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
import org.assertj.core.api.Assertions.catchThrowable
|
||||
|
||||
class SpineJsonTest {
|
||||
@Nested
|
||||
inner class `file format 3_7` {
|
||||
@Test
|
||||
fun `correctly reads valid file`() {
|
||||
val path = Paths.get("src/test/data/jsonFiles/matt-3.7.json").toAbsolutePath()
|
||||
val spine = SpineJson(path)
|
||||
|
||||
assertThat(spine.audioDirectoryPath)
|
||||
.isEqualTo(Paths.get("src/test/data/jsonFiles/audio").toAbsolutePath())
|
||||
assertThat(spine.frameRate).isEqualTo(30.0)
|
||||
assertThat(spine.slots).containsExactly("legs", "torso", "head", "mouth")
|
||||
assertThat(spine.guessMouthSlot()).isEqualTo("mouth")
|
||||
assertThat(spine.audioEvents).containsExactly(
|
||||
SpineJson.AudioEvent("1-have-you-heard", "1-have-you-heard.wav", null),
|
||||
SpineJson.AudioEvent("2-it's-a-tool", "2-it's-a-tool.wav", null),
|
||||
SpineJson.AudioEvent("3-and-now-you-can", "3-and-now-you-can.wav", null)
|
||||
)
|
||||
assertThat(spine.getSlotAttachmentNames("mouth")).isEqualTo(('a'..'h').map{ "mouth_$it" })
|
||||
assertThat(spine.animationNames).containsExactly("shake_head", "walk")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `throws on file without nonessential data`() {
|
||||
val path = Paths.get("src/test/data/jsonFiles/matt-3.7-essential.json").toAbsolutePath()
|
||||
val throwable = catchThrowable { SpineJson(path) }
|
||||
assertThat(throwable)
|
||||
.hasMessage("JSON file is incomplete: Images path is missing. Make sure to check 'Nonessential data' when exporting.")
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
inner class `file format 3_8` {
|
||||
@Test
|
||||
fun `correctly reads valid file`() {
|
||||
val path = Paths.get("src/test/data/jsonFiles/matt-3.8.json").toAbsolutePath()
|
||||
val spine = SpineJson(path)
|
||||
|
||||
assertThat(spine.audioDirectoryPath)
|
||||
.isEqualTo(Paths.get("src/test/data/jsonFiles/audio").toAbsolutePath())
|
||||
assertThat(spine.frameRate).isEqualTo(30.0)
|
||||
assertThat(spine.slots).containsExactly("legs", "torso", "head", "mouth")
|
||||
assertThat(spine.guessMouthSlot()).isEqualTo("mouth")
|
||||
assertThat(spine.audioEvents).containsExactly(
|
||||
SpineJson.AudioEvent("1-have-you-heard", "1-have-you-heard.wav", null),
|
||||
SpineJson.AudioEvent("2-it's-a-tool", "2-it's-a-tool.wav", null),
|
||||
SpineJson.AudioEvent("3-and-now-you-can", "3-and-now-you-can.wav", null)
|
||||
)
|
||||
assertThat(spine.getSlotAttachmentNames("mouth")).isEqualTo(('a'..'h').map{ "mouth_$it" })
|
||||
assertThat(spine.animationNames).containsExactly("shake_head", "walk")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `throws on file without nonessential data`() {
|
||||
val path = Paths.get("src/test/data/jsonFiles/matt-3.8-essential.json").toAbsolutePath()
|
||||
val throwable = catchThrowable { SpineJson(path) }
|
||||
assertThat(throwable)
|
||||
.hasMessage("JSON file is incomplete: Images path is missing. Make sure to check 'Nonessential data' when exporting.")
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1 +0,0 @@
|
|||
junit.jupiter.testinstance.lifecycle.default = per_class
|
|
@ -1,14 +0,0 @@
|
|||
cmake_minimum_required(VERSION 3.24)
|
||||
|
||||
set(vegasFiles
|
||||
"Debug Rhubarb.cs"
|
||||
"Debug Rhubarb.cs.config"
|
||||
"Import Rhubarb.cs"
|
||||
"Import Rhubarb.cs.config"
|
||||
"README.adoc"
|
||||
)
|
||||
|
||||
install(
|
||||
FILES ${vegasFiles}
|
||||
DESTINATION "extras/MagixVegas"
|
||||
)
|
|
@ -1,23 +0,0 @@
|
|||
= Scripts for Magix Vegas
|
||||
|
||||
If you own a copy of http://www.vegascreativesoftware.com/[Magix Vegas] (previously Sony Vegas), you can use this script to visualize Rhubarb Lip Sync’s output on the timeline. This can be useful for creating lip-synced videos or for debugging.
|
||||
|
||||
== Installation
|
||||
|
||||
Copy (or symlink) the files in this directory to `<Vegas installation directory>\Script Menu`. When you restart Vegas, you’ll find two new menu items:
|
||||
|
||||
* _Tools > Scripting > Import Rhubarb:_ This will create a new Vegas project and add two tracks: a video track with a visualization of Rhubarb Lip Sync’s output and an audio track with the original recording.
|
||||
* _Tools > Scripting > Debug Rhubarb:_ This will create markers or regions on the timeline visualizing Rhubarb Lip Sync’s internal data from a log file. You can obtain a log file by redirecting `+stdout+`. I’ve written this script mainly as a debugging aid for myself; feel free to contact me if you’re interested and need a more thorough explanation.
|
||||
|
||||
== How to perform lip sync
|
||||
|
||||
You cannot perform lip sync directly from the Vegas scripts. Instead, run Rhubarb Lip Sync from the command line, specifying the XML output format.
|
||||
|
||||
== How to create an animation
|
||||
|
||||
Select _Tools > Scripting > Import Rhubarb_. Fill in at least the following fields:
|
||||
|
||||
* One image file: You need a set of image files, one for each mouth shapes. All image files should have the same size and should end with "`-<mouth shape>`", for instance _alison-a.png_, _alison-b.png_, and so on. Click the "`...`" button at the right of this field and select one of these image files. The script will automatically find the other image files.
|
||||
* XML file: Click the "`...`" button at the right of this field and select the XML file created by Rhubarb Lip Sync.
|
||||
|
||||
Click _OK_ to create the animation.
|
|
@ -13,8 +13,8 @@ using System.Windows.Forms;
|
|||
using System.Windows.Forms.Design;
|
||||
using System.Xml;
|
||||
using System.Xml.Serialization;
|
||||
using ScriptPortal.Vegas; // For older versions, this should say Sony.Vegas
|
||||
using Region = ScriptPortal.Vegas.Region; // For older versions, this should say Sony.Vegas.Region
|
||||
using Sony.Vegas;
|
||||
using Region = Sony.Vegas.Region;
|
||||
|
||||
public class EntryPoint {
|
||||
public void FromVegas(Vegas vegas) {
|
||||
|
@ -49,15 +49,7 @@ public class EntryPoint {
|
|||
List<TimedEvent> filteredEvents = FilterEvents(timedEvents[eventType], visualization.Regex);
|
||||
foreach (TimedEvent timedEvent in filteredEvents) {
|
||||
Timecode start = Timecode.FromSeconds(timedEvent.Start);
|
||||
Timecode end = Timecode.FromSeconds(timedEvent.End);
|
||||
Timecode length = end - start;
|
||||
if (config.LoopRegionOnly) {
|
||||
Timecode loopRegionStart = vegas.Transport.LoopRegionStart;
|
||||
Timecode loopRegionEnd = loopRegionStart + vegas.Transport.LoopRegionLength;
|
||||
if (start < loopRegionStart || start > loopRegionEnd || end < loopRegionStart || end > loopRegionEnd) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
Timecode length = Timecode.FromSeconds(timedEvent.End) - start;
|
||||
switch (visualization.VisualizationType) {
|
||||
case VisualizationType.Marker:
|
||||
project.Markers.Add(new Marker(start, timedEvent.Value));
|
||||
|
@ -157,7 +149,6 @@ public class Config {
|
|||
private string logFile;
|
||||
private bool clearMarkers;
|
||||
private bool clearRegions;
|
||||
private bool loopRegionOnly;
|
||||
private List<Visualization> visualizations = new List<Visualization>();
|
||||
|
||||
[DisplayName("Log File")]
|
||||
|
@ -182,13 +173,6 @@ public class Config {
|
|||
set { clearRegions = value; }
|
||||
}
|
||||
|
||||
[DisplayName("Loop region only")]
|
||||
[Description("Adds regions or markers to the loop region only.")]
|
||||
public bool LoopRegionOnly {
|
||||
get { return loopRegionOnly; }
|
||||
set { loopRegionOnly = value; }
|
||||
}
|
||||
|
||||
[DisplayName("Visualization rules")]
|
||||
[Description("Specify how to visualize various log events.")]
|
||||
[Editor(typeof(CollectionEditor), typeof(UITypeEditor))]
|
||||
|
@ -274,10 +258,8 @@ public class Visualization {
|
|||
public enum EventType {
|
||||
Utterance,
|
||||
Word,
|
||||
RawPhone,
|
||||
Phone,
|
||||
Shape,
|
||||
Segment
|
||||
Shape
|
||||
}
|
||||
|
||||
public enum VisualizationType {
|
|
@ -11,7 +11,7 @@ using System.Windows.Forms;
|
|||
using System.Windows.Forms.Design;
|
||||
using System.Xml;
|
||||
using System.Xml.Serialization;
|
||||
using ScriptPortal.Vegas; // For older versions, this should say Sony.Vegas
|
||||
using Sony.Vegas;
|
||||
|
||||
public class EntryPoint {
|
||||
public void FromVegas(Vegas vegas) {
|
|
@ -0,0 +1,8 @@
|
|||
# Scripts for Sony Vegas
|
||||
|
||||
If you own a copy of [Sony Vegas](http://www.sonycreativesoftware.com/vegassoftware), you can use this script to visualize Rhubarb Lip Sync's output on the timeline. This can be useful for creating lip-synced videos or for debugging.
|
||||
|
||||
Copy (or symlink) the files in this directory to `<Vegas installation directory>\Script Menu`. When you restart Vegas, you'll find two new menu items:
|
||||
|
||||
* *Tools > Scripting > Import Rhubarb:* This will create a new Vegas project and add two tracks: a video track with a visualization of Rhubarb Lip-Sync's output and an audio track with the original recording.
|
||||
* *Tools > Scripting > Debug Rhubarb:* This will create markers or regions on the timeline visualizing Rhubarb Lip-Sync's internal data from a log file. You can obtain a log file by redirecting `stdout`. I've written this script mainly as a debugging aid for myself; feel free to contact me if you're interested and need a more thorough explanation.
|
Before Width: | Height: | Size: 48 KiB |
After Width: | Height: | Size: 1023 B |
After Width: | Height: | Size: 1.0 KiB |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.0 KiB |
After Width: | Height: | Size: 1.0 KiB |
After Width: | Height: | Size: 981 B |
After Width: | Height: | Size: 1.1 KiB |
BIN
img/lisa-A.png
Before Width: | Height: | Size: 6.5 KiB |
BIN
img/lisa-B.png
Before Width: | Height: | Size: 10 KiB |
BIN
img/lisa-C.png
Before Width: | Height: | Size: 12 KiB |
BIN
img/lisa-D.png
Before Width: | Height: | Size: 14 KiB |
BIN
img/lisa-E.png
Before Width: | Height: | Size: 9.3 KiB |
BIN
img/lisa-F.png
Before Width: | Height: | Size: 7.0 KiB |
BIN
img/lisa-G.png
Before Width: | Height: | Size: 5.9 KiB |
BIN
img/lisa-H.png
Before Width: | Height: | Size: 13 KiB |
BIN
img/lisa-X.png
Before Width: | Height: | Size: 7.2 KiB |
BIN
img/logo.png
Before Width: | Height: | Size: 4.1 KiB |
BIN
img/moho.png
Before Width: | Height: | Size: 106 KiB |
|
@ -1,46 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Generator: Adobe Illustrator 19.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||
width="70px" height="70px" viewBox="0 0 70 70" style="enable-background:new 0 0 70 70;" xml:space="preserve">
|
||||
<g>
|
||||
<g>
|
||||
<g>
|
||||
<linearGradient id="SVGID_1_" gradientUnits="userSpaceOnUse" x1="8.0628" y1="16.1412" x2="29.2598" y2="69.7572">
|
||||
<stop offset="0.2204" style="stop-color:#C40B55"/>
|
||||
<stop offset="0.6828" style="stop-color:#E343E6"/>
|
||||
<stop offset="0.9247" style="stop-color:#F59252"/>
|
||||
</linearGradient>
|
||||
<polygon style="fill:url(#SVGID_1_);" points="20.2,15.2 34,36.7 11.6,70 0,23.1 "/>
|
||||
|
||||
<linearGradient id="SVGID_2_" gradientUnits="userSpaceOnUse" x1="875.7187" y1="73.2924" x2="927.5556" y2="18.1521" gradientTransform="matrix(-1 0 0 1 928 -2.064169e-004)">
|
||||
<stop offset="0.1129" style="stop-color:#FFBD00"/>
|
||||
<stop offset="0.586" style="stop-color:#E343E6"/>
|
||||
<stop offset="0.8172" style="stop-color:#EC841B"/>
|
||||
<stop offset="0.9355" style="stop-color:#FFBD00"/>
|
||||
</linearGradient>
|
||||
<polygon style="fill:url(#SVGID_2_);" points="18.9,15.7 21,0 51.2,33.6 42.4,42.3 49.2,70 11.6,70 "/>
|
||||
</g>
|
||||
<linearGradient id="SVGID_3_" gradientUnits="userSpaceOnUse" x1="25.5002" y1="-1.9302" x2="69.9604" y2="51.1679">
|
||||
<stop offset="0.129" style="stop-color:#FFBD00"/>
|
||||
<stop offset="0.6398" style="stop-color:#E343E6"/>
|
||||
<stop offset="0.9086" style="stop-color:#C40B55"/>
|
||||
</linearGradient>
|
||||
<polygon style="fill:url(#SVGID_3_);" points="35.3,47.1 70,47.1 58.4,0 21,0 "/>
|
||||
</g>
|
||||
<g>
|
||||
<g>
|
||||
<rect x="13.4" y="13.4" style="fill:#000000;" width="43.2" height="43.2"/>
|
||||
<path style="fill:#FFFFFF;" d="M17.4,19h8.2c2.3,0,4,0.6,5.2,1.8c1,1,1.5,2.4,1.5,4.1V25c0,1.5-0.4,2.6-1.1,3.5
|
||||
c-0.7,0.9-1.6,1.6-2.8,2l4.4,6.4h-4.6l-3.7-5.5h-3.3l0,5.5h-3.9V19z M25.4,27.7c1,0,1.7-0.2,2.2-0.7c0.5-0.5,0.8-1.1,0.8-1.8
|
||||
v-0.1c0-0.9-0.3-1.5-0.8-1.9c-0.5-0.4-1.3-0.6-2.3-0.6h-3.9v5.1H25.4z"/>
|
||||
<rect x="17.4" y="48.5" style="fill:#FFFFFF;" width="16.2" height="2.7"/>
|
||||
</g>
|
||||
<g>
|
||||
<path style="fill:#FFFFFF;" d="M43.7,24.4h-4v-3.6h4v-4h3.7v4h4v3.6h-4v4h-3.7V24.4z"/>
|
||||
</g>
|
||||
<g>
|
||||
<path style="fill:#FFFFFF;" d="M37.1,34.6h-4V31h4v-4h3.7v4h4v3.6h-4v4h-3.7V34.6z"/>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
Before Width: | Height: | Size: 2.4 KiB |
BIN
img/spine.png
Before Width: | Height: | Size: 52 KiB |
BIN
img/vegas.png
Before Width: | Height: | Size: 31 KiB |
Before Width: | Height: | Size: 62 KiB After Width: | Height: | Size: 62 KiB |