Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -12,7 +12,6 @@ def record_text(audio_file):
|
|
12 |
r = sr.Recognizer()
|
13 |
|
14 |
sound = audio_file
|
15 |
-
str_sound = str(sound)
|
16 |
sound_type = str_sound.split(".")
|
17 |
if sound_type[-1] == 'mp3':
|
18 |
input_file = sound
|
@@ -34,8 +33,8 @@ def record_text(audio_file):
|
|
34 |
return (MyText)
|
35 |
|
36 |
|
37 |
-
def api_calling(
|
38 |
-
|
39 |
if len(prompt) == 0:
|
40 |
prompt = "Apply proper punctuations, upper case and lower case to the provided text."
|
41 |
|
@@ -87,7 +86,7 @@ with block:
|
|
87 |
with gr.Row():
|
88 |
with gr.Column(scale=0.5):
|
89 |
aud_input = gr.Audio(type="filepath", label="Upload Audio")
|
90 |
-
audio_text = record_text(aud_input)
|
91 |
api_input = gr.Textbox(label="Enter Api-key")
|
92 |
upload_button = gr.Button(value="Upload & Start Chat", interactive=True, variant="primary")
|
93 |
with gr.Column():
|
@@ -95,7 +94,7 @@ with block:
|
|
95 |
message = gr.Textbox(label="User", placeholder=prompt)
|
96 |
state = gr.State()
|
97 |
|
98 |
-
upload_button.click(message_and_history, inputs=[
|
99 |
-
message.submit(message_and_history, inputs=[
|
100 |
message.submit(lambda: None, None, message, queue=False)
|
101 |
block.launch(share=True)
|
|
|
12 |
r = sr.Recognizer()
|
13 |
|
14 |
sound = audio_file
|
|
|
15 |
sound_type = str_sound.split(".")
|
16 |
if sound_type[-1] == 'mp3':
|
17 |
input_file = sound
|
|
|
33 |
return (MyText)
|
34 |
|
35 |
|
36 |
+
def api_calling(audio_file, prompt, api_key):
|
37 |
+
audio_text = record_text(audio_file)
|
38 |
if len(prompt) == 0:
|
39 |
prompt = "Apply proper punctuations, upper case and lower case to the provided text."
|
40 |
|
|
|
86 |
with gr.Row():
|
87 |
with gr.Column(scale=0.5):
|
88 |
aud_input = gr.Audio(type="filepath", label="Upload Audio")
|
89 |
+
# audio_text = record_text(aud_input)
|
90 |
api_input = gr.Textbox(label="Enter Api-key")
|
91 |
upload_button = gr.Button(value="Upload & Start Chat", interactive=True, variant="primary")
|
92 |
with gr.Column():
|
|
|
94 |
message = gr.Textbox(label="User", placeholder=prompt)
|
95 |
state = gr.State()
|
96 |
|
97 |
+
upload_button.click(message_and_history, inputs=[aud_input,message, state, api_input], outputs=[chatbot, state])
|
98 |
+
message.submit(message_and_history, inputs=[aud_input,message, state, api_input], outputs=[chatbot, state])
|
99 |
message.submit(lambda: None, None, message, queue=False)
|
100 |
block.launch(share=True)
|