Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ https://github.com/rsxdalv/one-click-installers-tts
This code provides a Gradio interface for generating audio from text input using the Bark TTS and Tortoise TTS models. The interface takes a text prompt as input and generates audio as output.

![Screenshot 1](./screenshots/screenshot%20(1).png)
![Screenshot 6](./screenshots/screenshot%20(6).png)
![Screenshot 2](./screenshots/screenshot%20(2).png)
![Screenshot 3](./screenshots/screenshot%20(3).png)
![Screenshot 4](./screenshots/screenshot%20(4).png)
Expand Down
261 changes: 129 additions & 132 deletions generation_tab_bark.py

Large diffs are not rendered by default.

112 changes: 112 additions & 0 deletions generation_tab_tortoise.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
from gen_tortoise import generate_tortoise_n
from models.tortoise.tortoise.utils.audio import get_voices


import gradio as gr


def generation_tab_tortoise():
with gr.Tab("Generation (Tortoise)"):
prompt = gr.Textbox(label="Prompt", lines=3,
placeholder="Enter text here...")

with gr.Row():
# with gr.Box():
# gr.Markdown("### Voice")
with gr.Row():
voice = gr.Dropdown(
choices=["random"] + list(get_voices()),
value="random",
# show_label=False,
label="Voice"
)
# voice.style(container=False)
# reload_voices = gr.Button("🔁", elem_classes="btn-sm")
# reload_voices.style(size="sm")
# def reload_voices_fn():
# choices =
# print(choices)
# return [
# gr.Dropdown.update(choices=choices),
# ]
# reload_voices.click(fn=reload_voices_fn, outputs=[voice])
preset = gr.Dropdown(label="Preset", choices=[
'ultra_fast',
'fast',
'standard',
'high_quality',
], value="ultra_fast")
# Args:
# seed (int): The desired seed. Value must be within the inclusive range
# `[-0x8000_0000_0000_0000, 0xffff_ffff_ffff_ffff]`. Otherwise, a RuntimeError
# is raised. Negative inputs are remapped to positive values with the formula
# `0xffff_ffff_ffff_ffff + seed`.
seed = gr.Textbox(label="Seed", lines=1,
placeholder="Enter seed here...", value="None", visible=False)
cvvp_amount = gr.Slider(label="CVVP Amount",
value=0.0, minimum=0.0, maximum=1.0, step=0.1)

inputs = [
prompt,
voice,
preset,
seed,
cvvp_amount
]

with gr.Row():
audio_1 = gr.Audio(type="filepath", label="Generated audio")
audio_2 = gr.Audio(
type="filepath", label="Generated audio", visible=False)
audio_3 = gr.Audio(
type="filepath", label="Generated audio", visible=False)

with gr.Row():
image_1 = gr.Image(label="Waveform")
image_2 = gr.Image(label="Waveform", visible=False)
image_3 = gr.Image(label="Waveform", visible=False)

outputs = [audio_1, image_1]
outputs2 = [audio_2, image_2]
outputs3 = [audio_3, image_3]

with gr.Row():
generate3_button = gr.Button("Generate 3")
generate2_button = gr.Button("Generate 2")
generate1_button = gr.Button("Generate", variant="primary")

prompt.submit(fn=generate_tortoise_n(1),
inputs=inputs, outputs=outputs)
generate1_button.click(fn=generate_tortoise_n(1),
inputs=inputs, outputs=outputs)
generate2_button.click(fn=generate_tortoise_n(2), inputs=inputs,
outputs=outputs + outputs2)
generate3_button.click(fn=generate_tortoise_n(3), inputs=inputs,
outputs=outputs + outputs2 + outputs3)

def show_closure(count):
def show():
return [
gr.Audio.update(visible=True),
gr.Image.update(visible=True),
gr.Audio.update(visible=count > 1),
gr.Image.update(visible=count > 1),
gr.Audio.update(visible=count > 2),
gr.Image.update(visible=count > 2),
]
return show

