Spaces:
Runtime error
Runtime error
RamAnanth1
commited on
Commit
•
c5f762e
1
Parent(s):
0011b9b
Update app.py
Browse files
app.py
CHANGED
@@ -10,8 +10,6 @@ def translate_or_transcribe(audio, task):
|
|
10 |
text_result = whisper(audio, None, task, fn_index=0)
|
11 |
return text_result
|
12 |
|
13 |
-
|
14 |
-
|
15 |
#Streaming endpoint
|
16 |
API_URL = "https://api.openai.com/v1/chat/completions" #os.getenv("API_URL") + "/generate_stream"
|
17 |
|
@@ -67,7 +65,7 @@ def predict(inputs, top_p, temperature, openai_api_key, history=[]):
|
|
67 |
def reset_textbox():
|
68 |
return gr.update(value='')
|
69 |
|
70 |
-
title = """<h1 align="center">🔥ChatGPT API 🚀Streaming
|
71 |
description = """Language models can be conditioned to act like dialogue agents through a conversational prompt that typically takes the form:
|
72 |
```
|
73 |
User: <utterance>
|
@@ -88,6 +86,12 @@ with gr.Blocks(css = """#col_container {width: 700px; margin-left: auto; margin-
|
|
88 |
with gr.Column(elem_id = "col_container"):
|
89 |
openai_api_key = gr.Textbox(type='password', label="Enter your OpenAI API key here")
|
90 |
chatbot = gr.Chatbot(elem_id='chatbot') #c
|
|
|
|
|
|
|
|
|
|
|
|
|
91 |
inputs = gr.Textbox(placeholder= "Hi there!", label= "Type an input and press Enter") #t
|
92 |
state = gr.State([]) #s
|
93 |
b1 = gr.Button()
|
@@ -99,7 +103,11 @@ with gr.Blocks(css = """#col_container {width: 700px; margin-left: auto; margin-
|
|
99 |
#top_k = gr.Slider( minimum=1, maximum=50, value=4, step=1, interactive=True, label="Top-k",)
|
100 |
#repetition_penalty = gr.Slider( minimum=0.1, maximum=3.0, value=1.03, step=0.01, interactive=True, label="Repetition Penalty", )
|
101 |
|
102 |
-
|
|
|
|
|
|
|
|
|
103 |
inputs.submit( predict, [inputs, top_p, temperature, openai_api_key, state], [chatbot, state],)
|
104 |
b1.click( predict, [inputs, top_p, temperature, openai_api_key, state], [chatbot, state],)
|
105 |
b1.click(reset_textbox, [], [inputs])
|
|
|
10 |
text_result = whisper(audio, None, task, fn_index=0)
|
11 |
return text_result
|
12 |
|
|
|
|
|
13 |
#Streaming endpoint
|
14 |
API_URL = "https://api.openai.com/v1/chat/completions" #os.getenv("API_URL") + "/generate_stream"
|
15 |
|
|
|
65 |
def reset_textbox():
|
66 |
return gr.update(value='')
|
67 |
|
68 |
+
title = """<h1 align="center">🔥ChatGPT API 🚀Streaming🚀 with Whisper</h1>"""
|
69 |
description = """Language models can be conditioned to act like dialogue agents through a conversational prompt that typically takes the form:
|
70 |
```
|
71 |
User: <utterance>
|
|
|
86 |
with gr.Column(elem_id = "col_container"):
|
87 |
openai_api_key = gr.Textbox(type='password', label="Enter your OpenAI API key here")
|
88 |
chatbot = gr.Chatbot(elem_id='chatbot') #c
|
89 |
+
|
90 |
+
prompt_input_audio = gr.Audio(source="microphone",type="filepath",label="Record Audio Input"
|
91 |
+
)
|
92 |
+
translate_btn = gr.Button("Check Whisper first ? 👍")
|
93 |
+
|
94 |
+
whisper_task = gr.Radio(["translate", "transcribe"], value="translate", show_label=False)
|
95 |
inputs = gr.Textbox(placeholder= "Hi there!", label= "Type an input and press Enter") #t
|
96 |
state = gr.State([]) #s
|
97 |
b1 = gr.Button()
|
|
|
103 |
#top_k = gr.Slider( minimum=1, maximum=50, value=4, step=1, interactive=True, label="Top-k",)
|
104 |
#repetition_penalty = gr.Slider( minimum=0.1, maximum=3.0, value=1.03, step=0.01, interactive=True, label="Repetition Penalty", )
|
105 |
|
106 |
+
translate_btn.click(fn=translate_or_transcribe,
|
107 |
+
inputs=[prompt_input_audio,whisper_task],
|
108 |
+
outputs=inputs
|
109 |
+
)
|
110 |
+
|
111 |
inputs.submit( predict, [inputs, top_p, temperature, openai_api_key, state], [chatbot, state],)
|
112 |
b1.click( predict, [inputs, top_p, temperature, openai_api_key, state], [chatbot, state],)
|
113 |
b1.click(reset_textbox, [], [inputs])
|