summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--GUI/GUI/GUI/Frame.cpp83
-rw-r--r--GUI/GUI/GUI/Frame.h2
-rw-r--r--GUI/GUI/GUI/PythonWrapper.cpp65
-rw-r--r--GUI/GUI/GUI/PythonWrapper.h11
-rw-r--r--Scripts/libtastt.py28
-rw-r--r--Scripts/libunity.py4
-rw-r--r--Scripts/transcribe.py3
-rw-r--r--UnityAssets/TaSTT.fbx (renamed from TaSTT.fbx)bin18172 -> 18172 bytes
-rw-r--r--UnityAssets/TaSTT_Menu.asset (renamed from TaSTT_Menu.asset)0
9 files changed, 170 insertions, 26 deletions
diff --git a/GUI/GUI/GUI/Frame.cpp b/GUI/GUI/GUI/Frame.cpp
index d535f85..1645258 100644
--- a/GUI/GUI/GUI/Frame.cpp
+++ b/GUI/GUI/GUI/Frame.cpp
@@ -31,6 +31,7 @@ namespace {
ID_UNITY_PANEL,
ID_UNITY_CONFIG_PANEL,
ID_UNITY_OUT,
+ ID_UNITY_ASSETS_FILE_PICKER,
ID_UNITY_ANIMATOR_FILE_PICKER,
ID_UNITY_PARAMETERS_FILE_PICKER,
ID_UNITY_MENU_FILE_PICKER,
@@ -281,6 +282,14 @@ Frame::Frame()
{
auto* unity_config_panel_pairs = new wxPanel(unity_config_panel, ID_UNITY_CONFIG_PANEL_PAIRS);
{
+ auto* unity_assets_file_picker = new wxDirPickerCtrl(
+ unity_config_panel_pairs,
+ ID_UNITY_ASSETS_FILE_PICKER,
+ /*path=*/wxEmptyString,
+ /*message=*/"Unity Assets folder"
+ );
+ unity_assets_file_picker_ = unity_assets_file_picker;
+
auto* unity_animator_file_picker = new wxFilePickerCtrl(
unity_config_panel_pairs,
ID_UNITY_ANIMATOR_FILE_PICKER,
@@ -312,7 +321,7 @@ Frame::Frame()
/*pos=*/wxDefaultPosition,
/*size=*/wxDefaultSize
);
- unity_parameters_file_picker_ = unity_parameters_file_picker;
+ unity_menu_file_picker_ = unity_menu_file_picker;
auto* unity_animator_generated_dir = new wxTextCtrl(unity_config_panel_pairs,
ID_UNITY_ANIMATOR_GENERATED_DIR,
@@ -339,6 +348,9 @@ Frame::Frame()
auto* sizer = new wxFlexGridSizer(/*cols=*/2);
unity_config_panel_pairs->SetSizer(sizer);
+ sizer->Add(new wxStaticText(unity_config_panel_pairs, wxID_ANY, /*label=*/"Unity Assets folder:"));
+ sizer->Add(unity_assets_file_picker);
+
sizer->Add(new wxStaticText(unity_config_panel_pairs, wxID_ANY, /*label=*/"FX controller:"));
sizer->Add(unity_animator_file_picker);
@@ -477,7 +489,64 @@ void Frame::OnDumpMics(wxCommandEvent& event)
transcribe_out_->AppendText(PythonWrapper::DumpMics());
}
-void Frame::OnGenerateFX(wxCommandEvent& event) {
+#define DEBUG
+
+void Frame::OnGenerateFX(wxCommandEvent& event)
+{
+ std::filesystem::path unity_assets_path = unity_assets_file_picker_->GetPath().ToStdString();
+#ifndef DEBUG
+ if (!std::filesystem::exists(unity_assets_path)) {
+ std::ostringstream oss;
+ oss << "Cannot generate FX layer: assets directory does not exist at " << unity_assets_path << std::endl;
+ wxLogError(oss.str().c_str());
+ return;
+ }
+#endif
+ std::filesystem::path unity_animator_path = unity_animator_file_picker_->GetPath().ToStdString();
+#ifndef DEBUG
+ if (!std::filesystem::exists(unity_animator_path)) {
+ std::ostringstream oss;
+ oss << "Cannot generate FX layer: animator does not exist at " << unity_animator_path << std::endl;
+ wxLogError(oss.str().c_str());
+ return;
+ }
+#endif
+ std::filesystem::path unity_parameters_path = unity_parameters_file_picker_->GetPath().ToStdString();
+#ifndef DEBUG
+ if (!std::filesystem::exists(unity_parameters_path)) {
+ std::ostringstream oss;
+ oss << "Cannot generate FX layer: parameters do not exist at " << unity_parameters_path << std::endl;
+ wxLogError(oss.str().c_str());
+ return;
+ }
+#endif
+ std::filesystem::path unity_menu_path = unity_menu_file_picker_->GetPath().ToStdString();
+#ifndef DEBUG
+ if (!std::filesystem::exists(unity_menu_path)) {
+ std::ostringstream oss;
+ oss << "Cannot generate FX layer: menu does not exist at " << unity_menu_path << std::endl;
+ wxLogError(oss.str().c_str());
+ return;
+ }
+#endif
+ std::string unity_animator_generated_dir = unity_animator_generated_dir_->GetLineText(0).ToStdString();
+ std::string unity_animator_generated_name = unity_animator_generated_name_->GetLineText(0).ToStdString();
+ std::string unity_parameters_generated_name = unity_parameters_generated_name_->GetLineText(0).ToStdString();
+ std::string unity_menu_generated_name = unity_menu_generated_name_->GetLineText(0).ToStdString();
+
+ std::string out;
+ if (!PythonWrapper::GenerateAnimator(
+ unity_assets_path.string(),
+ unity_animator_path.string(),
+ unity_parameters_path.string(),
+ unity_menu_path.string(),
+ unity_animator_generated_dir,
+ unity_animator_generated_name,
+ unity_parameters_generated_name,
+ unity_menu_generated_name,
+ unity_out_)) {
+ wxLogError("Failed to generate animator:\n%s\n", out.c_str());
+ }
}
void Frame::OnAppStart(wxCommandEvent& event) {
@@ -582,22 +651,12 @@ void Frame::DrainApp(wxProcess* proc, std::ostringstream& oss) {
return;
}
- bool first = true;
while (proc->IsInputAvailable()) {
- if (first) {
- first = false;
- oss << " " << "stdout:" << std::endl;
- }
wxTextInputStream iss(*(proc->GetInputStream()));
oss << " " << iss.ReadLine() << std::endl;
}
- first = true;
while (proc->IsErrorAvailable()) {
- if (first) {
- first = false;
- oss << " " << "stderr:" << std::endl;
- }
wxTextInputStream iss(*(proc->GetErrorStream()));
oss << " " << iss.ReadLine() << std::endl;
}
diff --git a/GUI/GUI/GUI/Frame.h b/GUI/GUI/GUI/Frame.h
index 35922a1..1d847ca 100644
--- a/GUI/GUI/GUI/Frame.h
+++ b/GUI/GUI/GUI/Frame.h
@@ -29,8 +29,10 @@ private:
wxTextCtrl* unity_parameters_generated_name_;
wxTextCtrl* unity_menu_generated_name_;
+ wxDirPickerCtrl* unity_assets_file_picker_;
wxFilePickerCtrl* unity_animator_file_picker_;
wxFilePickerCtrl* unity_parameters_file_picker_;
+ wxFilePickerCtrl* unity_menu_file_picker_;
wxChoice* py_app_mic_;
wxChoice* py_app_lang_;
diff --git a/GUI/GUI/GUI/PythonWrapper.cpp b/GUI/GUI/GUI/PythonWrapper.cpp
index 0878560..62a002a 100644
--- a/GUI/GUI/GUI/PythonWrapper.cpp
+++ b/GUI/GUI/GUI/PythonWrapper.cpp
@@ -2,6 +2,7 @@
#include <stdio.h>
+#include <filesystem>
#include <sstream>
class PythonProcess : public wxProcess {
@@ -130,3 +131,67 @@ wxProcess* PythonWrapper::StartApp(
std::move(exit_callback));
}
+bool PythonWrapper::GenerateAnimator(
+ const std::string& unity_assets_path,
+ const std::string& unity_animator_path,
+ const std::string& unity_parameters_path,
+ const std::string& unity_menu_path,
+ const std::string& unity_animator_generated_dir,
+ const std::string& unity_animator_generated_name,
+ const std::string& unity_parameters_generated_name,
+ const std::string& unity_menu_generated_name,
+ wxTextCtrl* out) {
+ // Python script locations
+ std::string libunity_path = "Resources/Scripts/libunity.py";
+ std::string libtastt_path = "Resources/Scripts/libtastt.py";
+
+ // Generated directory locations
+ std::filesystem::path tastt_generated_dir_path =
+ std::filesystem::path(unity_assets_path) / unity_animator_generated_dir;
+ std::filesystem::path guid_map_path =
+ tastt_generated_dir_path / "guid.map";
+ std::filesystem::path tastt_animations_path =
+ tastt_generated_dir_path / "Animations";
+ std::filesystem::path tastt_animator_path =
+ tastt_generated_dir_path / unity_animator_generated_name;
+ std::filesystem::path tastt_params_path =
+ tastt_generated_dir_path / unity_parameters_generated_name;
+ std::filesystem::path tastt_menu_path =
+ tastt_generated_dir_path / unity_menu_generated_name;
+
+ {
+ out->AppendText("Generating guid.map... ");
+ std::string py_stdout, py_stderr;
+ if (InvokeWithArgs({ libunity_path, "guid_map",
+ "--project_root", unity_assets_path,
+ "--save_to", guid_map_path.string() },
+ &py_stdout, &py_stderr)) {
+ out->AppendText("success!\n");
+ out->AppendText(py_stdout.c_str());
+ out->AppendText(py_stderr.c_str());
+ }
+ else {
+ wxLogError("Failed to generate guid.map: %s", py_stderr.c_str());
+ out->AppendText("failed!\n");
+ }
+ }
+ {
+ out->AppendText("Generating animations... ");
+ std::string py_stdout, py_stderr;
+ if (InvokeWithArgs({ libtastt_path, "gen_anims",
+ "--gen_anim_dir", tastt_animations_path.string(),
+ "--guid_map", guid_map_path.string() },
+ &py_stdout, &py_stderr)) {
+ out->AppendText("success!\n");
+ out->AppendText(py_stdout.c_str());
+ out->AppendText(py_stderr.c_str());
+ }
+ else {
+ wxLogError("Failed to generate animations: %s", py_stderr.c_str());
+ out->AppendText("failed!\n");
+ }
+ }
+
+ return true;
+}
+
diff --git a/GUI/GUI/GUI/PythonWrapper.h b/GUI/GUI/GUI/PythonWrapper.h
index 6c90087..de5a2e4 100644
--- a/GUI/GUI/GUI/PythonWrapper.h
+++ b/GUI/GUI/GUI/PythonWrapper.h
@@ -39,5 +39,16 @@ namespace PythonWrapper
wxProcess* StartApp(
std::function<void(wxProcess* proc, int ret)>&& exit_callback,
const std::string& mic, const std::string& lang, const std::string& model);
+
+ bool GenerateAnimator(
+ const std::string& unity_assets_path,
+ const std::string& unity_animator_path,
+ const std::string& unity_parameters_path,
+ const std::string& unity_menu_path,
+ const std::string& unity_animator_generated_dir,
+ const std::string& unity_animator_generated_name,
+ const std::string& unity_parameters_generated_name,
+ const std::string& unity_menu_generated_name,
+ wxTextCtrl* out);
};
diff --git a/Scripts/libtastt.py b/Scripts/libtastt.py
index bee535f..f448117 100644
--- a/Scripts/libtastt.py
+++ b/Scripts/libtastt.py
@@ -179,7 +179,8 @@ def generateClearAnimation(anim_dir, guid_map):
anim_clip.mapping['m_EditorCurves'].sequence.append(curve)
# Serialize animation to file
anim_name = generate_utils.getClearAnimationName()
- anim_path = anim_dir + anim_name + ".anim"
+ anim_path = os.path.join(anim_dir, anim_name + ".anim")
+ print("Generating clear animation at {}".format(anim_path))
with open(anim_path, "w") as f:
f.write(libunity.unityYamlToString([anim_node]))
# Generate metadata
@@ -221,7 +222,8 @@ def generateToggleAnimations(anim_dir, shader_param, guid_map):
anim_suffix = "_Off"
if shader_value == 1:
anim_suffix = "_On"
- anim_path = anim_dir + shader_param + anim_suffix + ".anim"
+ anim_path = os.path.join(anim_dir, shader_param + anim_suffix +
+ ".anim")
with open(anim_path, "w") as f:
f.write(libunity.unityYamlToString([anim_node]))
# Generate metadata
@@ -261,7 +263,7 @@ def generateFloatAnimation(anim_name: str, anim_dir: str,
anim_clip.mapping['m_EditorCurves'].sequence.append(curve)
# Serialize animation to file
- anim_path = anim_dir + anim_name + ".anim"
+ anim_path = os.path.join(anim_dir, anim_name + ".anim")
with open(anim_path, "w") as f:
f.write(libunity.unityYamlToString([anim_node]))
# Generate metadata
@@ -275,10 +277,10 @@ def generateFloatAnimation(anim_name: str, anim_dir: str,
return meta.guid
def generateAnimations(anim_dir, guid_map):
- generateClearAnimation(args.gen_anim_dir, guid_map)
+ generateClearAnimation(anim_dir, guid_map)
- generateToggleAnimations(args.gen_anim_dir, generate_utils.getIndicator0Param(), guid_map)
- generateToggleAnimations(args.gen_anim_dir, generate_utils.getIndicator1Param(), guid_map)
+ generateToggleAnimations(anim_dir, generate_utils.getIndicator0Param(), guid_map)
+ generateToggleAnimations(anim_dir, generate_utils.getIndicator1Param(), guid_map)
print("Generating letter animations", file=sys.stderr)
@@ -318,7 +320,7 @@ def generateAnimations(anim_dir, guid_map):
clip.mapping['m_FloatCurves'].sequence.append(curve)
clip.mapping['m_EditorCurves'].sequence.append(curve)
# Serialize animation to file
- anim_path = anim_dir + anim_name + ".anim"
+ anim_path = os.path.join(anim_dir, anim_name + ".anim")
with open(anim_path, "w") as f:
f.write(libunity.unityYamlToString([node]))
# Generate metadata
@@ -378,15 +380,15 @@ def generateFXLayer(which_layer: int, anim: libunity.UnityAnimator, layer:
dy = 200
# Create blend tree for this region.
- anim_lo_path = gen_anim_dir + \
+ anim_lo_path = os.path.join(gen_anim_dir,
generate_utils.getAnimationNameByLayerAndIndex(
which_layer, i, 0, byte) + \
- ".anim"
+ ".anim")
guid_lo = guid_map[anim_lo_path]
- anim_hi_path = gen_anim_dir + \
+ anim_hi_path = os.path.join(gen_anim_dir,
generate_utils.getAnimationNameByLayerAndIndex(
which_layer, i, generate_utils.CHARS_PER_CELL - 1, byte) + \
- ".anim"
+ ".anim")
guid_hi = guid_map[anim_hi_path]
select_states[i] = anim.addAnimatorBlendTree(layer,
@@ -430,13 +432,13 @@ def generateToggle(layer_name: str,
on_state = anim.addAnimatorState(layer, layer_name + "_On", dy=100)
if off_anim_basename:
- off_anim_path = gen_anim_dir + off_anim_basename
+ off_anim_path = os.path.join(gen_anim_dir, off_anim_basename)
off_anim_meta = libunity.Metadata()
off_anim_meta.load(off_anim_path)
anim.setAnimatorStateAnimation(off_state, off_anim_meta.guid)
if on_anim_basename:
- on_anim_path = gen_anim_dir + on_anim_basename
+ on_anim_path = os.path.join(gen_anim_dir, on_anim_basename)
on_anim_meta = libunity.Metadata()
on_anim_meta.load(on_anim_path)
anim.setAnimatorStateAnimation(on_state, on_anim_meta.guid)
diff --git a/Scripts/libunity.py b/Scripts/libunity.py
index f9e9e28..7223568 100644
--- a/Scripts/libunity.py
+++ b/Scripts/libunity.py
@@ -1259,6 +1259,10 @@ if __name__ == "__main__":
print("Looking up GUIDs under {}".format(args.project_root),
file=sys.stderr)
guid_map = getGuidMap(args.project_root)
+
+ save_to_dir = os.path.dirname(args.save_to)
+ os.makedirs(save_to_dir, exist_ok=True)
+
if args.guid_map_append:
tmp_map = {}
with open(args.save_to, "rb") as f:
diff --git a/Scripts/transcribe.py b/Scripts/transcribe.py
index 0f7ae37..831ae66 100644
--- a/Scripts/transcribe.py
+++ b/Scripts/transcribe.py
@@ -94,6 +94,8 @@ def onAudioFramesAvailable(
frame_count,
time_info,
status_flags):
+ if audio_state.audio_paused:
+ return (frames, pyaudio.paContinue)
# Reduce sample rate from mic rate to Whisper rate by dropping frames.
decimated = b''
@@ -207,7 +209,6 @@ def transcribe(audio_state, model, frames):
#for temp in (0.00, 0.05, 0.10, 0.15, 0.20):
#for temp in (0.00, 0.05):
for temp in (0.00,):
- print("temp: {}".format(temp))
options = whisper.DecodingOptions(language = audio_state.language,
beam_size = 5, temperature = temp, without_timestamps = True)
result = whisper.decode(model, mel, options)
diff --git a/TaSTT.fbx b/UnityAssets/TaSTT.fbx
index d6737d0..d6737d0 100644
--- a/TaSTT.fbx
+++ b/UnityAssets/TaSTT.fbx
Binary files differ
diff --git a/TaSTT_Menu.asset b/UnityAssets/TaSTT_Menu.asset
index 77628bd..77628bd 100644
--- a/TaSTT_Menu.asset
+++ b/UnityAssets/TaSTT_Menu.asset