diff options
| author | yum <yum.food.vr@gmail.com> | 2022-12-30 02:25:50 -0800 |
|---|---|---|
| committer | yum <yum.food.vr@gmail.com> | 2022-12-30 02:33:07 -0800 |
| commit | d9a0224466189d0fe1d46f21d586fa8a1a58c687 (patch) | |
| tree | 3431bad18d46b7bdbad91caa508cb65f859f0276 | |
| parent | 7bc6ee5f7f163b35e9de0a368406978d144be5c5 (diff) | |
Bugfix: regions truncate correctly at page boundaries
Boards whose size is an even multiple of CHARS_PER_SYNC would lose the
entire last region.
* Attempt to fix runaway memory usage of GUI text frames, but this needs
more work
| -rw-r--r-- | GUI/GUI/GUI/Frame.cpp | 10 | ||||
| -rw-r--r-- | GUI/GUI/GUI/Logging.h | 5 | ||||
| -rw-r--r-- | Scripts/osc_ctrl.py | 5 | ||||
| -rw-r--r-- | Scripts/transcribe.py | 9 |
4 files changed, 19 insertions, 10 deletions
diff --git a/GUI/GUI/GUI/Frame.cpp b/GUI/GUI/GUI/Frame.cpp index 9a43a25..bd4bbec 100644 --- a/GUI/GUI/GUI/Frame.cpp +++ b/GUI/GUI/GUI/Frame.cpp @@ -780,11 +780,11 @@ void Frame::OnGenerateFX(wxCommandEvent& event) rows = std::stoi(rows_str);
cols = std::stoi(cols_str);
}
- catch (const std::invalid_argument& e) {
+ catch (const std::invalid_argument&) {
Log(unity_out_, "Could not parse rows \"{}\" or cols \"{}\" as an integer\n", rows_str, cols_str);
return;
}
- catch (const std::out_of_range& e) {
+ catch (const std::out_of_range&) {
Log(unity_out_, "Rows \"{}\" or cols \"{}\" are out of range\n", rows_str, cols_str);
return;
}
@@ -841,7 +841,7 @@ void Frame::OnUnityParamChangeImpl() { int misc_bits = 9;
int total_bits = select_bits + layer_bits + scale_bits + misc_bits;
Log(unity_out_, "This configuration will use {} bits of avatar parameter space:\n", total_bits);
- Log(unity_out_, " {} bits coming from ({} chars per sync) * ({} bytes per char)\n", layer_bits, chars_per_sync, bytes_per_char);
+ Log(unity_out_, " {} bits coming from ({} characters per sync) * ({} bytes per character)\n", layer_bits, chars_per_sync, bytes_per_char);
Log(unity_out_, " {} bits coming from fixed overheads\n", select_bits + scale_bits + misc_bits);
}
@@ -897,11 +897,11 @@ void Frame::OnAppStart(wxCommandEvent& event) { cols = std::stoi(cols_str);
window_duration = std::stoi(window_duration_str);
}
- catch (const std::invalid_argument& e) {
+ catch (const std::invalid_argument&) {
Log(transcribe_out_, "Could not parse rows \"{}\", cols \"{}\", or window duration \"{}\" as an integer\n", rows_str, cols_str);
return;
}
- catch (const std::out_of_range& e) {
+ catch (const std::out_of_range&) {
Log(transcribe_out_, "Rows \"{}\", cols \"{}\", or window duration \"{}\" are out of range\n", rows_str, cols_str, window_duration);
return;
}
diff --git a/GUI/GUI/GUI/Logging.h b/GUI/GUI/GUI/Logging.h index 95e7802..6c1bf16 100644 --- a/GUI/GUI/GUI/Logging.h +++ b/GUI/GUI/GUI/Logging.h @@ -25,6 +25,11 @@ namespace Logging { const std::string raw = std::vformat(format, std::make_format_args(args...));
const std::string masked = HidePII(std::move(raw));
frame->AppendText(masked);
+ // Limit log to 10 MB to avoid runaway memory usage.
+ const int max_frame_len_bytes = 10 * 1000 * 1000;
+ if (frame->GetLastPosition() > max_frame_len_bytes) {
+ frame->Remove(0, frame->GetLastPosition() - max_frame_len_bytes);
+ }
}
}
diff --git a/Scripts/osc_ctrl.py b/Scripts/osc_ctrl.py index 422d854..7c7d0ae 100644 --- a/Scripts/osc_ctrl.py +++ b/Scripts/osc_ctrl.py @@ -100,7 +100,6 @@ def pageMessage(osc_state: OscState, msg: str) -> bool: # Really long messages just wrap back around. which_region = (slice_idx % generate_utils.config.numRegions(0)) - #print("send to region {}".format(which_region)) # if in last region: # how long is it @@ -109,12 +108,16 @@ def pageMessage(osc_state: OscState, msg: str) -> bool: #print("num regions: {}".format(num_regions)) if which_region == num_regions - 1: layers_in_last_region = num_cells % generate_utils.config.CHARS_PER_SYNC + if layers_in_last_region == 0: + layers_in_last_region = generate_utils.config.CHARS_PER_SYNC #print("layers in last region: {}".format(layers_in_last_region)) old_len = len(msg_slice) msg_slice = msg_slice[0:layers_in_last_region] #print("truncate msg_slice from length {} to length {}".format(old_len, # len(msg_slice))) + #print("send \"{}\" to region {}".format(msg_slice, which_region)) + enable(osc_state.client) # Seek to the current region. diff --git a/Scripts/transcribe.py b/Scripts/transcribe.py index f90867a..8491e4d 100644 --- a/Scripts/transcribe.py +++ b/Scripts/transcribe.py @@ -280,16 +280,17 @@ def transcribeAudio(audio_state, model): words = ''.join(c for c in text.lower() if (c.isalpha() or c == " ")).split() + old_text = audio_state.text + + audio_state.text = string_matcher.matchStrings(audio_state.text, + text, window_size = 25) + now = time.time() print("Transcription ({} seconds): {}".format( now - last_transcribe_time, audio_state.text)) last_transcribe_time = now - old_text = audio_state.text - - audio_state.text = string_matcher.matchStrings(audio_state.text, - text, window_size = 25) if old_text != audio_state.text: # We think the user said something, so reset the amount of # time we sleep between transcriptions to the minimum. |
