John Meade
commited on
Commit
·
1c370d2
1
Parent(s):
bae7388
add default spkr ref wav / prompt
Browse files
app.py
CHANGED
|
@@ -48,17 +48,17 @@ CUSTOM_CSS = """
|
|
| 48 |
INSERT_TAG_JS = """
|
| 49 |
(tag_val, current_text) => {
|
| 50 |
const textarea = document.querySelector('#main_textbox textarea');
|
| 51 |
-
if (!textarea) return current_text + " " + tag_val;
|
| 52 |
|
| 53 |
const start = textarea.selectionStart;
|
| 54 |
const end = textarea.selectionEnd;
|
| 55 |
-
|
| 56 |
let prefix = " ";
|
| 57 |
let suffix = " ";
|
| 58 |
-
|
| 59 |
if (start === 0) prefix = "";
|
| 60 |
else if (current_text[start - 1] === ' ') prefix = "";
|
| 61 |
-
|
| 62 |
if (end < current_text.length && current_text[end] === ' ') suffix = "";
|
| 63 |
|
| 64 |
return current_text.slice(0, start) + prefix + tag_val + suffix + current_text.slice(end);
|
|
@@ -97,7 +97,7 @@ def generate(
|
|
| 97 |
repetition_penalty=repetition_penalty,
|
| 98 |
norm_loudness=norm_loudness,
|
| 99 |
)
|
| 100 |
-
|
| 101 |
return (MODEL.sr, wav.squeeze(0).cpu().numpy())
|
| 102 |
|
| 103 |
|
|
@@ -110,16 +110,16 @@ with gr.Blocks(title="Chatterbox Turbo") as demo:
|
|
| 110 |
value="Oh, that's hilarious! [chuckle] Um anyway, we do have a new model in store. It's the SkyNet T-800 series and it's got basically everything. Including AI integration with ChatGPT and all that jazz. Would you like me to get some prices for you?",
|
| 111 |
label="Text to synthesize (max chars 300)",
|
| 112 |
max_lines=5,
|
| 113 |
-
elem_id="main_textbox"
|
| 114 |
)
|
| 115 |
|
| 116 |
with gr.Row(elem_classes=["tag-container"]):
|
| 117 |
for tag in EVENT_TAGS:
|
| 118 |
btn = gr.Button(tag, elem_classes=["tag-btn"])
|
| 119 |
btn.click(
|
| 120 |
-
fn=None,
|
| 121 |
-
inputs=[btn, text],
|
| 122 |
-
outputs=text,
|
| 123 |
js=INSERT_TAG_JS
|
| 124 |
)
|
| 125 |
|
|
@@ -127,7 +127,7 @@ with gr.Blocks(title="Chatterbox Turbo") as demo:
|
|
| 127 |
sources=["upload", "microphone"],
|
| 128 |
type="filepath",
|
| 129 |
label="Reference Audio File",
|
| 130 |
-
value=
|
| 131 |
)
|
| 132 |
|
| 133 |
run_btn = gr.Button("Generate ⚡", variant="primary")
|
|
@@ -165,4 +165,4 @@ if __name__ == "__main__":
|
|
| 165 |
mcp_server=True,
|
| 166 |
css=CUSTOM_CSS,
|
| 167 |
ssr_mode=False
|
| 168 |
-
)
|
|
|
|
| 48 |
INSERT_TAG_JS = """
|
| 49 |
(tag_val, current_text) => {
|
| 50 |
const textarea = document.querySelector('#main_textbox textarea');
|
| 51 |
+
if (!textarea) return current_text + " " + tag_val;
|
| 52 |
|
| 53 |
const start = textarea.selectionStart;
|
| 54 |
const end = textarea.selectionEnd;
|
| 55 |
+
|
| 56 |
let prefix = " ";
|
| 57 |
let suffix = " ";
|
| 58 |
+
|
| 59 |
if (start === 0) prefix = "";
|
| 60 |
else if (current_text[start - 1] === ' ') prefix = "";
|
| 61 |
+
|
| 62 |
if (end < current_text.length && current_text[end] === ' ') suffix = "";
|
| 63 |
|
| 64 |
return current_text.slice(0, start) + prefix + tag_val + suffix + current_text.slice(end);
|
|
|
|
| 97 |
repetition_penalty=repetition_penalty,
|
| 98 |
norm_loudness=norm_loudness,
|
| 99 |
)
|
| 100 |
+
|
| 101 |
return (MODEL.sr, wav.squeeze(0).cpu().numpy())
|
| 102 |
|
| 103 |
|
|
|
|
| 110 |
value="Oh, that's hilarious! [chuckle] Um anyway, we do have a new model in store. It's the SkyNet T-800 series and it's got basically everything. Including AI integration with ChatGPT and all that jazz. Would you like me to get some prices for you?",
|
| 111 |
label="Text to synthesize (max chars 300)",
|
| 112 |
max_lines=5,
|
| 113 |
+
elem_id="main_textbox"
|
| 114 |
)
|
| 115 |
|
| 116 |
with gr.Row(elem_classes=["tag-container"]):
|
| 117 |
for tag in EVENT_TAGS:
|
| 118 |
btn = gr.Button(tag, elem_classes=["tag-btn"])
|
| 119 |
btn.click(
|
| 120 |
+
fn=None,
|
| 121 |
+
inputs=[btn, text],
|
| 122 |
+
outputs=text,
|
| 123 |
js=INSERT_TAG_JS
|
| 124 |
)
|
| 125 |
|
|
|
|
| 127 |
sources=["upload", "microphone"],
|
| 128 |
type="filepath",
|
| 129 |
label="Reference Audio File",
|
| 130 |
+
value="https://storage.googleapis.com/chatterbox-demo-samples/prompts/Ethan.wav",
|
| 131 |
)
|
| 132 |
|
| 133 |
run_btn = gr.Button("Generate ⚡", variant="primary")
|
|
|
|
| 165 |
mcp_server=True,
|
| 166 |
css=CUSTOM_CSS,
|
| 167 |
ssr_mode=False
|
| 168 |
+
)
|