Spaces:
Sleeping
Sleeping
Helw150
commited on
Commit
·
7b1b100
1
Parent(s):
809dcd8
Add Duration
Browse files
app.py
CHANGED
@@ -24,7 +24,7 @@ diva_model = AutoModel.from_pretrained(
|
|
24 |
resampler = Audio(sampling_rate=16_000)
|
25 |
|
26 |
|
27 |
-
@spaces.GPU
|
28 |
@torch.no_grad
|
29 |
def diva_audio(audio_input, do_sample=False, temperature=0.001, prev_outs=None):
|
30 |
sr, y = audio_input
|
@@ -116,8 +116,10 @@ def process_audio(audio: tuple, state: AppState):
|
|
116 |
if state.stream is None:
|
117 |
state.stream = audio[1]
|
118 |
state.sampling_rate = audio[0]
|
119 |
-
|
120 |
state.stream = np.concatenate((state.stream, audio[1]))
|
|
|
|
|
121 |
|
122 |
pause_detected = determine_pause(state.stream, state.sampling_rate, state)
|
123 |
state.pause_detected = pause_detected
|
@@ -190,8 +192,8 @@ with gr.Blocks(theme=theme) as demo:
|
|
190 |
process_audio,
|
191 |
[input_audio, state],
|
192 |
[input_audio, state],
|
193 |
-
stream_every=0.
|
194 |
-
time_limit=
|
195 |
)
|
196 |
respond = input_audio.stop_recording(response, [state], [state, chatbot])
|
197 |
respond.then(start_recording_user, [state], [input_audio])
|
@@ -205,4 +207,4 @@ with gr.Blocks(theme=theme) as demo:
|
|
205 |
)
|
206 |
|
207 |
|
208 |
-
demo.launch(
|
|
|
24 |
resampler = Audio(sampling_rate=16_000)
|
25 |
|
26 |
|
27 |
+
@spaces.GPU(duration=20)
|
28 |
@torch.no_grad
|
29 |
def diva_audio(audio_input, do_sample=False, temperature=0.001, prev_outs=None):
|
30 |
sr, y = audio_input
|
|
|
116 |
if state.stream is None:
|
117 |
state.stream = audio[1]
|
118 |
state.sampling_rate = audio[0]
|
119 |
+
elif audio is not None and audio[1] is not None:
|
120 |
state.stream = np.concatenate((state.stream, audio[1]))
|
121 |
+
else:
|
122 |
+
return None, state
|
123 |
|
124 |
pause_detected = determine_pause(state.stream, state.sampling_rate, state)
|
125 |
state.pause_detected = pause_detected
|
|
|
192 |
process_audio,
|
193 |
[input_audio, state],
|
194 |
[input_audio, state],
|
195 |
+
stream_every=0.25,
|
196 |
+
time_limit=10,
|
197 |
)
|
198 |
respond = input_audio.stop_recording(response, [state], [state, chatbot])
|
199 |
respond.then(start_recording_user, [state], [input_audio])
|
|
|
207 |
)
|
208 |
|
209 |
|
210 |
+
demo.launch()
|