Spaces:
Runtime error
Runtime error
j
commited on
Commit
·
8c2366f
1
Parent(s):
895a54b
adjust input sample rate to 16k and optimize chunking to 55.12s segments
Browse files
app.py
CHANGED
@@ -35,23 +35,24 @@ def process_fn(input_audio_path, seed, guidance_scale, num_inference_steps):
|
|
35 |
output_audio_path (str): the filepath of the processed audio.
|
36 |
"""
|
37 |
|
38 |
-
sig = AudioSignal(input_audio_path, sample_rate=
|
39 |
|
40 |
outfile = "./output.wav"
|
41 |
|
42 |
audio_concat = None
|
43 |
|
44 |
total_length = sig.duration
|
45 |
-
num_segs = int(total_length /
|
46 |
-
remainder = total_length %
|
47 |
|
48 |
for audio_segment in range(num_segs):
|
49 |
-
|
|
|
50 |
|
51 |
if audio_segment == num_segs - 1:
|
52 |
end = start + remainder
|
53 |
else:
|
54 |
-
end = start +
|
55 |
|
56 |
# get segment of audio from original file
|
57 |
sig_seg = sig[start*sig.sample_rate:int(end*sig.sample_rate)] # int accounts for float end time on last seg
|
@@ -110,4 +111,4 @@ with gr.Blocks() as webapp:
|
|
110 |
ctrls_data, ctrls_button, process_button, cancel_button = build_endpoint(inputs, output, process_fn, card)
|
111 |
|
112 |
#webapp.queue()
|
113 |
-
webapp.launch(
|
|
|
35 |
output_audio_path (str): the filepath of the processed audio.
|
36 |
"""
|
37 |
|
38 |
+
sig = AudioSignal(input_audio_path, sample_rate=16000)
|
39 |
|
40 |
outfile = "./output.wav"
|
41 |
|
42 |
audio_concat = None
|
43 |
|
44 |
total_length = sig.duration
|
45 |
+
num_segs = int(total_length / 5.12) # 5.12 second segments
|
46 |
+
remainder = total_length % 5.12 # duration of last segment
|
47 |
|
48 |
for audio_segment in range(num_segs):
|
49 |
+
print(f"Processing segment {audio_segment} of {num_segs}")
|
50 |
+
start = audio_segment * 5.12
|
51 |
|
52 |
if audio_segment == num_segs - 1:
|
53 |
end = start + remainder
|
54 |
else:
|
55 |
+
end = start + 5.12
|
56 |
|
57 |
# get segment of audio from original file
|
58 |
sig_seg = sig[start*sig.sample_rate:int(end*sig.sample_rate)] # int accounts for float end time on last seg
|
|
|
111 |
ctrls_data, ctrls_button, process_button, cancel_button = build_endpoint(inputs, output, process_fn, card)
|
112 |
|
113 |
#webapp.queue()
|
114 |
+
webapp.launch()
|