Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,6 +3,40 @@ import gradio as gr
|
|
| 3 |
from transformers import BarkModel, AutoProcessor
|
| 4 |
import torch
|
| 5 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
# Desactivar paralelismo en tokenizers para evitar advertencias
|
| 7 |
os.environ["TOKENIZERS_PARALLELISM"] = "false"
|
| 8 |
|
|
@@ -22,9 +56,9 @@ def say_something(text):
|
|
| 22 |
return (sample_rate, audio_array)
|
| 23 |
|
| 24 |
|
| 25 |
-
with gr.Blocks() as demo:
|
| 26 |
textBox = gr.Textbox(label="Text", value="Hello! [laugths]. This is a test!")
|
| 27 |
-
button = gr.Button("Generate Speech")
|
| 28 |
audio_output = gr.Audio(label="Generated Speech")
|
| 29 |
button.click(say_something, inputs=textBox, outputs=audio_output)
|
| 30 |
|
|
|
|
| 3 |
from transformers import BarkModel, AutoProcessor
|
| 4 |
import torch
|
| 5 |
|
| 6 |
+
# funci贸n para el t铆tulo animado
|
| 7 |
+
js = """
|
| 8 |
+
function createGradioAnimation() {
|
| 9 |
+
var container = document.createElement('div');
|
| 10 |
+
container.id = 'gradio-animation';
|
| 11 |
+
container.style.fontSize = '2em';
|
| 12 |
+
container.style.fontWeight = 'bold';
|
| 13 |
+
container.style.textAlign = 'center';
|
| 14 |
+
container.style.marginBottom = '20px';
|
| 15 |
+
|
| 16 |
+
var text = 'Speech Generation!';
|
| 17 |
+
for (var i = 0; i < text.length; i++) {
|
| 18 |
+
(function(i){
|
| 19 |
+
setTimeout(function(){
|
| 20 |
+
var letter = document.createElement('span');
|
| 21 |
+
letter.style.opacity = '0';
|
| 22 |
+
letter.style.transition = 'opacity 0.5s';
|
| 23 |
+
letter.innerText = text[i];
|
| 24 |
+
|
| 25 |
+
container.appendChild(letter);
|
| 26 |
+
|
| 27 |
+
setTimeout(function() {
|
| 28 |
+
letter.style.opacity = '1';
|
| 29 |
+
}, 50);
|
| 30 |
+
}, i * 250);
|
| 31 |
+
})(i);
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
var gradioContainer = document.querySelector('.gradio-container');
|
| 35 |
+
gradioContainer.insertBefore(container, gradioContainer.firstChild);
|
| 36 |
+
|
| 37 |
+
return 'Animation created';
|
| 38 |
+
}
|
| 39 |
+
"""
|
| 40 |
# Desactivar paralelismo en tokenizers para evitar advertencias
|
| 41 |
os.environ["TOKENIZERS_PARALLELISM"] = "false"
|
| 42 |
|
|
|
|
| 56 |
return (sample_rate, audio_array)
|
| 57 |
|
| 58 |
|
| 59 |
+
with gr.Blocks(js=js) as demo:
|
| 60 |
textBox = gr.Textbox(label="Text", value="Hello! [laugths]. This is a test!")
|
| 61 |
+
button = gr.Button("Generate Speech", variant="primary")
|
| 62 |
audio_output = gr.Audio(label="Generated Speech")
|
| 63 |
button.click(say_something, inputs=textBox, outputs=audio_output)
|
| 64 |
|