Create app.py
Browse files
    	
        app.py
    ADDED
    
    | @@ -0,0 +1,73 @@ | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | 
|  | |
| 1 | 
            +
            import wave
         | 
| 2 | 
            +
            import gradio as gr
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            pretrains = {
         | 
| 5 | 
            +
                "OV2-32k": {
         | 
| 6 | 
            +
                    "D": "https://huggingface.co/poiqazwsx/Ov2Super32kfix/resolve/main/f0Ov2Super32kD.pth",
         | 
| 7 | 
            +
                    "G": "https://huggingface.co/poiqazwsx/Ov2Super32kfix/resolve/main/f0Ov2Super32kG.pth"
         | 
| 8 | 
            +
                },
         | 
| 9 | 
            +
                "OV2-40k": {
         | 
| 10 | 
            +
                    "D": "https://huggingface.co/ORVC/Ov2Super/resolve/main/f0Ov2Super40kD.pth",
         | 
| 11 | 
            +
                    "G": "https://huggingface.co/ORVC/Ov2Super/resolve/main/f0Ov2Super40kG.pth"
         | 
| 12 | 
            +
                },
         | 
| 13 | 
            +
                "RIN-40k": {
         | 
| 14 | 
            +
                    "D": "https://huggingface.co/ORVC/RIN_E3/resolve/main/RIN_E3_D.pth",
         | 
| 15 | 
            +
                    "G": "https://huggingface.co/ORVC/RIN_E3/resolve/main/RIN_E3_G.pth"
         | 
| 16 | 
            +
                },
         | 
| 17 | 
            +
                "Snowie-40k": {
         | 
| 18 | 
            +
                    "D": "https://huggingface.co/ORVC/Snowie_RuPretrain_40k/resolve/main/D_Snowie_RuPretrain_EnP.pth",
         | 
| 19 | 
            +
                    "G": "https://huggingface.co/ORVC/Snowie_RuPretrain_40k/resolve/main/G_Snowie_RuPretrain_EnP.pth"
         | 
| 20 | 
            +
                },
         | 
| 21 | 
            +
                "Snowie-48k": {
         | 
| 22 | 
            +
                    "D": "https://huggingface.co/ORVC/Snowie_RuPretrain_48k/resolve/main/D_Snowie_Rupretrain_48k_V1.2.pth",
         | 
| 23 | 
            +
                    "G": "https://huggingface.co/ORVC/Snowie_RuPretrain_48k/resolve/main/G_Snowie_Rupretrain_48k_V1.2.pth"
         | 
| 24 | 
            +
                },
         | 
| 25 | 
            +
                "SnowieV3.1-40k": {
         | 
| 26 | 
            +
                    "D": "https://huggingface.co/MUSTAR/SnowieV3.1-40k/resolve/main/D_SnowieV3.1_40k.pth",
         | 
| 27 | 
            +
                    "G": "https://huggingface.co/MUSTAR/SnowieV3.1-40k/resolve/main/G_SnowieV3.1_40k.pth"
         | 
| 28 | 
            +
                },
         | 
| 29 | 
            +
                "SnowieV3.1-32k": {
         | 
| 30 | 
            +
                    "D": "https://huggingface.co/MUSTAR/SnowieV3.1-32k/resolve/main/D_SnowieV3.1_32k.pth",
         | 
| 31 | 
            +
                    "G": "https://huggingface.co/MUSTAR/SnowieV3.1-32k/resolve/main/G_SnowieV3.1_32k.pth"
         | 
| 32 | 
            +
                },
         | 
| 33 | 
            +
                "SnowieV3.1-48k": {
         | 
| 34 | 
            +
                    "D": "https://huggingface.co/MUSTAR/SnowieV3.1-48k/resolve/main/D_SnowieV3.1_48k.pth",
         | 
| 35 | 
            +
                    "G": "https://huggingface.co/MUSTAR/SnowieV3.1-48k/resolve/main/G_SnowieV3.1_48k.pth"
         | 
| 36 | 
            +
                },
         | 
| 37 | 
            +
                "SnowieV3.1-X-RinE3-40k": {
         | 
| 38 | 
            +
                    "D": "https://huggingface.co/MUSTAR/SnowieV3.1-X-RinE3-40K/resolve/main/D_Snowie-X-Rin_40k.pth",
         | 
| 39 | 
            +
                    "G": "https://huggingface.co/MUSTAR/SnowieV3.1-X-RinE3-40K/resolve/main/G_Snowie-X-Rin_40k.pth"
         | 
| 40 | 
            +
                }
         | 
| 41 | 
            +
            }
         | 
| 42 | 
            +
             | 
| 43 | 
            +
            def get_training_info(audio_file):
         | 
| 44 | 
            +
                if audio_file is None:
         | 
| 45 | 
            +
                    return 'Please provide an audio file!'
         | 
| 46 | 
            +
                duration = get_audio_duration(audio_file)
         | 
| 47 | 
            +
                sample_rate = wave.open(audio_file, 'rb').getframerate()
         | 
| 48 | 
            +
             | 
| 49 | 
            +
                training_info = {
         | 
| 50 | 
            +
                    (0, 2): (150, 'OV2'),
         | 
| 51 | 
            +
                    (2, 3): (200, 'OV2'),
         | 
| 52 | 
            +
                    (3, 5): (250, 'OV2'),
         | 
| 53 | 
            +
                    (5, 10): (300, 'Normal'),
         | 
| 54 | 
            +
                    (10, 25): (500, 'Normal'),
         | 
| 55 | 
            +
                    (25, 45): (700, 'Normal'),
         | 
| 56 | 
            +
                    (45, 60): (1000, 'Normal')
         | 
| 57 | 
            +
                }
         | 
| 58 | 
            +
             | 
| 59 | 
            +
                for (min_duration, max_duration), (epochs, pretrain) in training_info.items():
         | 
| 60 | 
            +
                    if min_duration <= duration < max_duration:
         | 
| 61 | 
            +
                        break
         | 
| 62 | 
            +
                else:
         | 
| 63 | 
            +
                    return 'Duration is not within the specified range dude'
         | 
| 64 | 
            +
             | 
| 65 | 
            +
                return f'u should use the **{pretrain}** pretrain with **{epochs}** epochs at **{sample_rate/1000}khz** sample rate\n good luck at training ;).'
         | 
| 66 | 
            +
             | 
| 67 | 
            +
             | 
| 68 | 
            +
             | 
| 69 | 
            +
            with gr.Blocks() as demo:
         | 
| 70 | 
            +
                audio_p = gr.Audio(label="Your Audio here")
         | 
| 71 | 
            +
                audio_q = Texbox(label="Your Output here")
         | 
| 72 | 
            +
                wtar = gr.Button("Start!")
         | 
| 73 | 
            +
                wtar.click(get_training_info, inputs=[audio_p], outputs=[audio_q])
         | 
