File size: 5,931 Bytes
fb1f7ba
44b7476
fb1f7ba
44b7476
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
fb1f7ba
3f8919a
44b7476
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
import gradio as gr
from gradio_client import Client
import os
import tempfile

# Crea il client Gradio per l'inferenza
inference_client = Client("http://127.0.0.1:6969/")

# Cartella di output in assets
output_folder = "assets/generated"
os.makedirs(output_folder, exist_ok=True)

def process_audio(audio_file):
    if audio_file is None:
        return None, "Nessun file audio caricato."
    
    # Ottieni il percorso temporaneo del file caricato
    input_file = audio_file.name
    
    try:
        # Prepara il percorso di output
        output_filename = f"generated_{os.path.basename(input_file)}"
        output_path = os.path.join(output_folder, output_filename)

        # Esegui la predizione
        result = inference_client.predict(
            -24,  # Pece
            0,    # Raggio del filtro
            0,    # Rapporto feature di ricerca
            0,    # Inviluppo del volume
            0,    # Proteggi le consonanti sorde
            1,    # Lunghezza del luppolo
            "pm", # Algoritmo di estrazione del passo
            input_file,  # Percorso del file audio di input
            output_path, # Percorso del file audio di output
            "logs/master/master.pth", # Modello vocale
            "logs/master/added_IVF124_Flat_nprobe_1_master-v2_v2.index", # File di indice
            True, # Dividere l'audio
            True, # Sintonizzazione automatica
            True, # Audio pulito
            0,    # Forza pulita
            "WAV", # Export Format
            api_name="/run_infer_script"
        )

        return output_path, f"Elaborazione completata. File salvato in {output_path}"

    except Exception as e:
        return None, f"Errore durante l'elaborazione: {str(e)}"

# Creazione dell'interfaccia Gradio
iface = gr.Interface(
    fn=process_audio,
    inputs=gr.Audio(type="filepath", label="Carica file audio (WAV o MP3)"),
    outputs=[
        gr.Audio(type="filepath", label="Audio elaborato"),
        gr.Textbox(label="Messaggio")
    ],
    title="Elaborazione Audio con Applio",
    description="Carica un file audio WAV o MP3 per elaborarlo con Applio."
)

# Avvio dell'interfaccia
iface.launch()

# import gradio as gr
# import sys
# import os
# import logging

# now_dir = os.getcwd()
# sys.path.append(now_dir)

# # Tabs
# from tabs.inference.inference import inference_tab
# from tabs.train.train import train_tab
# from tabs.extra.extra import extra_tab
# from tabs.report.report import report_tab
# from tabs.download.download import download_tab
# from tabs.tts.tts import tts_tab
# from tabs.voice_blender.voice_blender import voice_blender_tab
# from tabs.settings.presence import presence_tab, load_config_presence
# from tabs.settings.flask_server import flask_server_tab
# from tabs.settings.fake_gpu import fake_gpu_tab, gpu_available, load_fake_gpu
# from tabs.settings.themes import theme_tab
# from tabs.plugins.plugins import plugins_tab
# from tabs.settings.version import version_tab
# from tabs.settings.lang import lang_tab
# from tabs.settings.restart import restart_tab

# # Assets
# import assets.themes.loadThemes as loadThemes
# from assets.i18n.i18n import I18nAuto
# import assets.installation_checker as installation_checker
# from assets.discord_presence import RPCManager
# from assets.flask.server import start_flask, load_config_flask
# from core import run_prerequisites_script

# run_prerequisites_script("False", "True", "True", "True")

# i18n = I18nAuto()
# if load_config_presence() == True:
#     RPCManager.start_presence()
# installation_checker.check_installation()
# logging.getLogger("uvicorn").disabled = True
# logging.getLogger("fairseq").disabled = True
# if load_config_flask() == True:
#     print("Starting Flask server")
#     start_flask()

# my_applio = loadThemes.load_json()
# if my_applio:
#     pass
# else:
#     my_applio = "ParityError/Interstellar"

# with gr.Blocks(theme=my_applio, title="Applio") as Applio:
#     gr.Markdown("# Applio")
#     gr.Markdown(
#         i18n(
#             "Ultimate voice cloning tool, meticulously optimized for unrivaled power, modularity, and user-friendly experience."
#         )
#     )
#     gr.Markdown(
#         i18n(
#             "[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)"
#         )
#     )
#     with gr.Tab(i18n("Inference")):
#         inference_tab()

#     with gr.Tab(i18n("Train")):
#         if gpu_available() or load_fake_gpu():
#             train_tab()
#         else:
#             gr.Markdown(
#                 i18n(
#                     "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/)."
#                 )
#             )

#     with gr.Tab(i18n("TTS")):
#         tts_tab()

# #    with gr.Tab(i18n("Voice Blender")):
# #        voice_blender_tab()

# #    with gr.Tab(i18n("Plugins")):
# #        plugins_tab()

#     with gr.Tab(i18n("Download")):
#         download_tab()

#     with gr.Tab(i18n("Report a Bug")):
#         report_tab()

#     with gr.Tab(i18n("Extra")):
#         extra_tab()

# #    with gr.Tab(i18n("Settings")):
# #        presence_tab()
# #        flask_server_tab()
# #        if not gpu_available():
# #            fake_gpu_tab()
# #        theme_tab()
# #        version_tab()
# #        lang_tab()
# #        restart_tab()


# def launch_gradio():
#     Applio.launch()


# if __name__ == "__main__":
#     launch_gradio()