check changelog tab for new update
Browse files
    	
        app.py
    CHANGED
    
    | @@ -3,8 +3,6 @@ from pytube import YouTube | |
| 3 | 
             
            from moviepy.editor import VideoFileClip
         | 
| 4 |  | 
| 5 | 
             
            def download_video(url, download_as):
         | 
| 6 | 
            -
                if download_as == "mp3":
         | 
| 7 | 
            -
                    gr.Warning("MP3 support is experimental at the moment, but is in current testing.")
         | 
| 8 | 
             
                try:
         | 
| 9 | 
             
                    yt = YouTube(url)
         | 
| 10 | 
             
                except pytube.exceptions.RegexMatchError:
         | 
| @@ -27,10 +25,6 @@ def download_video(url, download_as): | |
| 27 | 
             
            def split_audio_from_yt_video(mindur, maxdur, name_for_split_files, show_amount_of_files_and_file_dur):
         | 
| 28 | 
             
                if show_amount_of_files_and_file_dur == True:
         | 
| 29 | 
             
                    gr.Warning(f"show_amount_of_files_and_file_dur set to True. This will take longer if your audio file is long.")
         | 
| 30 | 
            -
                if not os.path.exists("output.wav") and os.path.exists("output.mp3"):
         | 
| 31 | 
            -
                    gr.Warning("Output.wav does not exist, but output.mp3 does. Splitting MP3 file instead...")
         | 
| 32 | 
            -
                if not os.path.exists("output.mp3") and os.path.exists("output.wav"):
         | 
| 33 | 
            -
                    gr.Warning("Output.mp3 does not exist, but output.wav does. Splitting WAV file instead...")
         | 
| 34 | 
             
                if not os.path.exists("output.mp3") and not os.path.exists("output.wav"):
         | 
| 35 | 
             
                    raise gr.Error("Neither output.mp3 or output.wav exist! Did the video download correctly?")
         | 
| 36 | 
             
                if mindur == maxdur:
         | 
