Spaces:
Runtime error
Runtime error
Commit
·
d53f8eb
1
Parent(s):
e7e13c0
Update app.py
Browse files
app.py
CHANGED
@@ -10,30 +10,14 @@ co = cohere.Client(os.environ.get('COHERE_API_KEY'))
|
|
10 |
|
11 |
device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
|
12 |
|
13 |
-
|
14 |
-
task="automatic-speech-recognition",
|
15 |
-
model="openai/whisper-large-v2",
|
16 |
-
chunk_length_s=30,
|
17 |
-
device=device,
|
18 |
-
)
|
19 |
|
20 |
-
all_special_ids = whisper_model.tokenizer.all_special_ids
|
21 |
-
transcribe_token_id = all_special_ids[-5]
|
22 |
-
translate_token_id = all_special_ids[-6]
|
23 |
|
24 |
def translate_or_transcribe(audio, task):
|
25 |
-
|
26 |
-
text = whisper_model(audio)["text"]
|
27 |
-
return text
|
28 |
|
29 |
def get_response_from_chatbot(text):
|
30 |
-
|
31 |
-
resp = api.send_message(text)
|
32 |
-
response = resp['message']
|
33 |
-
# logger.info(f"response_: {response}")
|
34 |
-
except:
|
35 |
-
response = "Sorry, the chatGPT queue is full. Please try again in some time"
|
36 |
-
return response
|
37 |
|
38 |
def chat(message, chat_history):
|
39 |
out_chat = []
|
@@ -153,7 +137,7 @@ with gr.Blocks(title='Talk to catGPT') as demo:
|
|
153 |
)
|
154 |
translate_btn = gr.Button("Check Whisper first ? 👍")
|
155 |
|
156 |
-
whisper_task = gr.Radio(["
|
157 |
with gr.Row(elem_id="prompt_row"):
|
158 |
prompt_input = gr.Textbox(lines=2, label="Input text",show_label=True)
|
159 |
chat_history = gr.Textbox(lines=4, label="prompt", visible=False)
|
|
|
10 |
|
11 |
device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
|
12 |
|
13 |
+
whisper = gr.Interface.load(name="spaces/sanchit-gandhi/whisper-large-v2")
|
|
|
|
|
|
|
|
|
|
|
14 |
|
|
|
|
|
|
|
15 |
|
16 |
def translate_or_transcribe(audio, task):
|
17 |
+
return whisper(audio, None, task, fn_index=0)
|
|
|
|
|
18 |
|
19 |
def get_response_from_chatbot(text):
|
20 |
+
return text
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
|
22 |
def chat(message, chat_history):
|
23 |
out_chat = []
|
|
|
137 |
)
|
138 |
translate_btn = gr.Button("Check Whisper first ? 👍")
|
139 |
|
140 |
+
whisper_task = gr.Radio(["translate", "transcribe"], value="translate", show_label=False)
|
141 |
with gr.Row(elem_id="prompt_row"):
|
142 |
prompt_input = gr.Textbox(lines=2, label="Input text",show_label=True)
|
143 |
chat_history = gr.Textbox(lines=4, label="prompt", visible=False)
|