freddyaboulton HF staff commited on
Commit
cc76c21
1 Parent(s): 645d699
Files changed (1) hide show
  1. app.py +3 -9
app.py CHANGED
@@ -117,20 +117,13 @@ def set_api_key(api_key):
117
 
118
 
119
  with gr.Blocks() as demo:
120
- with gr.Row():
121
- with gr.Group():
122
- with gr.Column():
123
- api_key_input = gr.Textbox(type="password", label="Enter your Lepton API Key")
124
- api_key_status = gr.Textbox(label="API Key Status", interactive=False)
125
- with gr.Column():
126
- set_key_button = gr.Button("Set API Key")
127
-
128
  with gr.Group():
129
  with gr.Row():
130
  chatbot = gr.Chatbot(label="Conversation", type="messages")
131
  with gr.Row():
132
  with gr.Column():
133
  format_dropdown = gr.Dropdown(choices=["mp3", "opus"], value="mp3", label="Output Audio Format")
 
134
  with gr.Column():
135
  audio = WebRTC(modality="audio", mode="send-receive",
136
  label="Audio Stream")
@@ -138,6 +131,8 @@ with gr.Blocks() as demo:
138
  client_state = gr.State(None)
139
  lepton_conversation = gr.State([])
140
 
 
 
141
  audio.stream(
142
  ReplyOnPause(response),
143
  inputs=[audio, lepton_conversation, chatbot, client_state, format_dropdown],
@@ -145,5 +140,4 @@ with gr.Blocks() as demo:
145
  )
146
  audio.on_additional_outputs(lambda l, g: (l, g), outputs=[lepton_conversation, chatbot])
147
 
148
- if __name__ == "__main__":
149
  demo.launch()
 
117
 
118
 
119
  with gr.Blocks() as demo:
 
 
 
 
 
 
 
 
120
  with gr.Group():
121
  with gr.Row():
122
  chatbot = gr.Chatbot(label="Conversation", type="messages")
123
  with gr.Row():
124
  with gr.Column():
125
  format_dropdown = gr.Dropdown(choices=["mp3", "opus"], value="mp3", label="Output Audio Format")
126
+ api_key_input = gr.Textbox(type="password", label="Enter your Lepton API Key")
127
  with gr.Column():
128
  audio = WebRTC(modality="audio", mode="send-receive",
129
  label="Audio Stream")
 
131
  client_state = gr.State(None)
132
  lepton_conversation = gr.State([])
133
 
134
+ api_key_input.submit(set_api_key, inputs=[api_key_input], outputs=[client_state])
135
+
136
  audio.stream(
137
  ReplyOnPause(response),
138
  inputs=[audio, lepton_conversation, chatbot, client_state, format_dropdown],
 
140
  )
141
  audio.on_additional_outputs(lambda l, g: (l, g), outputs=[lepton_conversation, chatbot])
142
 
 
143
  demo.launch()