Spaces:
Running
on
Zero
Running
on
Zero
Helw150
commited on
Commit
•
016ec2e
1
Parent(s):
8abf06c
Test 3
Browse files
app.py
CHANGED
@@ -78,12 +78,11 @@ def response(state: AppState, audio: tuple):
|
|
78 |
tuple(torch.tensor(vec).cuda() for vec in tup)
|
79 |
for tup in state.model_outs.past_key_values
|
80 |
)
|
81 |
-
print(outs)
|
82 |
prev_outs = state.model_outs
|
83 |
start = False
|
84 |
for resp, outs in diva_audio(
|
85 |
(state.sampling_rate, state.stream),
|
86 |
-
prev_outs=(
|
87 |
):
|
88 |
if not start:
|
89 |
state.conversation.append({"role": "assistant", "content": resp})
|
@@ -99,7 +98,7 @@ def response(state: AppState, audio: tuple):
|
|
99 |
tuple(vec.cpu().numpy() for vec in tup) for tup in outs.past_key_values
|
100 |
)
|
101 |
return (
|
102 |
-
AppState(conversation=state.conversation),
|
103 |
state.conversation,
|
104 |
)
|
105 |
|
@@ -190,7 +189,7 @@ with gr.Blocks(theme=theme, js=js) as demo:
|
|
190 |
respond = input_audio.stop_recording(
|
191 |
response, [state, input_audio], [state, chatbot]
|
192 |
)
|
193 |
-
restart = respond.
|
194 |
lambda state: state, state, state, js=js_reset
|
195 |
)
|
196 |
|
|
|
78 |
tuple(torch.tensor(vec).cuda() for vec in tup)
|
79 |
for tup in state.model_outs.past_key_values
|
80 |
)
|
|
|
81 |
prev_outs = state.model_outs
|
82 |
start = False
|
83 |
for resp, outs in diva_audio(
|
84 |
(state.sampling_rate, state.stream),
|
85 |
+
prev_outs=(prev_outs if state.model_outs is not None else None),
|
86 |
):
|
87 |
if not start:
|
88 |
state.conversation.append({"role": "assistant", "content": resp})
|
|
|
98 |
tuple(vec.cpu().numpy() for vec in tup) for tup in outs.past_key_values
|
99 |
)
|
100 |
return (
|
101 |
+
AppState(conversation=state.conversation, model_outs=outs),
|
102 |
state.conversation,
|
103 |
)
|
104 |
|
|
|
189 |
respond = input_audio.stop_recording(
|
190 |
response, [state, input_audio], [state, chatbot]
|
191 |
)
|
192 |
+
restart = respond.success(start_recording_user, [state], [input_audio]).then(
|
193 |
lambda state: state, state, state, js=js_reset
|
194 |
)
|
195 |
|