Skip to content

Commit

Permalink
[BUGFIX] setting whisper task option
Browse files Browse the repository at this point in the history
[TASK] allow setting conditioning while running
[TASK] Add option to switch textual translation languages
  • Loading branch information
Sharrnah authored Oct 26, 2022
1 parent 90e0752 commit c39627c
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 5 deletions.
2 changes: 1 addition & 1 deletion audioWhisper.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
def main(devices, device_index, sample_rate, task, model, english, condition_on_previous_text, verbose, energy, pause, dynamic_energy, phrase_time_limit, osc_ip, osc_port,
osc_address, osc_convert_ascii, websocket_ip, websocket_port, ai_device, open_browser):
# set initial settings
settings.SetOption("task", task)
settings.SetOption("whisper_task", task)
settings.SetOption("condition_on_previous_text", condition_on_previous_text)
settings.SetOption("model", model)
settings.SetOption("english", english)
Expand Down
4 changes: 2 additions & 2 deletions audioprocessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,15 @@ def whisper_worker():
whisper_model = settings.GetOption("model")
whisper_english = settings.GetOption("english")
whisper_ai_device = settings.GetOption("ai_device")
whisper_condition_on_previous_text = settings.GetOption("condition_on_previous_text")
audio_model = load_whisper(whisper_model, whisper_english, whisper_ai_device)

print("Say something!")

while True:
audio_sample = convert_audio(q.get())

whisper_task = settings.GetOption("task")
whisper_task = settings.GetOption("whisper_task")
whisper_condition_on_previous_text = settings.GetOption("condition_on_previous_text")

if whisper_english:
result = audio_model.transcribe(audio_sample, task=whisper_task, language='english',
Expand Down
Binary file modified images/vrchat_live_subtitles.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 25 additions & 2 deletions websocket_clients/websocket-remote/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,25 @@
document.querySelector('#sse').addEventListener("click", showAllTranscriptions);
}

document.querySelector('#lang_swap').addEventListener("click", swapLanguages);
function swapLanguages(e) {
let src_lang = document.querySelector('#settings #src_lang');
let src_lang_value = src_lang.value;
let trg_lang = document.querySelector('#settings #trg_lang');
let trg_lang_value = trg_lang.value;
let translate_text = document.querySelector('#translate_textarea');
let translate_text_value = translate_text.value;
let transl_result = document.querySelector('#transl_result_textarea');
let transl_result_value = transl_result.value;

src_lang.value = trg_lang_value;
trg_lang.value = src_lang_value;
translate_text.value = transl_result_value;
transl_result.value = translate_text_value;
src_lang.dispatchEvent(new Event("change"));
trg_lang.dispatchEvent(new Event("change"));
}

function WebSocketStart() {
if ("WebSocket" in window) {
// Let us open a web socket
Expand Down Expand Up @@ -303,8 +322,10 @@

// load whisper settings
var whisper_task_el = document.querySelector('#settings #whisper_task');
var whisper_condition_on_previous_text_el = document.querySelector('#settings #condition_on_previous_text');

whisper_task_el.value = received_msg.data.whisper_task;
whisper_condition_on_previous_text_el.value = received_msg.data.condition_on_previous_text;

var osc_ip = received_msg.data.osc_ip;
if (osc_ip === 0) {
Expand Down Expand Up @@ -359,7 +380,9 @@
<select name="whisper_task" id="whisper_task">
<option value="transcribe">transcribe</option>
<option value="translate">translate (to en)</option>
</select>
</select>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<label for="condition_on_previous_text">condition on previous text:</label> <input type="checkbox" id="condition_on_previous_text"
name="condition_on_previous_text" value="1" />
<hr />
</div>
</div>
Expand All @@ -383,7 +406,7 @@
<select name="src_lang" id="src_lang"></select>
</div>
<div class="col">
<div style="text-align:center;"><strong>==></strong></div>
<div style="text-align:center;"><button name="lang_swap" id="lang_swap" value="1" title="swap languages"><strong><==></strong></button></div>
</div>
<div class="col-5">
Target Language:
Expand Down

0 comments on commit c39627c

Please sign in to comment.