Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -32,38 +32,16 @@ def predict(message, chatbot, system_prompt="", temperature=0.9, max_new_tokens=
|
|
32 |
max_new_tokens, # int | float (numeric value between 0 and 4096)
|
33 |
0.3, # int | float (numeric value between 0.0 and 1)
|
34 |
1, # int | float (numeric value between 1.0 and 2.0)
|
35 |
-
api_name="/
|
36 |
)
|
37 |
|
38 |
|
39 |
|
40 |
-
def transcribe(audio):
|
41 |
-
whisper_client = Client("https://sanchit-gandhi-whisper-large-v2.hf.space/")
|
42 |
|
43 |
-
return whisper_client.predict(
|
44 |
-
audio[1], # str (filepath or URL to file) in 'inputs' Audio component
|
45 |
-
"transcribe", # str in 'Task' Radio component
|
46 |
-
api_name="/predict"
|
47 |
-
)
|
48 |
-
|
49 |
-
def app_interface(input_type, message="", audio=None):
|
50 |
-
if input_type == "Text":
|
51 |
-
return predict(message)
|
52 |
-
elif input_type == "Audio":
|
53 |
-
transcribed_message = transcribe(audio.name)
|
54 |
-
return predict(transcribed_message)
|
55 |
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
],
|
63 |
-
outputs="text",
|
64 |
-
live=True,
|
65 |
-
title=title,
|
66 |
-
description=description
|
67 |
-
)
|
68 |
-
|
69 |
-
interface.launch()
|
|
|
32 |
max_new_tokens, # int | float (numeric value between 0 and 4096)
|
33 |
0.3, # int | float (numeric value between 0.0 and 1)
|
34 |
1, # int | float (numeric value between 1.0 and 2.0)
|
35 |
+
api_name="/chat_1"
|
36 |
)
|
37 |
|
38 |
|
39 |
|
|
|
|
|
40 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
|
42 |
+
# Gradio Demo
|
43 |
+
with gr.Blocks(theme=gr.themes.Base()) as demo:
|
44 |
+
gr.DuplicateButton()
|
45 |
+
gr.ChatInterface(predict, title=title, description=description, css=css, examples=examples)
|
46 |
+
|
47 |
+
demo.queue().launch(debug=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|