| @@ -38,7 +32,7 @@ def split_audio_from_yt_video(mindur, maxdur, name_for_split_files, show_amount_ | |
| 38 | 
             
                elif mindur > maxdur:
         | 
| 39 | 
             
                    raise gr.Error(f"Cannot split mindur={mindur} and maxdur={maxdur}, mindur is higher than maxdur.")
         | 
| 40 | 
             
                elif name_for_split_files == None:
         | 
| 41 | 
            -
                    raise gr.Error("Split files name cannot be empty! | 
| 42 | 
             
                else:
         | 
| 43 | 
             
                    audio_path = "output.wav" if not os.path.exists("output.mp3") else "output.mp3"
         | 
| 44 | 
             
                    audio_regions = auditok.split(
         | 
| @@ -114,7 +108,7 @@ def split_wav_or_mp3_file(audiofileuploader, mindur2, maxdur2, name_for_split_fi | |
| 114 | 
             
                elif mindur2 > maxdur2:
         | 
| 115 | 
             
                    raise gr.Error(f"Cannot split mindur={mindur} and maxdur={maxdur}, mindur is higher than maxdur.")
         | 
| 116 | 
             
                elif name_for_split_files2 == None:
         | 
| 117 | 
            -
                    raise gr.Error("Split files name cannot be empty! | 
| 118 | 
             
                else:
         | 
| 119 | 
             
                    audio_path = audiofileuploader
         | 
| 120 | 
             
                    audio_regions = auditok.split(
         | 
| @@ -149,16 +143,14 @@ def get_average_pitch(audio_file): | |
| 149 | 
             
            def all_in_one_inator(ytvideo, download_yt_video_as, min_duration, max_duration, name_for_outputted_split_files, progress=gr.Progress()):
         | 
| 150 | 
             
                if download_as == "mp3":
         | 
| 151 | 
             
                    gr.Warning("MP3 is experimental, especially with this, so caution is advised.")
         | 
| 152 | 
            -
                if not os.path.exists("output. | 
| 153 | 
            -
                    gr. | 
| 154 | 
            -
                if not os.path.exists("output.mp3") and os.path.exists("output.wav"):
         | 
| 155 | 
            -
                    gr.Warning("Output.mp3 does not exist, but output.wav does. Splitting WAV file instead...")
         | 
| 156 | 
             
                if min_duration == max_duration:
         | 
| 157 | 
             
                    raise gr.Error(f"Cannot split mindur={min_duration} and maxdur={max_duration}, min and max are the same number.")
         | 
| 158 | 
             
                elif min_duration > max_duration:
         | 
| 159 | 
            -
                    raise gr.Error(f"Cannot split mindur={ | 
| 160 | 
             
                elif name_for_outputted_split_files == None:
         | 
| 161 | 
            -
                    raise gr.Error("Split files name cannot be empty! | 
| 162 | 
             
                else:
         | 
| 163 | 
             
                    try:
         | 
| 164 | 
             
                        progress(0, "Downloading video...")
         | 
| @@ -295,6 +287,7 @@ with gr.Blocks(theme='NoCrypt/miku', title="Global Dataset Maker") as app: | |
| 295 | 
             
                                        [gr.Text(label="Result"), gr.File(label="Zipped files")]
         | 
| 296 | 
             
                                    )
         | 
| 297 | 
             
                    with gr.TabItem("Changelog"):
         | 
|  | |
| 298 | 
             
                        gr.Markdown("v0.92 - Added all-in-one tab under Misc Tools.")
         | 
| 299 | 
             
                        gr.Markdown("v0.91 - Added mp3 file support for single file splitting, and also fixed bug if neither output.wav or output.mp3 exists.")
         | 
| 300 | 
             
                        gr.Markdown("v0.90a - Fixed bug that if 'show_amount_of_files_and_file_dur' was False, split wav files would not be deleted.")
         | 
|  | |
| 3 | 
             
            from moviepy.editor import VideoFileClip
         | 
| 4 |  | 
| 5 | 
             
            def download_video(url, download_as):
         | 
|  | |
|  | |
| 6 | 
             
                try:
         | 
| 7 | 
             
                    yt = YouTube(url)
         | 
| 8 | 
             
                except pytube.exceptions.RegexMatchError:
         | 
|  | |
| 25 | 
             
            def split_audio_from_yt_video(mindur, maxdur, name_for_split_files, show_amount_of_files_and_file_dur):
         | 
| 26 | 
             
                if show_amount_of_files_and_file_dur == True:
         | 
| 27 | 
             
                    gr.Warning(f"show_amount_of_files_and_file_dur set to True. This will take longer if your audio file is long.")
         | 
|  | |
|  | |
|  | |
|  | |
| 28 | 
             
                if not os.path.exists("output.mp3") and not os.path.exists("output.wav"):
         | 
| 29 | 
             
                    raise gr.Error("Neither output.mp3 or output.wav exist! Did the video download correctly?")
         | 
| 30 | 
             
                if mindur == maxdur:
         | 
|  | |
| 32 | 
             
                elif mindur > maxdur:
         | 
| 33 | 
             
                    raise gr.Error(f"Cannot split mindur={mindur} and maxdur={maxdur}, mindur is higher than maxdur.")
         | 
| 34 | 
             
                elif name_for_split_files == None:
         | 
| 35 | 
            +
                    raise gr.Error("Split files name cannot be empty!")
         | 
| 36 | 
             
                else:
         | 
| 37 | 
             
                    audio_path = "output.wav" if not os.path.exists("output.mp3") else "output.mp3"
         | 
| 38 | 
             
                    audio_regions = auditok.split(
         | 
|  | |
| 108 | 
             
                elif mindur2 > maxdur2:
         | 
| 109 | 
             
                    raise gr.Error(f"Cannot split mindur={mindur} and maxdur={maxdur}, mindur is higher than maxdur.")
         | 
| 110 | 
             
                elif name_for_split_files2 == None:
         | 
| 111 | 
            +
                    raise gr.Error("Split files name cannot be empty!")
         | 
| 112 | 
             
                else:
         | 
| 113 | 
             
                    audio_path = audiofileuploader
         | 
| 114 | 
             
                    audio_regions = auditok.split(
         | 
|  | |
| 143 | 
             
            def all_in_one_inator(ytvideo, download_yt_video_as, min_duration, max_duration, name_for_outputted_split_files, progress=gr.Progress()):
         | 
| 144 | 
             
                if download_as == "mp3":
         | 
| 145 | 
             
                    gr.Warning("MP3 is experimental, especially with this, so caution is advised.")
         | 
| 146 | 
            +
                if not os.path.exists("output.mp3") and not os.path.exists("output.wav"):
         | 
| 147 | 
            +
                    raise gr.Error("Neither output.mp3 or output.wav exist! Did the video download correctly?")
         | 
|  | |
|  | |
| 148 | 
             
                if min_duration == max_duration:
         | 
| 149 | 
             
                    raise gr.Error(f"Cannot split mindur={min_duration} and maxdur={max_duration}, min and max are the same number.")
         | 
| 150 | 
             
                elif min_duration > max_duration:
         | 
| 151 | 
            +
                    raise gr.Error(f"Cannot split mindur={min_duration} and maxdur={max_duration}, mindur is higher than maxdur.")
         | 
| 152 | 
             
                elif name_for_outputted_split_files == None:
         | 
| 153 | 
            +
                    raise gr.Error("Split files name cannot be empty!")
         | 
| 154 | 
             
                else:
         | 
| 155 | 
             
                    try:
         | 
| 156 | 
             
                        progress(0, "Downloading video...")
         | 
|  | |
| 287 | 
             
                                        [gr.Text(label="Result"), gr.File(label="Zipped files")]
         | 
| 288 | 
             
                                    )
         | 
| 289 | 
             
                    with gr.TabItem("Changelog"):
         | 
| 290 | 
            +
                        gr.Markdown("v0.93 - Removed obsolete warnings and fixed issue with all-in-one if output.mp3 or output.wav doesnt exist.")
         | 
| 291 | 
             
                        gr.Markdown("v0.92 - Added all-in-one tab under Misc Tools.")
         | 
| 292 | 
             
                        gr.Markdown("v0.91 - Added mp3 file support for single file splitting, and also fixed bug if neither output.wav or output.mp3 exists.")
         | 
| 293 | 
             
                        gr.Markdown("v0.90a - Fixed bug that if 'show_amount_of_files_and_file_dur' was False, split wav files would not be deleted.")
         | 
