fix
Browse files- app.py +22 -33
- logs/sentence_analyzer_2024-12-02.log +10 -0
app.py
CHANGED
@@ -66,36 +66,23 @@ last_ema = None
|
|
66 |
tts_api = None
|
67 |
training_process = None # Adicione esta linha se necessário para o seu contexto
|
68 |
|
69 |
-
#
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
background-color: #111;
|
87 |
-
color: #eee;
|
88 |
-
}
|
89 |
-
.gradio-container {
|
90 |
-
background-color: #111;
|
91 |
-
}
|
92 |
-
.dark {
|
93 |
-
background-color: #333;
|
94 |
-
color: #eee;
|
95 |
-
}
|
96 |
-
"""
|
97 |
-
|
98 |
-
with gr.Blocks(css=custom_css, theme=gr.themes.Default(primary_hue="gray", secondary_hue="gray")) as app:
|
99 |
with gr.Tabs():
|
100 |
with gr.Tab("TTS Básico"):
|
101 |
gr.Markdown("# TTS Básico com F5-TTS")
|
@@ -153,7 +140,7 @@ with gr.Blocks(css=custom_css, theme=gr.themes.Default(primary_hue="gray", secon
|
|
153 |
seed_input = gr.Number(label="Seed", value=-1, minimum=-1) # Seed na seção avançada
|
154 |
|
155 |
analyzer = SentenceAnalyzer()
|
156 |
-
|
157 |
@gpu_decorator
|
158 |
def process_chunks(
|
159 |
ref_audio_input,
|
@@ -168,6 +155,7 @@ with gr.Blocks(css=custom_css, theme=gr.themes.Default(primary_hue="gray", secon
|
|
168 |
):
|
169 |
# Acessando a instância F5TTS_ema_model diretamente
|
170 |
f5tts_model = F5TTS_ema_model
|
|
|
171 |
# Dividir o texto em sentenças
|
172 |
sentences = analyzer.split_into_sentences(gen_text_input)
|
173 |
|
@@ -223,8 +211,8 @@ with gr.Blocks(css=custom_css, theme=gr.themes.Default(primary_hue="gray", secon
|
|
223 |
speed_slider,
|
224 |
nfe_slider,
|
225 |
chunk_size_slider,
|
226 |
-
seed_input,
|
227 |
-
],
|
228 |
outputs=[
|
229 |
audio_output,
|
230 |
ref_text_input,
|
@@ -232,6 +220,7 @@ with gr.Blocks(css=custom_css, theme=gr.themes.Default(primary_hue="gray", secon
|
|
232 |
],
|
233 |
)
|
234 |
|
|
|
235 |
# Código para iniciar a aplicação Gradio
|
236 |
@click.command()
|
237 |
@click.option("--port", "-p", default=None, type=int, help="Port to run the app on")
|
|
|
66 |
tts_api = None
|
67 |
training_process = None # Adicione esta linha se necessário para o seu contexto
|
68 |
|
69 |
+
# Modificação na classe F5TTS para salvar o áudio em um arquivo temporário
|
70 |
+
class F5TTS(F5TTS): # Herdando da classe original F5TTS
|
71 |
+
def infer(
|
72 |
+
self,
|
73 |
+
# ... seus argumentos
|
74 |
+
):
|
75 |
+
# ... (seu código para gerar o áudio - wav, sr, spect)
|
76 |
+
|
77 |
+
# Salvar o áudio em um arquivo temporário
|
78 |
+
with tempfile.NamedTemporaryFile(delete=False, suffix=".wav") as f:
|
79 |
+
sf.write(f.name, wav, sr)
|
80 |
+
audio_file = f.name # Atribuir o caminho do arquivo temporário à variável audio_file
|
81 |
+
|
82 |
+
# Retornar o caminho do arquivo temporário
|
83 |
+
return audio_file, self.device, str(self.seed)
|
84 |
+
|
85 |
+
with gr.Blocks() as app: # Removido o CSS customizado
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
86 |
with gr.Tabs():
|
87 |
with gr.Tab("TTS Básico"):
|
88 |
gr.Markdown("# TTS Básico com F5-TTS")
|
|
|
140 |
seed_input = gr.Number(label="Seed", value=-1, minimum=-1) # Seed na seção avançada
|
141 |
|
142 |
analyzer = SentenceAnalyzer()
|
143 |
+
|
144 |
@gpu_decorator
|
145 |
def process_chunks(
|
146 |
ref_audio_input,
|
|
|
155 |
):
|
156 |
# Acessando a instância F5TTS_ema_model diretamente
|
157 |
f5tts_model = F5TTS_ema_model
|
158 |
+
|
159 |
# Dividir o texto em sentenças
|
160 |
sentences = analyzer.split_into_sentences(gen_text_input)
|
161 |
|
|
|
211 |
speed_slider,
|
212 |
nfe_slider,
|
213 |
chunk_size_slider,
|
214 |
+
seed_input,
|
215 |
+
],
|
216 |
outputs=[
|
217 |
audio_output,
|
218 |
ref_text_input,
|
|
|
220 |
],
|
221 |
)
|
222 |
|
223 |
+
|
224 |
# Código para iniciar a aplicação Gradio
|
225 |
@click.command()
|
226 |
@click.option("--port", "-p", default=None, type=int, help="Port to run the app on")
|
logs/sentence_analyzer_2024-12-02.log
CHANGED
@@ -56,3 +56,13 @@
|
|
56 |
2024-12-02 20:27:51,734 - SentenceAnalyzer - INFO - Split text into 2 sentences after cleanup
|
57 |
2024-12-02 20:32:57,401 - SentenceAnalyzer - DEBUG - Logger set up successfully
|
58 |
2024-12-02 20:32:57,401 - SentenceAnalyzer - INFO - SentenceAnalyzer initialized successfully
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
56 |
2024-12-02 20:27:51,734 - SentenceAnalyzer - INFO - Split text into 2 sentences after cleanup
|
57 |
2024-12-02 20:32:57,401 - SentenceAnalyzer - DEBUG - Logger set up successfully
|
58 |
2024-12-02 20:32:57,401 - SentenceAnalyzer - INFO - SentenceAnalyzer initialized successfully
|
59 |
+
2024-12-02 20:39:49,009 - SentenceAnalyzer - DEBUG - Logger set up successfully
|
60 |
+
2024-12-02 20:39:49,010 - SentenceAnalyzer - INFO - SentenceAnalyzer initialized successfully
|
61 |
+
2024-12-02 20:40:49,340 - SentenceAnalyzer - DEBUG - Starting sentence splitting
|
62 |
+
2024-12-02 20:40:49,340 - SentenceAnalyzer - DEBUG - Normalized text using NFC
|
63 |
+
2024-12-02 20:40:49,341 - SentenceAnalyzer - DEBUG - Removed page numbers and chapter titles
|
64 |
+
2024-12-02 20:40:49,341 - SentenceAnalyzer - DEBUG - Replaced hyphenated line breaks
|
65 |
+
2024-12-02 20:40:49,341 - SentenceAnalyzer - DEBUG - Replaced multiple newlines with a space
|
66 |
+
2024-12-02 20:40:49,341 - SentenceAnalyzer - DEBUG - Normalized whitespace
|
67 |
+
2024-12-02 20:40:49,364 - SentenceAnalyzer - DEBUG - Split text into 1 sentences using NLTK
|
68 |
+
2024-12-02 20:40:49,364 - SentenceAnalyzer - INFO - Split text into 1 sentences after cleanup
|