File size: 1,662 Bytes
03b76a9
 
 
0a65394
d052f09
 
 
 
 
 
 
03b76a9
 
0a65394
d052f09
03b76a9
 
 
 
7c6d107
 
 
 
03b76a9
 
 
 
 
 
 
 
 
d052f09
03b76a9
d052f09
03b76a9
f7a2d31
0a65394
 
 
0b33fb8
0a65394
 
f7a2d31
0a65394
 
d052f09
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
import wave
import gradio as gr


def get_audio_duration(audio_file):
    with wave.open(audio_file, 'rb') as audio:
        frames = audio.getnframes()
        rate = audio.getframerate()
        duration = frames / float(rate)
    return duration

def get_training_info(audio_file):
    if audio_file is None:
        return 'the audio file pls'
    
    duration = get_audio_duration(audio_file)
    sample_rate = wave.open(audio_file, 'rb').getframerate()

    training_info = {
        (0, 2): (150, 'TITAN'),
        (2, 3): (200, 'TITAN'),
        (3, 5): (250, 'TITAN'),
        (5, 10): (300, 'normal'),
        (10, 25): (500, 'Normal'),
        (25, 45): (700, 'Normal'),
        (45, 60): (1000, 'Normal')
    }

    for (min_duration, max_duration), (epochs, pretrain) in training_info.items():
        if min_duration <= duration < max_duration:
            break
    else:
        return 'Duration is not within the specified range.'

    return f'You should use the **{pretrain}** pretrain with **{epochs}** epochs at **{sample_rate/1000}kHz** sample rate. Good luck with your training!'

with gr.Blocks(theme=gr.themes.Base(primary_hue="sky", secondary_hue="blue"), title="RVC TRAINING HELPER") as demo:
    with gr.Tab("Main Settings"):
        audio_p = gr.Audio(type="filepath", label="Your Audio here")
        wtar = gr.Button("Start!")
        audio_q = gr.Textbox(scale=3, label="Your Output here")
        wtar.click(get_training_info, inputs=[audio_p], outputs=[audio_q])
    with gr.Tab("Credits"):
        gr.Markdown("### This code Originaly by [TheStinger](https://huggingface.co./TheStinger)")

        
    demo.launch(debug=True)