Spaces:
Runtime error
Runtime error
SHAKAZAMBA
commited on
Commit
•
44b7476
1
Parent(s):
b802bc6
testVocie2voice
Browse files
app.py
CHANGED
@@ -1,111 +1,176 @@
|
|
1 |
import gradio as gr
|
2 |
-
import
|
3 |
import os
|
4 |
-
import
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
#
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
start_flask()
|
45 |
-
|
46 |
-
my_applio = loadThemes.load_json()
|
47 |
-
if my_applio:
|
48 |
-
pass
|
49 |
-
else:
|
50 |
-
my_applio = "ParityError/Interstellar"
|
51 |
-
|
52 |
-
with gr.Blocks(theme=my_applio, title="Applio") as Applio:
|
53 |
-
gr.Markdown("# Applio")
|
54 |
-
gr.Markdown(
|
55 |
-
i18n(
|
56 |
-
"Ultimate voice cloning tool, meticulously optimized for unrivaled power, modularity, and user-friendly experience."
|
57 |
)
|
58 |
-
)
|
59 |
-
gr.Markdown(
|
60 |
-
i18n(
|
61 |
-
"[Support](https://discord.gg/IAHispano) — [Discord Bot](https://discord.com/oauth2/authorize?client_id=1144714449563955302&permissions=1376674695271&scope=bot%20applications.commands) — [Find Voices](https://applio.org/models) — [GitHub](https://github.com/IAHispano/Applio)"
|
62 |
-
)
|
63 |
-
)
|
64 |
-
with gr.Tab(i18n("Inference")):
|
65 |
-
inference_tab()
|
66 |
-
|
67 |
-
with gr.Tab(i18n("Train")):
|
68 |
-
if gpu_available() or load_fake_gpu():
|
69 |
-
train_tab()
|
70 |
-
else:
|
71 |
-
gr.Markdown(
|
72 |
-
i18n(
|
73 |
-
"Currently, training is unsupported due to the absence of a GPU. If you have a PC with a GPU and wish to train a model, please refer to our installation guide here: [Applio Installation Guide](https://docs.applio.org/get-started/installation/). For those without a GPU-enabled PC, explore alternative options here: [Applio Alternatives](https://docs.applio.org/get-started/alternatives/)."
|
74 |
-
)
|
75 |
-
)
|
76 |
-
|
77 |
-
with gr.Tab(i18n("TTS")):
|
78 |
-
tts_tab()
|
79 |
-
|
80 |
-
# with gr.Tab(i18n("Voice Blender")):
|
81 |
-
# voice_blender_tab()
|
82 |
-
|
83 |
-
# with gr.Tab(i18n("Plugins")):
|
84 |
-
# plugins_tab()
|
85 |
-
|
86 |
-
with gr.Tab(i18n("Download")):
|
87 |
-
download_tab()
|
88 |
-
|
89 |
-
with gr.Tab(i18n("Report a Bug")):
|
90 |
-
report_tab()
|
91 |
-
|
92 |
-
with gr.Tab(i18n("Extra")):
|
93 |
-
extra_tab()
|
94 |
-
|
95 |
-
# with gr.Tab(i18n("Settings")):
|
96 |
-
# presence_tab()
|
97 |
-
# flask_server_tab()
|
98 |
-
# if not gpu_available():
|
99 |
-
# fake_gpu_tab()
|
100 |
-
# theme_tab()
|
101 |
-
# version_tab()
|
102 |
-
# lang_tab()
|
103 |
-
# restart_tab()
|
104 |
-
|
105 |
-
|
106 |
-
def launch_gradio():
|
107 |
-
Applio.launch()
|
108 |
-
|
109 |
|
110 |
-
|
111 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
+
from gradio_client import Client
|
3 |
import os
|
4 |
+
import tempfile
|
5 |
+
|
6 |
+
# Crea il client Gradio per l'inferenza
|
7 |
+
inference_client = Client("http://127.0.0.1:6969/")
|
8 |
+
|
9 |
+
# Cartella di output in assets
|
10 |
+
output_folder = "assets/generated"
|
11 |
+
os.makedirs(output_folder, exist_ok=True)
|
12 |
+
|
13 |
+
def process_audio(audio_file):
|
14 |
+
if audio_file is None:
|
15 |
+
return None, "Nessun file audio caricato."
|
16 |
+
|
17 |
+
# Ottieni il percorso temporaneo del file caricato
|
18 |
+
input_file = audio_file.name
|
19 |
+
|
20 |
+
try:
|
21 |
+
# Prepara il percorso di output
|
22 |
+
output_filename = f"generated_{os.path.basename(input_file)}"
|
23 |
+
output_path = os.path.join(output_folder, output_filename)
|
24 |
+
|
25 |
+
# Esegui la predizione
|
26 |
+
result = inference_client.predict(
|
27 |
+
-24, # Pece
|
28 |
+
0, # Raggio del filtro
|
29 |
+
0, # Rapporto feature di ricerca
|
30 |
+
0, # Inviluppo del volume
|
31 |
+
0, # Proteggi le consonanti sorde
|
32 |
+
1, # Lunghezza del luppolo
|
33 |
+
"pm", # Algoritmo di estrazione del passo
|
34 |
+
input_file, # Percorso del file audio di input
|
35 |
+
output_path, # Percorso del file audio di output
|
36 |
+
"logs/master/master.pth", # Modello vocale
|
37 |
+
"logs/master/added_IVF124_Flat_nprobe_1_master-v2_v2.index", # File di indice
|
38 |
+
True, # Dividere l'audio
|
39 |
+
True, # Sintonizzazione automatica
|
40 |
+
True, # Audio pulito
|
41 |
+
0, # Forza pulita
|
42 |
+
"WAV", # Export Format
|
43 |
+
api_name="/run_infer_script"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
44 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
|
46 |
+
return output_path, f"Elaborazione completata. File salvato in {output_path}"
|
47 |
+
|
48 |
+
except Exception as e:
|
49 |
+
return None, f"Errore durante l'elaborazione: {str(e)}"
|
50 |
+
|
51 |
+
# Creazione dell'interfaccia Gradio
|
52 |
+
iface = gr.Interface(
|
53 |
+
fn=process_audio,
|
54 |
+
inputs=gr.Audio(type="filepath", label="Carica file audio (WAV o MP3)"),
|
55 |
+
outputs=[
|
56 |
+
gr.Audio(type="filepath", label="Audio elaborato"),
|
57 |
+
gr.Textbox(label="Messaggio")
|
58 |
+
],
|
59 |
+
title="Elaborazione Audio con Applio",
|
60 |
+
description="Carica un file audio WAV o MP3 per elaborarlo con Applio."
|
61 |
+
)
|
62 |
+
|
63 |
+
# Avvio dell'interfaccia
|
64 |
+
iface.launch()
|
65 |
+
|
66 |
+
# import gradio as gr
|
67 |
+
# import sys
|
68 |
+
# import os
|
69 |
+
# import logging
|
70 |
+
|
71 |
+
# now_dir = os.getcwd()
|
72 |
+
# sys.path.append(now_dir)
|
73 |
+
|
74 |
+
# # Tabs
|
75 |
+
# from tabs.inference.inference import inference_tab
|
76 |
+
# from tabs.train.train import train_tab
|
77 |
+
# from tabs.extra.extra import extra_tab
|
78 |
+
# from tabs.report.report import report_tab
|
79 |
+
# from tabs.download.download import download_tab
|
80 |
+
# from tabs.tts.tts import tts_tab
|
81 |
+
# from tabs.voice_blender.voice_blender import voice_blender_tab
|
82 |
+
# from tabs.settings.presence import presence_tab, load_config_presence
|
83 |
+
# from tabs.settings.flask_server import flask_server_tab
|
84 |
+
# from tabs.settings.fake_gpu import fake_gpu_tab, gpu_available, load_fake_gpu
|
85 |
+
# from tabs.settings.themes import theme_tab
|
86 |
+
# from tabs.plugins.plugins import plugins_tab
|
87 |
+
# from tabs.settings.version import version_tab
|
88 |
+
# from tabs.settings.lang import lang_tab
|
89 |
+
# from tabs.settings.restart import restart_tab
|
90 |
+
|
91 |
+
# # Assets
|
92 |
+
# import assets.themes.loadThemes as loadThemes
|
93 |
+
# from assets.i18n.i18n import I18nAuto
|
94 |
+
# import assets.installation_checker as installation_checker
|
95 |
+
# from assets.discord_presence import RPCManager
|
96 |
+
# from assets.flask.server import start_flask, load_config_flask
|
97 |
+
# from core import run_prerequisites_script
|
98 |
+
|
99 |
+
# run_prerequisites_script("False", "True", "True", "True")
|
100 |
+
|
101 |
+
# i18n = I18nAuto()
|
102 |
+
# if load_config_presence() == True:
|
103 |
+
# RPCManager.start_presence()
|
104 |
+
# installation_checker.check_installation()
|
105 |
+
# logging.getLogger("uvicorn").disabled = True
|
106 |
+
# logging.getLogger("fairseq").disabled = True
|
107 |
+
# if load_config_flask() == True:
|
108 |
+
# print("Starting Flask server")
|
109 |
+
# start_flask()
|
110 |
+
|
111 |
+
# my_applio = loadThemes.load_json()
|
112 |
+
# if my_applio:
|
113 |
+
# pass
|
114 |
+
# else:
|
115 |
+
# my_applio = "ParityError/Interstellar"
|
116 |
+
|
117 |
+
# with gr.Blocks(theme=my_applio, title="Applio") as Applio:
|
118 |
+
# gr.Markdown("# Applio")
|
119 |
+
# gr.Markdown(
|
120 |
+
# i18n(
|
121 |
+
# "Ultimate voice cloning tool, meticulously optimized for unrivaled power, modularity, and user-friendly experience."
|
122 |
+
# )
|
123 |
+
# )
|
124 |
+
# gr.Markdown(
|
125 |
+
# i18n(
|
126 |
+
# "[Support](https://discord.gg/IAHispano) — [Discord Bot](https://discord.com/oauth2/authorize?client_id=1144714449563955302&permissions=1376674695271&scope=bot%20applications.commands) — [Find Voices](https://applio.org/models) — [GitHub](https://github.com/IAHispano/Applio)"
|
127 |
+
# )
|
128 |
+
# )
|
129 |
+
# with gr.Tab(i18n("Inference")):
|
130 |
+
# inference_tab()
|
131 |
+
|
132 |
+
# with gr.Tab(i18n("Train")):
|
133 |
+
# if gpu_available() or load_fake_gpu():
|
134 |
+
# train_tab()
|
135 |
+
# else:
|
136 |
+
# gr.Markdown(
|
137 |
+
# i18n(
|
138 |
+
# "Currently, training is unsupported due to the absence of a GPU. If you have a PC with a GPU and wish to train a model, please refer to our installation guide here: [Applio Installation Guide](https://docs.applio.org/get-started/installation/). For those without a GPU-enabled PC, explore alternative options here: [Applio Alternatives](https://docs.applio.org/get-started/alternatives/)."
|
139 |
+
# )
|
140 |
+
# )
|
141 |
+
|
142 |
+
# with gr.Tab(i18n("TTS")):
|
143 |
+
# tts_tab()
|
144 |
+
|
145 |
+
# # with gr.Tab(i18n("Voice Blender")):
|
146 |
+
# # voice_blender_tab()
|
147 |
+
|
148 |
+
# # with gr.Tab(i18n("Plugins")):
|
149 |
+
# # plugins_tab()
|
150 |
+
|
151 |
+
# with gr.Tab(i18n("Download")):
|
152 |
+
# download_tab()
|
153 |
+
|
154 |
+
# with gr.Tab(i18n("Report a Bug")):
|
155 |
+
# report_tab()
|
156 |
+
|
157 |
+
# with gr.Tab(i18n("Extra")):
|
158 |
+
# extra_tab()
|
159 |
+
|
160 |
+
# # with gr.Tab(i18n("Settings")):
|
161 |
+
# # presence_tab()
|
162 |
+
# # flask_server_tab()
|
163 |
+
# # if not gpu_available():
|
164 |
+
# # fake_gpu_tab()
|
165 |
+
# # theme_tab()
|
166 |
+
# # version_tab()
|
167 |
+
# # lang_tab()
|
168 |
+
# # restart_tab()
|
169 |
+
|
170 |
+
|
171 |
+
# def launch_gradio():
|
172 |
+
# Applio.launch()
|
173 |
+
|
174 |
+
|
175 |
+
# if __name__ == "__main__":
|
176 |
+
# launch_gradio()
|