generate1_button.click(fn=show_closure(
1), outputs=outputs + outputs2 + outputs3)
generate2_button.click(fn=show_closure(
2), outputs=outputs + outputs2 + outputs3)
generate3_button.click(fn=show_closure(
3), outputs=outputs + outputs2 + outputs3)


css_tortoise = """
.btn-sm {
min-width: 3em !important;
flex-grow: 0 !important;
}
"""
12 changes: 8 additions & 4 deletions history_tab.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,17 @@ def open_favorites_folder():
def save_to_favorites(json_text):
shutil.copy(json_text["filename"], "favorites/")
shutil.copy(json_text["filename_png"], "favorites/")
shutil.copy(json_text["filename_npz"], "favorites/")
# write new json file with new filename
json_text["filename"] = json_text["filename"].replace(
"outputs/", "favorites/")
"outputs\\", "favorites\\").replace("outputs/", "favorites/")
json_text["filename_png"] = json_text["filename_png"].replace(
"outputs/", "favorites/")
"outputs\\", "favorites\\").replace("outputs/", "favorites/")
json_text["filename_json"] = json_text["filename_json"].replace(
"outputs/", "favorites/")
with open(json_text["filename_json"].replace("outputs/", "favorites/"), "w") as f:
"outputs\\", "favorites\\").replace("outputs/", "favorites/")
json_text["filename_npz"] = json_text["filename_npz"].replace(
"outputs\\", "favorites\\").replace("outputs/", "favorites/")
with open(json_text["filename_json"], "w") as f:
json.dump(json_text, f, indent=2)
return gr.Button.update(value="Saved")

Expand All @@ -36,6 +39,7 @@ def delete_generation(json):
os.remove(json["filename"])
os.remove(json["filename_png"])
os.remove(json["filename_json"])
os.remove(json["filename_npz"])

return refresh()

Expand Down
1 change: 1 addition & 0 deletions save_waveform_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ def save_waveform_plot(audio_array, filename_png):
plt.plot(audio_array, color='orange')
plt.axis("off")
plt.savefig(filename_png)
plt.close()
Binary file added screenshots/screenshot (6).png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
40 changes: 29 additions & 11 deletions server.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from generation_tab_tortoise import css_tortoise, generation_tab_tortoise
import setup_or_recover
import dotenv_init
import matplotlib
import matplotlib.pyplot as plt
from generation_tab_bark import generation_tab_tortoise, generation_tab_bark, css_tortoise
from generation_tab_bark import generation_tab_bark
import gradio as gr
import json
from history_tab import favorites_tab, history_tab
Expand Down Expand Up @@ -59,9 +60,31 @@ def load_models(
model_manager.reload_models(config)
return gr.Button.update(value="Reload models", interactive=True)

full_css = css_tortoise

with gr.Blocks(css=full_css) as block:
material_symbols_css = """
@import url('https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@20..48,100..700,0..1,-50..200');

.material-symbols-outlined {
font-family: 'Material Symbols Outlined' !important;
font-weight: normal !important;
font-style: normal !important;
font-size: 24px !important;
line-height: 1 !important;
letter-spacing: normal;
text-transform: none;
display: inline-block;
white-space: nowrap;
word-wrap: normal;
direction: ltr;
-webkit-font-feature-settings: 'liga';
-webkit-font-smoothing: antialiased;
}
"""

full_css = ""
full_css += material_symbols_css
full_css += css_tortoise

with gr.Blocks(css=full_css) as demo:
gr.Markdown("# TTS Generation WebUI (Bark & Tortoise)")
generation_tab_bark()
generation_tab_tortoise()
Expand All @@ -71,10 +94,5 @@ def load_models(

settings_tab(config, save_config, load_models)

block.launch(server_name='0.0.0.0')






if __name__ == "__main__":
demo.launch(server_name='0.0.0.0')
Binary file added voices/Alice.npz
Binary file not shown.