Unrelated bugs that I noticed and had to fix
This commit is contained in:
@@ -5,6 +5,7 @@ import gradio as gr
|
|||||||
import torch
|
import torch
|
||||||
from extensions.silero_tts import tts_preprocessor
|
from extensions.silero_tts import tts_preprocessor
|
||||||
from modules import chat, shared
|
from modules import chat, shared
|
||||||
|
from modules.html_generator import chat_html_wrapper
|
||||||
|
|
||||||
|
|
||||||
torch._C._jit_set_profiling_mode(False)
|
torch._C._jit_set_profiling_mode(False)
|
||||||
@@ -50,13 +51,13 @@ def load_model():
|
|||||||
model = load_model()
|
model = load_model()
|
||||||
|
|
||||||
|
|
||||||
def remove_tts_from_history(name1, name2):
|
def remove_tts_from_history(name1, name2, mode):
|
||||||
for i, entry in enumerate(shared.history['internal']):
|
for i, entry in enumerate(shared.history['internal']):
|
||||||
shared.history['visible'][i] = [shared.history['visible'][i][0], entry[1]]
|
shared.history['visible'][i] = [shared.history['visible'][i][0], entry[1]]
|
||||||
return chat.generate_chat_output(shared.history['visible'], name1, name2, shared.character)
|
return chat_html_wrapper(shared.history['visible'], name1, name2, mode)
|
||||||
|
|
||||||
|
|
||||||
def toggle_text_in_history(name1, name2):
|
def toggle_text_in_history(name1, name2, mode):
|
||||||
for i, entry in enumerate(shared.history['visible']):
|
for i, entry in enumerate(shared.history['visible']):
|
||||||
visible_reply = entry[1]
|
visible_reply = entry[1]
|
||||||
if visible_reply.startswith('<audio'):
|
if visible_reply.startswith('<audio'):
|
||||||
@@ -65,7 +66,7 @@ def toggle_text_in_history(name1, name2):
|
|||||||
shared.history['visible'][i] = [shared.history['visible'][i][0], f"{visible_reply.split('</audio>')[0]}</audio>\n\n{reply}"]
|
shared.history['visible'][i] = [shared.history['visible'][i][0], f"{visible_reply.split('</audio>')[0]}</audio>\n\n{reply}"]
|
||||||
else:
|
else:
|
||||||
shared.history['visible'][i] = [shared.history['visible'][i][0], f"{visible_reply.split('</audio>')[0]}</audio>"]
|
shared.history['visible'][i] = [shared.history['visible'][i][0], f"{visible_reply.split('</audio>')[0]}</audio>"]
|
||||||
return chat.generate_chat_output(shared.history['visible'], name1, name2, shared.character)
|
return chat_html_wrapper(shared.history['visible'], name1, name2, mode)
|
||||||
|
|
||||||
|
|
||||||
def input_modifier(string):
|
def input_modifier(string):
|
||||||
@@ -153,13 +154,13 @@ def ui():
|
|||||||
convert_arr = [convert_confirm, convert, convert_cancel]
|
convert_arr = [convert_confirm, convert, convert_cancel]
|
||||||
convert.click(lambda :[gr.update(visible=True), gr.update(visible=False), gr.update(visible=True)], None, convert_arr)
|
convert.click(lambda :[gr.update(visible=True), gr.update(visible=False), gr.update(visible=True)], None, convert_arr)
|
||||||
convert_confirm.click(lambda :[gr.update(visible=False), gr.update(visible=True), gr.update(visible=False)], None, convert_arr)
|
convert_confirm.click(lambda :[gr.update(visible=False), gr.update(visible=True), gr.update(visible=False)], None, convert_arr)
|
||||||
convert_confirm.click(remove_tts_from_history, [shared.gradio['name1'], shared.gradio['name2']], shared.gradio['display'])
|
convert_confirm.click(remove_tts_from_history, [shared.gradio[k] for k in ['name1', 'name2', 'Chat mode']], shared.gradio['display'])
|
||||||
convert_confirm.click(lambda : chat.save_history(timestamp=False), [], [], show_progress=False)
|
convert_confirm.click(lambda : chat.save_history(timestamp=False), [], [], show_progress=False)
|
||||||
convert_cancel.click(lambda :[gr.update(visible=False), gr.update(visible=True), gr.update(visible=False)], None, convert_arr)
|
convert_cancel.click(lambda :[gr.update(visible=False), gr.update(visible=True), gr.update(visible=False)], None, convert_arr)
|
||||||
|
|
||||||
# Toggle message text in history
|
# Toggle message text in history
|
||||||
show_text.change(lambda x: params.update({"show_text": x}), show_text, None)
|
show_text.change(lambda x: params.update({"show_text": x}), show_text, None)
|
||||||
show_text.change(toggle_text_in_history, [shared.gradio['name1'], shared.gradio['name2']], shared.gradio['display'])
|
show_text.change(toggle_text_in_history, [shared.gradio[k] for k in ['name1', 'name2', 'Chat mode']], shared.gradio['display'])
|
||||||
show_text.change(lambda : chat.save_history(timestamp=False), [], [], show_progress=False)
|
show_text.change(lambda : chat.save_history(timestamp=False), [], [], show_progress=False)
|
||||||
|
|
||||||
# Event functions to update the parameters in the backend
|
# Event functions to update the parameters in the backend
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import re
|
|||||||
|
|
||||||
from num2words import num2words
|
from num2words import num2words
|
||||||
|
|
||||||
|
#punctuation = r'[\s,.?!/)"\'\]>]“”'
|
||||||
punctuation = r'[\s,.?!/)"\'\]>]'
|
punctuation = r'[\s,.?!/)"\'\]>]'
|
||||||
alphabet_map = {
|
alphabet_map = {
|
||||||
"A": " Ei ",
|
"A": " Ei ",
|
||||||
|
|||||||
Reference in New Issue
Block a user