check changelog tab for new update
Browse files
app.py
CHANGED
|
@@ -22,8 +22,7 @@ def download_video(url, download_as):
|
|
| 22 |
video_clip.close()
|
| 23 |
for removalmp4 in glob.glob("*.mp4"):
|
| 24 |
os.remove(removalmp4)
|
| 25 |
-
|
| 26 |
-
#return "Finished downloading! Please proceed to next tab."
|
| 27 |
|
| 28 |
def split_audio_from_yt_video(mindur, maxdur, name_for_split_files, show_amount_of_files_and_file_dur):
|
| 29 |
if show_amount_of_files_and_file_dur == True:
|
|
@@ -32,6 +31,8 @@ def split_audio_from_yt_video(mindur, maxdur, name_for_split_files, show_amount_
|
|
| 32 |
gr.Warning("Output.wav does not exist, but output.mp3 does. Splitting MP3 file instead...")
|
| 33 |
if not os.path.exists("output.mp3") and os.path.exists("output.wav"):
|
| 34 |
gr.Warning("Output.mp3 does not exist, but output.wav does. Splitting WAV file instead...")
|
|
|
|
|
|
|
| 35 |
if mindur == maxdur:
|
| 36 |
raise gr.Error(f"Cannot split mindur={mindur} and maxdur={maxdur}, min and max are the same number.")
|
| 37 |
elif mindur > maxdur:
|
|
@@ -105,7 +106,7 @@ def analyze_audio(zip_file_path):
|
|
| 105 |
else:
|
| 106 |
return "No average sample rate could be found."
|
| 107 |
|
| 108 |
-
def
|
| 109 |
if audiofileuploader == None:
|
| 110 |
raise gr.Error("Audio file cannot be empty!")
|
| 111 |
if mindur2 == maxdur2:
|
|
@@ -194,20 +195,17 @@ with gr.Blocks(theme='NoCrypt/miku', title="Global Dataset Maker") as app:
|
|
| 194 |
[gr.Text(label="Result")]
|
| 195 |
)
|
| 196 |
with gr.Tab("File splitter"):
|
| 197 |
-
gr.Markdown("If you would rather split a single WAV
|
| 198 |
-
gr.HTML(
|
| 199 |
-
"<h1> Most bugs should be fixed now, if not, let me know. </h1>"
|
| 200 |
-
)
|
| 201 |
with gr.Row():
|
| 202 |
with gr.Column():
|
| 203 |
with gr.Row():
|
| 204 |
-
audiofileuploader = gr.File(file_count='single', file_types=[".wav"], label="WAV file")
|
| 205 |
mindur2 = gr.Number(label="Min duration", minimum=1, maximum=10, value=1)
|
| 206 |
maxdur2 = gr.Number(label="Max duration", minimum=1, maximum=10, value=5)
|
| 207 |
name_for_split_files2 = gr.Textbox(label="Name for split files")
|
| 208 |
audiofileuploadbtn = gr.Button("Split", variant='primary')
|
| 209 |
audiofileuploadbtn.click(
|
| 210 |
-
|
| 211 |
[audiofileuploader, mindur2, maxdur2, name_for_split_files2],
|
| 212 |
[gr.Text(label="Output"), gr.File(label="Zipped files")]
|
| 213 |
)
|
|
@@ -225,8 +223,7 @@ with gr.Blocks(theme='NoCrypt/miku', title="Global Dataset Maker") as app:
|
|
| 225 |
[gr.Text(label="Result")]
|
| 226 |
)
|
| 227 |
with gr.TabItem("Changelog"):
|
| 228 |
-
gr.
|
| 229 |
-
gr.Markdown("---")
|
| 230 |
gr.Markdown("v0.90a - Fixed bug that if 'show_amount_of_files_and_file_dur' was False, split wav files would not be deleted.")
|
| 231 |
gr.Markdown("v0.90 - Added mp3 support for downloading a Youtube video.")
|
| 232 |
gr.Markdown("v0.85 - Fixed bug in pitch analyzer if no audio file was given.")
|
|
|
|
| 22 |
video_clip.close()
|
| 23 |
for removalmp4 in glob.glob("*.mp4"):
|
| 24 |
os.remove(removalmp4)
|
| 25 |
+
return "Finished downloading! Please proceed to next tab."
|
|
|
|
| 26 |
|
| 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:
|
|
|
|
| 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:
|
| 37 |
raise gr.Error(f"Cannot split mindur={mindur} and maxdur={maxdur}, min and max are the same number.")
|
| 38 |
elif mindur > maxdur:
|
|
|
|
| 106 |
else:
|
| 107 |
return "No average sample rate could be found."
|
| 108 |
|
| 109 |
+
def split_wav_or_mp3_file(audiofileuploader, mindur2, maxdur2, name_for_split_files2):
|
| 110 |
if audiofileuploader == None:
|
| 111 |
raise gr.Error("Audio file cannot be empty!")
|
| 112 |
if mindur2 == maxdur2:
|
|
|
|
| 195 |
[gr.Text(label="Result")]
|
| 196 |
)
|
| 197 |
with gr.Tab("File splitter"):
|
| 198 |
+
gr.Markdown("If you would rather split a single WAV or mp3 audio file, use this method instead.")
|
|
|
|
|
|
|
|
|
|
| 199 |
with gr.Row():
|
| 200 |
with gr.Column():
|
| 201 |
with gr.Row():
|
| 202 |
+
audiofileuploader = gr.File(file_count='single', file_types=[".wav", ".mp3"], label="WAV or mp3 file")
|
| 203 |
mindur2 = gr.Number(label="Min duration", minimum=1, maximum=10, value=1)
|
| 204 |
maxdur2 = gr.Number(label="Max duration", minimum=1, maximum=10, value=5)
|
| 205 |
name_for_split_files2 = gr.Textbox(label="Name for split files")
|
| 206 |
audiofileuploadbtn = gr.Button("Split", variant='primary')
|
| 207 |
audiofileuploadbtn.click(
|
| 208 |
+
split_wav_or_mp3_file,
|
| 209 |
[audiofileuploader, mindur2, maxdur2, name_for_split_files2],
|
| 210 |
[gr.Text(label="Output"), gr.File(label="Zipped files")]
|
| 211 |
)
|
|
|
|
| 223 |
[gr.Text(label="Result")]
|
| 224 |
)
|
| 225 |
with gr.TabItem("Changelog"):
|
| 226 |
+
gr.Markdown("v0.91 - Added mp3 file suuport for single file splitting, and also fixed bug if neither output.wav or output.mp3 exists.")
|
|
|
|
| 227 |
gr.Markdown("v0.90a - Fixed bug that if 'show_amount_of_files_and_file_dur' was False, split wav files would not be deleted.")
|
| 228 |
gr.Markdown("v0.90 - Added mp3 support for downloading a Youtube video.")
|
| 229 |
gr.Markdown("v0.85 - Fixed bug in pitch analyzer if no audio file was given.")
|