forked from mrq/tortoise-tts
Added tab to read and copy settings from a voice clip (in the future, I'll see about enmbedding the latent used to generate the voice)
This commit is contained in:
parent
edb6a173d3
commit
e25ec325fe
66
app.py
66
app.py
|
@ -130,7 +130,7 @@ def generate(text, delimiter, emotion, prompt, voice, mic_audio, preset, seed, c
|
||||||
|
|
||||||
info = {
|
info = {
|
||||||
'text': text,
|
'text': text,
|
||||||
'delimiter': delimiter,
|
'delimiter': '\\n' if delimiter == "\n" else delimiter,
|
||||||
'emotion': emotion,
|
'emotion': emotion,
|
||||||
'prompt': prompt,
|
'prompt': prompt,
|
||||||
'voice': voice,
|
'voice': voice,
|
||||||
|
@ -185,11 +185,44 @@ def update_presets(value):
|
||||||
else:
|
else:
|
||||||
return (gr.update(), gr.update())
|
return (gr.update(), gr.update())
|
||||||
|
|
||||||
|
def read_metadata(file):
|
||||||
|
j = None
|
||||||
|
if file is not None:
|
||||||
|
metadata = music_tag.load_file(file.name)
|
||||||
|
if 'lyrics' in metadata:
|
||||||
|
j = json.loads(str(metadata['lyrics']))
|
||||||
|
print(j)
|
||||||
|
return j
|
||||||
|
|
||||||
|
def copy_settings(file):
|
||||||
|
metadata = read_metadata(file)
|
||||||
|
if metadata is None:
|
||||||
|
return None
|
||||||
|
|
||||||
|
return (
|
||||||
|
metadata['text'],
|
||||||
|
metadata['delimiter'],
|
||||||
|
metadata['emotion'],
|
||||||
|
metadata['prompt'],
|
||||||
|
metadata['voice'],
|
||||||
|
metadata['mic_audio'],
|
||||||
|
metadata['preset'],
|
||||||
|
metadata['seed'],
|
||||||
|
metadata['candidates'],
|
||||||
|
metadata['num_autoregressive_samples'],
|
||||||
|
metadata['diffusion_iterations'],
|
||||||
|
metadata['temperature'],
|
||||||
|
metadata['diffusion_sampler'],
|
||||||
|
metadata['breathing_room'],
|
||||||
|
metadata['experimentals'],
|
||||||
|
)
|
||||||
|
|
||||||
def update_voices():
|
def update_voices():
|
||||||
return gr.Dropdown.update(choices=os.listdir(os.path.join("tortoise", "voices")) + ["microphone"])
|
return gr.Dropdown.update(choices=os.listdir(os.path.join("tortoise", "voices")) + ["microphone"])
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
with gr.Blocks() as demo:
|
with gr.Blocks() as webui:
|
||||||
|
with gr.Tab("Generate"):
|
||||||
with gr.Row():
|
with gr.Row():
|
||||||
with gr.Column():
|
with gr.Column():
|
||||||
text = gr.Textbox(lines=4, label="Prompt")
|
text = gr.Textbox(lines=4, label="Prompt")
|
||||||
|
@ -266,8 +299,7 @@ def main():
|
||||||
submit = gr.Button(value="Generate")
|
submit = gr.Button(value="Generate")
|
||||||
#stop = gr.Button(value="Stop")
|
#stop = gr.Button(value="Stop")
|
||||||
|
|
||||||
submit_event = submit.click(generate,
|
input_settings = [
|
||||||
inputs=[
|
|
||||||
text,
|
text,
|
||||||
delimiter,
|
delimiter,
|
||||||
emotion,
|
emotion,
|
||||||
|
@ -283,13 +315,34 @@ def main():
|
||||||
diffusion_sampler,
|
diffusion_sampler,
|
||||||
breathing_room,
|
breathing_room,
|
||||||
experimentals,
|
experimentals,
|
||||||
],
|
]
|
||||||
|
|
||||||
|
submit_event = submit.click(generate,
|
||||||
|
inputs=input_settings,
|
||||||
outputs=[selected_voice, output_audio, usedSeed],
|
outputs=[selected_voice, output_audio, usedSeed],
|
||||||
)
|
)
|
||||||
|
|
||||||
#stop.click(fn=None, inputs=None, outputs=None, cancels=[submit_event])
|
#stop.click(fn=None, inputs=None, outputs=None, cancels=[submit_event])
|
||||||
|
with gr.Tab("Utilities"):
|
||||||
|
with gr.Row():
|
||||||
|
with gr.Column():
|
||||||
|
audio_in = gr.File(type="file", label="Audio Input", file_types=["audio"])
|
||||||
|
copy_button = gr.Button(value="Copy Settings")
|
||||||
|
with gr.Column():
|
||||||
|
metadata_out = gr.JSON(label="Audio Metadata")
|
||||||
|
|
||||||
demo.queue().launch(share=args.share)
|
audio_in.upload(
|
||||||
|
fn=read_metadata,
|
||||||
|
inputs=audio_in,
|
||||||
|
outputs=metadata_out,
|
||||||
|
)
|
||||||
|
|
||||||
|
copy_button.click(copy_settings,
|
||||||
|
inputs=audio_in, # JSON elements cannt be used as inputs
|
||||||
|
outputs=input_settings
|
||||||
|
)
|
||||||
|
|
||||||
|
webui.queue().launch(share=args.share)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
@ -299,6 +352,7 @@ if __name__ == "__main__":
|
||||||
parser.add_argument("--cond-latent-max-chunk-size", type=int, default=1000000, help="Sets an upper limit to audio chunk size when computing conditioning latents")
|
parser.add_argument("--cond-latent-max-chunk-size", type=int, default=1000000, help="Sets an upper limit to audio chunk size when computing conditioning latents")
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
print("Initializating TorToiSe...")
|
||||||
tts = TextToSpeech(minor_optimizations=not args.low_vram)
|
tts = TextToSpeech(minor_optimizations=not args.low_vram)
|
||||||
|
|
||||||
main()
|
main()
|
Loading…
Reference in New Issue
Block a user